From f5d8121ea2900d55de2b5b43d221856213b185aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 9 May 2025 17:44:34 +0300 Subject: [PATCH] build-llvm: Use llvm-libtool-darwin if doing LTO macOS builds with a custom clang --- build-llvm.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build-llvm.sh b/build-llvm.sh index 6a229bb..b5786fc 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -298,6 +298,19 @@ if [ -z "$HOST" ] && [ "$(uname)" = "Darwin" ]; then # This silences a cmake warning. CMAKEFLAGS="$CMAKEFLAGS -DLLDB_USE_SYSTEM_DEBUGSERVER=ON" fi + if [ -n "$WITH_CLANG" ] && [ -n "$LTO" ]; then + # If doing LTO, we need to make sure other related tools are used. + # CMAKE_LIBTOOL is not a standard cmake tool, but an LLVM specific + # thing. It defaults to looking up the tool with xcrun rather than + # looking in paths first. + # If building for multiple architectures at once + # (CMAKE_OSX_ARCHITECTURES), we also need to provide a tool named + # "lipo" in the PATH (this is invoked by Clang directly, so we can't + # specify it here unless we pass in the option "-fuse-lipo="). If + # the LLVM CMake build wasn't using libtool, we would also need to + # specify LLVM_AR and LLVM_RANLIB. + CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_LIBTOOL=$(command -v llvm-libtool-darwin)" + fi fi TOOLCHAIN_ONLY=ON