Index: compiler-rt/trunk/cmake/config-ix.cmake =================================================================== --- compiler-rt/trunk/cmake/config-ix.cmake +++ compiler-rt/trunk/cmake/config-ix.cmake @@ -128,6 +128,24 @@ endif() endfunction() +# Returns a compiler and CFLAGS that should be used to run tests for the +# specific architecture. When cross-compiling, this is controled via +# COMPILER_RT_TEST_COMPILER and COMPILER_RT_TEST_COMPILER_CFLAGS. +macro(get_test_cc_for_arch arch cc_out cflags_out) + 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(${cc_out} ${COMPILER_RT_TEST_COMPILER}) + set(${cflags_out} ${COMPILER_RT_TEST_COMPILER_CFLAGS}) + else() + get_target_flags_for_arch(${arch} ${cflags_out}) + if(APPLE) + list(APPEND ${cflags_out} ${DARWIN_osx_CFLAGS}) + endif() + string(REPLACE ";" " " ${cflags_out} "${${cflags_out}}") + endif() +endmacro() + set(ARM64 aarch64) set(ARM32 arm armhf) set(X86 i386 i686) Index: compiler-rt/trunk/test/asan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/asan/CMakeLists.txt +++ compiler-rt/trunk/test/asan/CMakeLists.txt @@ -43,15 +43,7 @@ endif() string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX) get_bits_for_arch(${arch} ASAN_TEST_BITS) - 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(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} ASAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " ASAN_TEST_TARGET_CFLAGS "${ASAN_TEST_TARGET_CFLAGS}") - endif() + get_test_cc_for_arch(${arch} ASAN_TEST_TARGET_CC ASAN_TEST_TARGET_CFLAGS) if(ANDROID) set(ASAN_TEST_DYNAMIC True) else() Index: compiler-rt/trunk/test/dfsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/dfsan/CMakeLists.txt +++ compiler-rt/trunk/test/dfsan/CMakeLists.txt @@ -10,16 +10,7 @@ foreach(arch ${DFSAN_TEST_ARCH}) set(DFSAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" DFSAN_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(DFSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(DFSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} DFSAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " DFSAN_TEST_TARGET_CFLAGS "${DFSAN_TEST_TARGET_CFLAGS}") - endif() - + get_test_cc_for_arch(${arch} DFSAN_TEST_TARGET_CC DFSAN_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) Index: compiler-rt/trunk/test/lsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/lsan/CMakeLists.txt +++ compiler-rt/trunk/test/lsan/CMakeLists.txt @@ -10,16 +10,7 @@ foreach(arch ${LSAN_TEST_ARCH}) set(LSAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" LSAN_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(LSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(LSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} LSAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " LSAN_TEST_TARGET_CFLAGS "${LSAN_TEST_TARGET_CFLAGS}") - endif() - + get_test_cc_for_arch(${arch} LSAN_TEST_TARGET_CC LSAN_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(LSAN_LIT_TEST_MODE "Standalone") set(CONFIG_NAME ${ARCH_UPPER_CASE}LsanConfig) Index: compiler-rt/trunk/test/msan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/msan/CMakeLists.txt +++ compiler-rt/trunk/test/msan/CMakeLists.txt @@ -10,16 +10,7 @@ foreach(arch ${MSAN_TEST_ARCH}) set(MSAN_TEST_TARGET_ARCH ${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() - + get_test_cc_for_arch(${arch} MSAN_TEST_TARGET_CC MSAN_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) Index: compiler-rt/trunk/test/profile/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/profile/CMakeLists.txt +++ compiler-rt/trunk/test/profile/CMakeLists.txt @@ -14,13 +14,7 @@ foreach(arch ${PROFILE_TEST_ARCH}) set(PROFILE_TEST_TARGET_ARCH ${arch}) - if(${arch} MATCHES "arm|aarch64") - # This is only true if we're cross-compiling. - set(PROFILE_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} PROFILE_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " PROFILE_TEST_TARGET_CFLAGS "${PROFILE_TEST_TARGET_CFLAGS}") - endif() + 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.in Index: compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt +++ compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt @@ -27,14 +27,7 @@ foreach(arch ${TEST_ARCH}) set(SANITIZER_COMMON_LIT_TEST_MODE ${tool}) set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch}) - if(${arch} MATCHES "arm|aarch64") - # This is only true if we're cross-compiling. - set(SANITIZER_COMMON_TEST_TARGET_CFLAGS - ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}") - endif() + get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS) set(CONFIG_NAME ${tool}-${arch}-${OS_NAME}) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in Index: compiler-rt/trunk/test/tsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/tsan/CMakeLists.txt +++ compiler-rt/trunk/test/tsan/CMakeLists.txt @@ -24,15 +24,7 @@ foreach(arch ${TSAN_TEST_ARCH}) set(TSAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" TSAN_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(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(TSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} TSAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " TSAN_TEST_TARGET_CFLAGS "${TSAN_TEST_TARGET_CFLAGS}") - endif() + get_test_cc_for_arch(${arch} TSAN_TEST_TARGET_CC TSAN_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) Index: compiler-rt/trunk/test/ubsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/ubsan/CMakeLists.txt +++ compiler-rt/trunk/test/ubsan/CMakeLists.txt @@ -22,13 +22,7 @@ foreach(arch ${UBSAN_TEST_ARCH}) set(UBSAN_TEST_TARGET_ARCH ${arch}) - if(${arch} MATCHES "arm|aarch64") - # This is only true if we're cross-compiling. - set(UBSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} UBSAN_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS}") - endif() + get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) add_ubsan_testsuite("Standalone" ubsan ${arch}) if(COMPILER_RT_HAS_ASAN AND ";${ASAN_SUPPORTED_ARCH};" MATCHES ";${arch};") Index: compiler-rt/trunk/test/xray/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/xray/CMakeLists.txt +++ compiler-rt/trunk/test/xray/CMakeLists.txt @@ -14,17 +14,7 @@ foreach(arch ${XRAY_TEST_ARCH}) set(XRAY_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}-${OS_NAME}" XRAY_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(XRAY_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(XRAY_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - else() - get_target_flags_for_arch(${arch} XRAY_TEST_TARGET_CFLAGS) - string(REPLACE ";" " " XRAY_TEST_TARGET_CFLAGS "${XRAY_TEST_TARGET_CFLAGS}") - endif() - + get_test_cc_for_arch(${arch} XRAY_TEST_TARGET_CC XRAY_TEST_TARGET_CFLAGS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)