build-llvm: Add an option --use-linker=
This allows overriding which linker to use. Currently, building LLVM on Ubuntu 25.10 with these scripts fails, if LLD is available. This, because the GCC on that distribution produces object files that LLD (and gold) rejects during linking - see https://github.com/llvm/llvm-project/issues/156667 for details. By building with --use-linker=bfd, linking does succeed in that configuration. Also pass the same option through from build-all.sh.
This commit is contained in:
1 parent
9347c21f74
commit
e455d4c3cb
2 files changed
+11
-6
No files matched your search
+9
-4
@@ -40,6 +40,9 @@ while [ $# -gt 0 ]; do
|
||||
WITH_CLANG=1
|
||||
BUILDDIR="$BUILDDIR-withclang"
|
||||
;;
|
||||
--use-linker=*)
|
||||
USE_LINKER="${1#*=}"
|
||||
;;
|
||||
--thinlto)
|
||||
LTO="thin"
|
||||
BUILDDIR="$BUILDDIR-thinlto"
|
||||
@@ -104,7 +107,7 @@ done
|
||||
BUILDDIR="$BUILDDIR$ASSERTSSUFFIX"
|
||||
if [ -z "$CHECKOUT_ONLY" ]; then
|
||||
if [ -z "$PREFIX" ]; then
|
||||
echo $0 [--enable-asserts] [--with-clang] [--thinlto] [--lto] [--instrumented[=type]] [--pgo[=profile]] [--disable-dylib] [--full-llvm] [--with-python] [--disable-lldb] [--disable-clang-tools-extra] [--host=triple] [--no-llvm-tool-reuse] [--macos-native-tools] dest
|
||||
echo $0 [--enable-asserts] [--with-clang] [--use-linker=linker] [--thinlto] [--lto] [--instrumented[=type]] [--pgo[=profile]] [--disable-dylib] [--full-llvm] [--with-python] [--disable-lldb] [--disable-clang-tools-extra] [--host=triple] [--no-llvm-tool-reuse] [--macos-native-tools] dest
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -190,7 +193,7 @@ if [ -n "$HOST" ]; then
|
||||
if [ -n "$WITH_CLANG" ]; then
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=clang"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=clang++"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=${USE_LINKER:-lld}"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_ASM_COMPILER_TARGET=$HOST"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER_TARGET=$HOST"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER_TARGET=$HOST"
|
||||
@@ -267,12 +270,14 @@ elif [ -n "$WITH_CLANG" ]; then
|
||||
# tools.
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=clang"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=clang++"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld"
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=${USE_LINKER:-lld}"
|
||||
else
|
||||
# Native compilation with the system default compiler.
|
||||
|
||||
# Use a faster linker, if available.
|
||||
if command -v ld.lld >/dev/null; then
|
||||
if [ -n "$USE_LINKER" ]; then
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=$USE_LINKER"
|
||||
elif command -v ld.lld >/dev/null; then
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=lld"
|
||||
elif command -v ld.gold >/dev/null; then
|
||||
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_USE_LINKER=gold"
|
||||
|
||||
Reference in new issue
Block a user