diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -497,7 +497,7 @@ if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD) set(COMPILER_RT_HAS_LLD TRUE) else() - set(COMPILER_RT_HAS_LLD FALSE) + set(COMPILER_RT_HAS_LLD ${COMPILER_RT_HAS_FUSE_LD_LLD_FLAG}) endif() endif() pythonize_bool(COMPILER_RT_HAS_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 @@ -146,6 +146,7 @@ # Linker flags. check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT) +check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG) if(ANDROID) check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL) diff --git a/compiler-rt/test/hwasan/CMakeLists.txt b/compiler-rt/test/hwasan/CMakeLists.txt --- a/compiler-rt/test/hwasan/CMakeLists.txt +++ b/compiler-rt/test/hwasan/CMakeLists.txt @@ -24,7 +24,9 @@ if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND HWASAN_TEST_DEPS hwasan) if(COMPILER_RT_HAS_LLD) - list(APPEND HWASAN_TEST_DEPS lld) + if (TARGET lld) + list(APPEND HWASAN_TEST_DEPS lld) + endif() endif() endif() diff --git a/compiler-rt/test/msan/CMakeLists.txt b/compiler-rt/test/msan/CMakeLists.txt --- a/compiler-rt/test/msan/CMakeLists.txt +++ b/compiler-rt/test/msan/CMakeLists.txt @@ -20,7 +20,9 @@ endif() if (${lld}) set(CONFIG_NAME "lld-${CONFIG_NAME}") - list(APPEND MSAN_TEST_DEPS lld) + if (TARGET lld) + list(APPEND MSAN_TEST_DEPS lld) + endif() endif() set(MSAN_TEST_USE_THINLTO ${thinlto}) set(MSAN_TEST_USE_LLD ${lld}) diff --git a/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt --- a/compiler-rt/test/ubsan/CMakeLists.txt +++ b/compiler-rt/test/ubsan/CMakeLists.txt @@ -8,7 +8,9 @@ set(CONFIG_NAME ${UBSAN_LIT_TEST_MODE}) if (${lld}) set(CONFIG_NAME ${CONFIG_NAME}-lld) - list(APPEND UBSAN_TEST_DEPS lld) + if (TARGET lld) + list(APPEND UBSAN_TEST_DEPS lld) + endif() endif() if (${thinlto}) set(CONFIG_NAME ${CONFIG_NAME}-thinlto) @@ -28,7 +30,6 @@ macro(add_ubsan_testsuites test_mode sanitizer arch) add_ubsan_testsuite(${test_mode} ${sanitizer} ${arch} False False) - if(COMPILER_RT_HAS_LLD AND arch STREQUAL "x86_64" AND NOT (APPLE OR WIN32)) add_ubsan_testsuite(${test_mode} ${sanitizer} ${arch} True False) endif()