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 ASSERTS=ON
ASSERTSSUFFIX="-asserts" ASSERTSSUFFIX="-asserts"
;; ;;
--stage2) --with-clang)
STAGE2=1 WITH_CLANG=1
BUILDDIR="$BUILDDIR-stage2" BUILDDIR="$BUILDDIR-withclang"
;; ;;
--thinlto) --thinlto)
LTO="thin" LTO="thin"
@@ -77,7 +77,7 @@ done
BUILDDIR="$BUILDDIR$ASSERTSSUFFIX" BUILDDIR="$BUILDDIR$ASSERTSSUFFIX"
if [ -z "$CHECKOUT_ONLY" ]; then if [ -z "$CHECKOUT_ONLY" ]; then
if [ -z "$PREFIX" ]; 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 exit 1
fi fi
@@ -220,9 +220,9 @@ if [ -n "$HOST" ]; then
CMAKEFLAGS="$CMAKEFLAGS -DPython3_INCLUDE_DIRS=$PYTHON_INCLUDE_DIR" CMAKEFLAGS="$CMAKEFLAGS -DPython3_INCLUDE_DIRS=$PYTHON_INCLUDE_DIR"
CMAKEFLAGS="$CMAKEFLAGS -DPython3_LIBRARIES=$PYTHON_LIB" CMAKEFLAGS="$CMAKEFLAGS -DPython3_LIBRARIES=$PYTHON_LIB"
fi fi
elif [ -n "$STAGE2" ]; then elif [ -n "$WITH_CLANG" ]; then
# Build using an earlier built and installed clang in the target directory # Build using clang and lld (from $PATH), rather than the system default
export PATH="$PREFIX/bin:$PATH" # tools.
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=clang" CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=clang"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=clang++" CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=clang++"
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld" CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld"