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.
This commit is contained in:
Martin Storsjö committed 2025-06-25 11:51:06 +03:00
1 parent 07c6640a17
commit 5f28a085f5
1 file changed
+7 -7
+7 -7
View File
@@ -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"