Index: test/cfi/CMakeLists.txt =================================================================== --- test/cfi/CMakeLists.txt +++ test/cfi/CMakeLists.txt @@ -1,14 +1,36 @@ +set(CFI_TESTSUITES) + +set(CFI_LIT_TEST_USE_LLD 0) set(CFI_LIT_TEST_MODE Standalone) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Standalone/lit.site.cfg - ) +) +list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Standalone) set(CFI_LIT_TEST_MODE Devirt) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Devirt/lit.site.cfg +) +list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Devirt) + +if(NOT APPLE AND COMPILER_RT_HAS_LLD) + set(CFI_LIT_TEST_USE_LLD 1) + set(CFI_LIT_TEST_MODE Standalone) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Standalone-lld/lit.site.cfg + ) + list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Standalone-lld) + + set(CFI_LIT_TEST_MODE Devirt) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Devirt-lld/lit.site.cfg ) + list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Devirt-lld) +endif() set(CFI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) list(APPEND CFI_TEST_DEPS @@ -34,7 +56,7 @@ LTO ) endif() - if(WIN32 AND COMPILER_RT_HAS_LLD) + if(NOT APPLE AND COMPILER_RT_HAS_LLD) list(APPEND CFI_TEST_DEPS lld ) @@ -42,13 +64,11 @@ endif() add_lit_testsuite(check-cfi "Running the cfi regression tests" - ${CMAKE_CURRENT_BINARY_DIR}/Standalone - ${CMAKE_CURRENT_BINARY_DIR}/Devirt + ${CFI_TESTSUITES} DEPENDS ${CFI_TEST_DEPS}) add_lit_target(check-cfi-and-supported "Running the cfi regression tests" - ${CMAKE_CURRENT_BINARY_DIR}/Standalone - ${CMAKE_CURRENT_BINARY_DIR}/Devirt + ${CFI_TESTSUITES} PARAMS check_supported=1 DEPENDS ${CFI_TEST_DEPS}) Index: test/cfi/lit.site.cfg.in =================================================================== --- test/cfi/lit.site.cfg.in +++ test/cfi/lit.site.cfg.in @@ -1,6 +1,7 @@ @LIT_SITE_CFG_IN_HEADER@ config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@" +config.lit_test_use_lld = @CFI_LIT_TEST_USE_LLD@ lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -180,6 +180,9 @@ return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) def is_linux_lto_supported(): + if config.lit_test_use_lld: + return True + if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): return False @@ -202,7 +205,10 @@ elif config.host_os == 'Linux' and is_linux_lto_supported(): config.lto_supported = True config.lto_launch = [] - config.lto_flags = ["-fuse-ld=gold"] + if config.lit_test_use_lld: + config.lto_flags = ["-fuse-ld=lld", "-Wl,-rpath,%T"] + else: + config.lto_flags = ["-fuse-ld=gold"] elif config.host_os == 'Windows' and is_windows_lto_supported(): config.lto_supported = True config.lto_launch = []