diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt --- a/compiler-rt/test/asan/CMakeLists.txt +++ b/compiler-rt/test/asan/CMakeLists.txt @@ -45,6 +45,7 @@ list(REMOVE_ITEM ASAN_TEST_ARCH x86_64) endif() +set(LIT_SITE_MULTI_CFG_ASAN "CompilerRT ASAN") foreach(arch ${ASAN_TEST_ARCH}) set(ASAN_TEST_TARGET_ARCH ${arch}) set(ASAN_TEST_APPLE_PLATFORM "osx") @@ -61,6 +62,7 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + MULTI_CONFIG LIT_SITE_MULTI_CFG_ASAN ) list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) @@ -70,12 +72,18 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + MULTI_CONFIG LIT_SITE_MULTI_CFG_ASAN + ) list(APPEND ASAN_DYNAMIC_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endif() endforeach() +configure_lit_site_multi_cfg(${LIT_SITE_MULTI_CFG_ASAN} + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.multi.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) + # iOS and iOS simulator test suites # These are not added into "check-all", in order to run these tests, use # "check-asan-iossim-x86_64" and similar. They also require that an extra env diff --git a/compiler-rt/test/asan/lit.site.cfg.py.in b/compiler-rt/test/asan/lit.site.cfg.py.in --- a/compiler-rt/test/asan/lit.site.cfg.py.in +++ b/compiler-rt/test/asan/lit.site.cfg.py.in @@ -8,6 +8,7 @@ config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@" config.asan_dynamic = @ASAN_TEST_DYNAMIC@ config.target_arch = "@ASAN_TEST_TARGET_ARCH@" +config.test_exec_root = os.path.dirname(__file__) # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") diff --git a/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt --- a/compiler-rt/test/fuzzer/CMakeLists.txt +++ b/compiler-rt/test/fuzzer/CMakeLists.txt @@ -22,7 +22,13 @@ list(APPEND LIBFUZZER_TEST_DEPS FuzzedDataProviderUnitTests) endif() -add_custom_target(check-fuzzer) +add_lit_testsuite(check-fuzzer + "Running libFuzzer tests for all configurations" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${LIBFUZZER_TEST_DEPS}) +if(TEST_DEPS) + add_dependencies(check-fuzzer ${TEST_DEPS}) +endif() if(COMPILER_RT_INCLUDE_TESTS) # libFuzzer unit tests. @@ -36,6 +42,7 @@ add_dependencies(check-fuzzer check-fuzzer-unit) endif() +set(LIT_SITE_MULTI_CFG_FUZZER "CompilerRT fuzzer") macro(test_fuzzer stdlib) cmake_parse_arguments(TEST "" "" "DEPS" ${ARGN}) string(REPLACE "+" "x" stdlib_name ${stdlib}) @@ -51,30 +58,31 @@ set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER}) get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS) - set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) + set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${STDLIB_CAPITALIZED}") set(LIBFUZZER_TEST_APPLE_PLATFORM "osx") - + set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) set(LIBFUZZER_TEST_STDLIB ${stdlib}) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}${STDLIB_CAPITALIZED}${OS_NAME}Config) + set(LIBFUZZER_TEST_EXEC_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) # LIT-based libFuzzer tests. configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + ${LIBFUZZER_TEST_EXEC_DIR}/lit.site.cfg.py + MULTI_CONFIG LIT_SITE_MULTI_CFG_FUZZER ) add_lit_testsuite(check-fuzzer-${stdlib_name}-${arch} "Running libFuzzer ${stdlib} tests for arch ${arch}" - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ + ${LIBFUZZER_TEST_EXEC_DIR} DEPENDS ${LIBFUZZER_TEST_DEPS}) if(TEST_DEPS) add_dependencies(check-fuzzer-${stdlib_name}-${arch} ${TEST_DEPS}) endif() set_target_properties(check-fuzzer-${stdlib_name}-${arch} PROPERTIES FOLDER "Compiler-RT Tests") - add_dependencies(check-fuzzer check-fuzzer-${stdlib_name}-${arch}) endforeach() endmacro() @@ -88,6 +96,10 @@ endif() endif() +configure_lit_site_multi_cfg(${LIT_SITE_MULTI_CFG_FUZZER} + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.multi.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) + if (APPLE) set(EXCLUDE_FROM_ALL ON) set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER}) diff --git a/compiler-rt/test/fuzzer/lit.site.cfg.py.in b/compiler-rt/test/fuzzer/lit.site.cfg.py.in --- a/compiler-rt/test/fuzzer/lit.site.cfg.py.in +++ b/compiler-rt/test/fuzzer/lit.site.cfg.py.in @@ -6,6 +6,7 @@ config.stdlib = "@LIBFUZZER_TEST_STDLIB@" config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@" config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@" +config.test_exec_root = os.path.dirname(__file__) config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@" config.cmake_binary_dir = "@CMAKE_BINARY_DIR@" diff --git a/compiler-rt/test/profile/CMakeLists.txt b/compiler-rt/test/profile/CMakeLists.txt --- a/compiler-rt/test/profile/CMakeLists.txt +++ b/compiler-rt/test/profile/CMakeLists.txt @@ -1,7 +1,3 @@ -set(PROFILE_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(PROFILE_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) - -set(PROFILE_TESTSUITES) set(PROFILE_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND PROFILE_TEST_DEPS profile llvm-profdata llvm-cov) @@ -12,18 +8,21 @@ darwin_filter_host_archs(PROFILE_SUPPORTED_ARCH PROFILE_TEST_ARCH) endif() +set(LIT_SITE_MULTI_CFG_PROFILE "Compiler-RT profile") foreach(arch ${PROFILE_TEST_ARCH}) set(PROFILE_TEST_TARGET_ARCH ${arch}) get_test_cc_for_arch(${arch} PROFILE_TEST_TARGET_CC PROFILE_TEST_TARGET_CFLAGS) - set(CONFIG_NAME Profile-${arch}) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + ${CMAKE_CURRENT_BINARY_DIR}/${arch}/lit.site.cfg.py + MULTI_CONFIG LIT_SITE_MULTI_CFG_PROFILE ) - list(APPEND PROFILE_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() add_lit_testsuite(check-profile "Running the profile tests" - ${PROFILE_TESTSUITES} + ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${PROFILE_TEST_DEPS}) set_target_properties(check-profile PROPERTIES FOLDER "Compiler-RT Misc") +configure_lit_site_multi_cfg(${LIT_SITE_MULTI_CFG_PROFILE} + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.multi.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) diff --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py --- a/compiler-rt/test/profile/lit.cfg.py +++ b/compiler-rt/test/profile/lit.cfg.py @@ -17,11 +17,6 @@ # Setup source root. config.test_source_root = os.path.dirname(__file__) -# Setup executable root. -if hasattr(config, 'profile_lit_binary_dir') and \ - config.profile_lit_binary_dir is not None: - config.test_exec_root = os.path.join(config.profile_lit_binary_dir, config.name) - if config.host_os in ['Linux']: extra_link_flags = ["-ldl"] elif config.host_os in ['Windows']: diff --git a/compiler-rt/test/profile/lit.site.cfg.py.in b/compiler-rt/test/profile/lit.site.cfg.py.in --- a/compiler-rt/test/profile/lit.site.cfg.py.in +++ b/compiler-rt/test/profile/lit.site.cfg.py.in @@ -1,12 +1,12 @@ @LIT_SITE_CFG_IN_HEADER@ # Tool-specific config options. -config.profile_lit_binary_dir = "@PROFILE_LIT_BINARY_DIR@" config.target_cflags = "@PROFILE_TEST_TARGET_CFLAGS@" config.target_arch = "@PROFILE_TEST_TARGET_ARCH@" +config.test_exec_root = os.path.dirname(__file__) # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") # Load tool-specific config that would do the real work. -lit_config.load_config(config, "@PROFILE_LIT_SOURCE_DIR@/lit.cfg.py") +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") 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 @@ -3,6 +3,8 @@ set(UBSAN_TESTSUITES) set(UBSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) +set(LIT_SITE_MULTI_CFG_UBSAN "Compiler-RT ubsan") + macro(add_ubsan_testsuite test_mode sanitizer arch lld thinlto) set(UBSAN_LIT_TEST_MODE "${test_mode}") set(CONFIG_NAME ${UBSAN_LIT_TEST_MODE}) @@ -21,7 +23,10 @@ set(CONFIG_NAME ${CONFIG_NAME}-${arch}) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + MULTI_CONFIG + LIT_SITE_MULTI_CFG_UBSAN + ) list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND UBSAN_TEST_DEPS ${sanitizer}) @@ -64,6 +69,10 @@ endif() endforeach() +configure_lit_site_multi_cfg(${LIT_SITE_MULTI_CFG_UBSAN} + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.multi.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) + macro(add_ubsan_device_testsuite test_mode sanitizer platform arch) # Note we expect the caller to have already set UBSAN_TEST_TARGET_CFLAGS set(UBSAN_LIT_TEST_MODE "${test_mode}") diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.cfg.py rename from compiler-rt/test/ubsan/lit.common.cfg.py rename to compiler-rt/test/ubsan/lit.cfg.py diff --git a/compiler-rt/test/ubsan/lit.site.cfg.py.in b/compiler-rt/test/ubsan/lit.site.cfg.py.in --- a/compiler-rt/test/ubsan/lit.site.cfg.py.in +++ b/compiler-rt/test/ubsan/lit.site.cfg.py.in @@ -8,9 +8,10 @@ config.use_lld = @UBSAN_TEST_USE_LLD@ config.use_thinlto = @UBSAN_TEST_USE_THINLTO@ config.apple_platform = "@UBSAN_TEST_APPLE_PLATFORM@" +config.test_exec_root = os.path.dirname(__file__) # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") # Load tool-specific config that would do the real work. -lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg.py") +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.cfg.py") diff --git a/compiler-rt/test/ubsan_minimal/CMakeLists.txt b/compiler-rt/test/ubsan_minimal/CMakeLists.txt --- a/compiler-rt/test/ubsan_minimal/CMakeLists.txt +++ b/compiler-rt/test/ubsan_minimal/CMakeLists.txt @@ -11,12 +11,15 @@ list(APPEND UBSAN_TEST_DEPS ubsan-minimal) endif() +set(LIT_SITE_MULTI_CFG_UBSAN_MINIMAL "Compiler-RT usban minimal") foreach(arch ${UBSAN_TEST_ARCH}) get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) set(CONFIG_NAME ${arch}) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + MULTI_CONFIG LIT_SITE_MULTI_CFG_UBSAN_MINIMAL + ) list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() @@ -24,3 +27,6 @@ ${UBSAN_TESTSUITES} DEPENDS ${UBSAN_TEST_DEPS}) set_target_properties(check-ubsan-minimal PROPERTIES FOLDER "Compiler-RT Misc") +configure_lit_site_multi_cfg(${LIT_SITE_MULTI_CFG_UBSAN_MINIMAL} + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.multi.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) diff --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py b/compiler-rt/test/ubsan_minimal/lit.cfg.py rename from compiler-rt/test/ubsan_minimal/lit.common.cfg.py rename to compiler-rt/test/ubsan_minimal/lit.cfg.py diff --git a/compiler-rt/test/ubsan_minimal/lit.site.cfg.py.in b/compiler-rt/test/ubsan_minimal/lit.site.cfg.py.in --- a/compiler-rt/test/ubsan_minimal/lit.site.cfg.py.in +++ b/compiler-rt/test/ubsan_minimal/lit.site.cfg.py.in @@ -3,9 +3,10 @@ # Tool-specific config options. config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@" config.target_arch = "@UBSAN_TEST_TARGET_ARCH@" +config.test_exec_root = os.path.dirname(__file__) # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") # Load tool-specific config that would do the real work. -lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg.py") +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.cfg.py") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1379,13 +1379,18 @@ endif () endmacro() +function(add_entry_to_lit_config_map key val) + set_property(GLOBAL APPEND_STRING + PROPERTY LLVM_LIT_CONFIG_MAP "map_config('${key}', '${val}')\n") +endfunction() + # This function provides an automatic way to 'configure'-like generate a file # based on a set of common and custom variables, specifically targeting the # variables needed for the 'lit.site.cfg' files. This function bundles the # common variables that any Lit instance is likely to need, and custom # variables can be passed in. function(configure_lit_site_cfg site_in site_out) - cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING" ${ARGN}) + cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING;MULTI_CONFIG" ${ARGN}) if ("${ARG_MAIN_CONFIG}" STREQUAL "") get_filename_component(INPUT_DIR ${site_in} DIRECTORY) @@ -1395,6 +1400,11 @@ set(ARG_OUTPUT_MAPPING "${site_out}") endif() + if (NOT "${ARG_MULTI_CONFIG}" STREQUAL "") + string(APPEND ${ARG_MULTI_CONFIG} "\n${site_out}") + set(${ARG_MULTI_CONFIG} ${${ARG_MULTI_CONFIG}} PARENT_SCOPE) + endif() + foreach(c ${LLVM_TARGETS_TO_BUILD}) set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") endforeach(c) @@ -1452,13 +1462,16 @@ configure_file(${site_in} ${site_out} @ONLY) if (EXISTS "${ARG_MAIN_CONFIG}") - set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')") - get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP) - set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_CONFIG_MAP}\n${PYTHON_STATEMENT}") - set_property(GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP ${LLVM_LIT_CONFIG_MAP}) + add_entry_to_lit_config_map(${ARG_MAIN_CONFIG} ${site_out}) endif() endfunction() +function(configure_lit_site_multi_cfg site_outs site_multi_out main_config) + # Generate test suite multi-config file for 'config_map' + file(GENERATE OUTPUT ${site_multi_out} CONTENT "${site_outs}") + add_entry_to_lit_config_map(${main_config} ${site_multi_out}) +endfunction() + function(dump_all_cmake_variables) get_cmake_property(_variableNames VARIABLES) foreach (_variableName ${_variableNames})