build-llvm: Add a --macos-native-tools option

This augments the result of an earlier build, with tools required
for building for macOS with the tools built with build-llvm.sh.
This commit is contained in:
Martin Storsjö committed 2025-06-25 11:51:06 +03:00
1 parent f5d8121ea2
commit 19f1c90a15
1 file changed
+22 -1
+22 -1
View File
@@ -68,6 +68,9 @@ while [ $# -gt 0 ]; do
--no-llvm-tool-reuse)
NO_LLVM_TOOL_REUSE=1
;;
--macos-native-tools)
MACOS_NATIVE_TOOLS=1
;;
*)
PREFIX="$1"
;;
@@ -77,7 +80,7 @@ done
BUILDDIR="$BUILDDIR$ASSERTSSUFFIX"
if [ -z "$CHECKOUT_ONLY" ]; then
if [ -z "$PREFIX" ]; then
echo $0 [--enable-asserts] [--with-clang] [--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] [--macos-native-tools] dest
exit 1
fi
@@ -331,6 +334,24 @@ fi
[ -z "$CLEAN" ] || rm -rf $BUILDDIR
mkdir -p $BUILDDIR
cd $BUILDDIR
if [ -n "$MACOS_NATIVE_TOOLS" ]; then
# Build tools needed for targeting macOS with LTO.
#
# The install-<tool>(-stripped) targets are unavailable for
# tools that are excluded due to LLVM_INSTALL_TOOLCHAIN_ONLY=ON and
# LLVM_TOOLCHAIN_TOOLS, so install those manually.
cmake --build . --target llvm-lipo --target llvm-libtool-darwin
# Install ld64.lld, required for -fuse-ld=lld
cmake --install . --strip --component lld
# Install llvm-libtool-darwin and lipo, needed for building with LTO.
# See the comment further above for more details about this.
cp bin/llvm-lipo bin/llvm-libtool-darwin $PREFIX/bin
strip $PREFIX/bin/llvm-lipo $PREFIX/bin/llvm-libtool-darwin
ln -sf llvm-lipo $PREFIX/bin/lipo
exit 0
fi
[ -n "$NO_RECONF" ] || rm -rf CMake*
cmake \
${CMAKE_GENERATOR+-G} "$CMAKE_GENERATOR" \