diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -622,7 +622,7 @@ endif() endif() -if(ANDROID) +if(ANDROID OR LLVM_ENABLE_LLD OR LLVM_USE_LINKER STREQUAL "lld") set(COMPILER_RT_HAS_LLD TRUE) set(COMPILER_RT_TEST_USE_LLD TRUE) append_list_if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG -fuse-ld=lld SANITIZER_COMMON_LINK_FLAGS) @@ -630,7 +630,13 @@ if(COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) set(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT FALSE) endif() +else() + if (LLVM_USE_LINKER) + append_list_if(COMPILER_RT_HAS_FUSE_LD_LLVM_LINKER "-fuse-ld=${LLVM_USE_LINKER}" SANITIZER_COMMON_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_FUSE_LD_LLVM_LINKER "-fuse-ld=${LLVM_USE_LINKER}" COMPILER_RT_UNITTEST_LINK_FLAGS) + endif() endif() + pythonize_bool(COMPILER_RT_HAS_LLD) pythonize_bool(COMPILER_RT_TEST_USE_LLD) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -169,6 +169,9 @@ # Linker flags. compiler_rt_check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) compiler_rt_check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) +if (LLVM_USE_LINKER) + compiler_rt_check_linker_flag("-fuse-ld=${LLVM_USE_LINKER}" COMPILER_RT_HAS_FUSE_LD_LLVM_LINKER) +endif() set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat") compiler_rt_check_linker_flag("${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)