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