From 5f28a085f514d2e85210dc3e2ef868e26e2d6a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 8 May 2025 16:33:54 +0300 Subject: [PATCH] build-llvm: Change the (unused) --stage2 option into --with-clang Don't use tools from $PREFIX/bin automatically; this can be confusing and problematic. If running with $PREFIX/bin in path, the build at this stage gets reconfigured if rebuilding after installing clang. For multistage builds, install into separate toolchain directories and add the right one to $PATH before invoking build-llvm.sh. If one really wants to use the tools from $PREFIX for a new build into the same directory, one has to add that directory to the path manually. --- build-llvm.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build-llvm.sh b/build-llvm.sh index de2c4a4..7e6fe42 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -35,9 +35,9 @@ while [ $# -gt 0 ]; do ASSERTS=ON ASSERTSSUFFIX="-asserts" ;; - --stage2) - STAGE2=1 - BUILDDIR="$BUILDDIR-stage2" + --with-clang) + WITH_CLANG=1 + BUILDDIR="$BUILDDIR-withclang" ;; --thinlto) LTO="thin" @@ -77,7 +77,7 @@ done BUILDDIR="$BUILDDIR$ASSERTSSUFFIX" if [ -z "$CHECKOUT_ONLY" ]; then if [ -z "$PREFIX" ]; then - echo $0 [--enable-asserts] [--stage2] [--thinlto] [--lto] [--disable-dylib] [--full-llvm] [--with-python] [--disable-lldb] [--disable-clang-tools-extra] [--host=triple] dest + echo $0 [--enable-asserts] [--with-clang] [--thinlto] [--lto] [--disable-dylib] [--full-llvm] [--with-python] [--disable-lldb] [--disable-clang-tools-extra] [--host=triple] dest exit 1 fi @@ -220,9 +220,9 @@ if [ -n "$HOST" ]; then CMAKEFLAGS="$CMAKEFLAGS -DPython3_INCLUDE_DIRS=$PYTHON_INCLUDE_DIR" CMAKEFLAGS="$CMAKEFLAGS -DPython3_LIBRARIES=$PYTHON_LIB" fi -elif [ -n "$STAGE2" ]; then - # Build using an earlier built and installed clang in the target directory - export PATH="$PREFIX/bin:$PATH" +elif [ -n "$WITH_CLANG" ]; then + # Build using clang and lld (from $PATH), rather than the system default + # tools. CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=clang" CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=clang++" CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld"