Skip to content

Commit 10ffe01

Browse files
committed
Change build script for C++ modules with recent Clang
1 parent 6c10fca commit 10ffe01

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

modules/build/build-clang-modules.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
#!/bin/sh
22

33
# This script will compile all files with .cpp extension in the parent directory
4-
# Clang version 12 (or newer) C++ modules version
4+
# Clang version 16 (or newer) C++ modules version
5+
6+
if [ -z "$CLANG_PREFIX" ] ; then
7+
CLANG_PREFIX="/usr"
8+
fi
9+
10+
if [ -z "$CLANG_PCM" ] ; then
11+
CLANG_PCM="./std.pcm"
12+
fi
13+
14+
CLANG="$CLANG_PREFIX/bin/clang++"
15+
16+
if [ ! -f "$CLANG_PCM" ] ; then
17+
echo "Compiling library module..."
18+
if [ ! -f "$CLANG_PREFIX/share/libc++/v1/std.cppm" ] ; then
19+
echo "Error: Could not find file $CLANG_PREFIX/share/libc++/v1/std.cppm"
20+
echo "Please set environment variable CLANG_PREFIX and re-run script"
21+
exit 1
22+
fi
23+
LD_LIBRARY_PATH="$CLANG_PREFIX/lib":"$CLANG_PREFIX/lib/x86_64-unknown-linux-gnu" \
24+
"$CLANG" -std=c++23 -stdlib=libc++ -Wno-reserved-identifier -Wno-reserved-module-identifier \
25+
--precompile -o "$CLANG_PCM" "$CLANG_PREFIX/share/libc++/v1/std.cppm"
26+
fi
527

628
failures=0
729
for PROGRAM in ../*.cpp ; do
830
BASE="$(basename $PROGRAM)"
931
echo "$BASE..."
1032
failed=""
11-
clang++ -fmodules -std=c++20 -stdlib=libc++ -o ${BASE%.cpp} $PROGRAM >/dev/null 2>&1 || failed="y"
33+
LD_LIBRARY_PATH="$CLANG_PREFIX/lib":"$CLANG_PREFIX/lib/x86_64-unknown-linux-gnu" \
34+
"$CLANG" -fmodule-file=std="$CLANG_PCM" -std=c++23 -stdlib=libc++ -o ${BASE%.cpp} $PROGRAM || failed="y"
1235
if [ -n "$failed" ] ; then
1336
echo "Failed to compile $BASE"
1437
failures=$((failures+1))

0 commit comments

Comments
 (0)