diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index cfbd07a40e15..c7e86946bcf3 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -112,7 +112,7 @@ if (COMPILER_RT_STANDALONE_BUILD) endif() # Ensure that fat libraries are built correctly on Darwin - if(CMAKE_HOST_APPLE AND APPLE) + if(APPLE) include(UseLibtool) endif() diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 9c272afdc0c7..eb533a7325c7 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -20,7 +20,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) if(APPLE) include(CompilerRTDarwinUtils) endif() - if(CMAKE_HOST_APPLE AND APPLE) + if(APPLE) include(UseLibtool) endif() include(AddCompilerRT) diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake index 0aeaf663ad1c..db3a536b0c24 100644 --- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake +++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake @@ -53,8 +53,10 @@ function(llvm_ExternalProject_Add name source_dir) endforeach() if(NOT ARG_TOOLCHAIN_TOOLS) - set(ARG_TOOLCHAIN_TOOLS clang lld llvm-ar llvm-lipo llvm-ranlib llvm-nm llvm-objdump) - if(NOT _cmake_system_name STREQUAL Darwin) + set(ARG_TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objdump) + if(_cmake_system_name STREQUAL Darwin) + list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo) + else() # TODO: These tools don't fully support Mach-O format yet. list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip) endif() @@ -144,6 +146,9 @@ function(llvm_ExternalProject_Add name source_dir) if(llvm-ar IN_LIST TOOLCHAIN_TOOLS) list(APPEND compiler_args -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar${CMAKE_EXECUTABLE_SUFFIX}) endif() + if(llvm-libtool-darwin IN_LIST TOOLCHAIN_TOOLS) + list(APPEND compiler_args -DCMAKE_LIBTOOL=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-libtool-darwin${CMAKE_EXECUTABLE_SUFFIX}) + endif() if(llvm-lipo IN_LIST TOOLCHAIN_TOOLS) list(APPEND compiler_args -DCMAKE_LIPO=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lipo${CMAKE_EXECUTABLE_SUFFIX}) endif()