Index: test/msan/CMakeLists.txt =================================================================== --- test/msan/CMakeLists.txt +++ test/msan/CMakeLists.txt @@ -1,8 +1,32 @@ set(MSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) +set(MSAN_TESTSUITES) + +set(MSAN_TEST_ARCH ${MSAN_SUPPORTED_ARCH}) +if(APPLE) + darwin_filter_host_archs(MSAN_SUPPORTED_ARCH MSAN_TEST_ARCH) +endif() + +foreach(arch ${MSAN_TEST_ARCH}) + string(TOLOWER "-${arch}" MSAN_TEST_CONFIG_SUFFIX) + if(ANDROID OR ${arch} MATCHES "arm|aarch64") + # This is only true if we are cross-compiling. + # Build all tests with host compiler and use host tools. + set(MSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) + set(MSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) + else() + get_target_flags_for_arch(${arch} MSAN_TEST_TARGET_CFLAGS) + string(REPLACE ";" " " MSAN_TEST_TARGET_CFLAGS "${MSAN_TEST_TARGET_CFLAGS}") + endif() + + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) + + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + list(APPEND MSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) +endforeach() set(MSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) if(NOT COMPILER_RT_STANDALONE_BUILD) @@ -17,7 +41,7 @@ endif() add_lit_testsuite(check-msan "Running the MemorySanitizer tests" - ${CMAKE_CURRENT_BINARY_DIR} + ${MSAN_TESTSUITES} DEPENDS ${MSAN_TEST_DEPS} ) set_target_properties(check-msan PROPERTIES FOLDER "MSan tests") Index: test/msan/lit.cfg =================================================================== --- test/msan/lit.cfg +++ test/msan/lit.cfg @@ -3,17 +3,18 @@ import os # Setup config name. -config.name = 'MemorySanitizer' +config.name = 'MemorySanitizer' + config.name_suffix # Setup source root. config.test_source_root = os.path.dirname(__file__) # Setup default compiler flags used with -fsanitize=memory option. -clang_msan_cflags = ["-fsanitize=memory", - "-mno-omit-leaf-frame-pointer", - "-fno-omit-frame-pointer", - "-fno-optimize-sibling-calls", - "-m64"] + config.debug_info_flags +clang_msan_cflags = (["-fsanitize=memory", + "-mno-omit-leaf-frame-pointer", + "-fno-omit-frame-pointer", + "-fno-optimize-sibling-calls"] + + [config.target_cflags] + + config.debug_info_flags) # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD. if config.host_os == 'FreeBSD': clang_msan_cflags += ["-lexecinfo"] Index: test/msan/lit.site.cfg.in =================================================================== --- test/msan/lit.site.cfg.in +++ test/msan/lit.site.cfg.in @@ -1,5 +1,11 @@ +## Autogenerated by LLVM/Clang configuration. +# Do not edit! + # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") +# Tool-specific config options. +config.name_suffix = "@MSAN_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@" # Load tool-specific config that would do the real work. lit_config.load_config(config, "@MSAN_LIT_SOURCE_DIR@/lit.cfg")