diff options
author | Kuba Mracek <mracek@apple.com> | 2016-11-29 19:25:53 +0000 |
---|---|---|
committer | Kuba Mracek <mracek@apple.com> | 2016-11-29 19:25:53 +0000 |
commit | f5b57a6e6c35536268c680c785dff33d1b587c97 (patch) | |
tree | fd7839bd688a4bed34c67d8de9cc19821dfab21c | |
parent | cae76be0761eb694ded4da32ff95f50257f5bfe0 (diff) |
[sanitizer] Add macOS minimum deployment target to all compiler invocations in lit tests
The Clang driver on macOS decides the deployment target based on various things, like your host OS version, the SDK version and some environment variables, which makes lit tests pass or fail based on your environment. Let's make sure we run all lit tests with `-mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}` (10.9 unless overriden).
Differential Revision: https://reviews.llvm.org/D26929
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288186 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | cmake/config-ix.cmake | 18 | ||||
-rw-r--r-- | test/asan/CMakeLists.txt | 10 | ||||
-rw-r--r-- | test/dfsan/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/lsan/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/msan/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/profile/CMakeLists.txt | 8 | ||||
-rw-r--r-- | test/sanitizer_common/CMakeLists.txt | 9 | ||||
-rw-r--r-- | test/tsan/CMakeLists.txt | 10 | ||||
-rw-r--r-- | test/ubsan/CMakeLists.txt | 8 | ||||
-rw-r--r-- | test/xray/CMakeLists.txt | 12 |
10 files changed, 27 insertions, 81 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 19288c236..f796fe18a 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -128,6 +128,24 @@ function(get_target_flags_for_arch arch out_var) 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) diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt index cb32cfba8..637c5b808 100644 --- a/test/asan/CMakeLists.txt +++ b/test/asan/CMakeLists.txt @@ -43,15 +43,7 @@ foreach(arch ${ASAN_TEST_ARCH}) 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() diff --git a/test/dfsan/CMakeLists.txt b/test/dfsan/CMakeLists.txt index c2baf930d..04035faed 100644 --- a/test/dfsan/CMakeLists.txt +++ b/test/dfsan/CMakeLists.txt @@ -10,16 +10,7 @@ endif() 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) diff --git a/test/lsan/CMakeLists.txt b/test/lsan/CMakeLists.txt index e3d363a1f..3324928dd 100644 --- a/test/lsan/CMakeLists.txt +++ b/test/lsan/CMakeLists.txt @@ -10,16 +10,7 @@ endif() 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) diff --git a/test/msan/CMakeLists.txt b/test/msan/CMakeLists.txt index 176fb4ae1..171bcb961 100644 --- a/test/msan/CMakeLists.txt +++ b/test/msan/CMakeLists.txt @@ -10,16 +10,7 @@ endif() 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) diff --git a/test/profile/CMakeLists.txt b/test/profile/CMakeLists.txt index 0eb2b8947..5a4cfa101 100644 --- a/test/profile/CMakeLists.txt +++ b/test/profile/CMakeLists.txt @@ -14,13 +14,7 @@ endif() 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 diff --git a/test/sanitizer_common/CMakeLists.txt b/test/sanitizer_common/CMakeLists.txt index 218fbf003..9b4070b0f 100644 --- a/test/sanitizer_common/CMakeLists.txt +++ b/test/sanitizer_common/CMakeLists.txt @@ -27,14 +27,7 @@ foreach(tool ${SUPPORTED_TOOLS}) 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 diff --git a/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt index e05b100f3..2db6ce0a8 100644 --- a/test/tsan/CMakeLists.txt +++ b/test/tsan/CMakeLists.txt @@ -24,15 +24,7 @@ endif() 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) diff --git a/test/ubsan/CMakeLists.txt b/test/ubsan/CMakeLists.txt index 7b14a70b7..f4b73e87f 100644 --- a/test/ubsan/CMakeLists.txt +++ b/test/ubsan/CMakeLists.txt @@ -22,13 +22,7 @@ endif() 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};") diff --git a/test/xray/CMakeLists.txt b/test/xray/CMakeLists.txt index e58032d03..def0f44ce 100644 --- a/test/xray/CMakeLists.txt +++ b/test/xray/CMakeLists.txt @@ -14,17 +14,7 @@ if (COMPILER_RT_BUILD_XRAY AND COMPILER_RT_HAS_XRAY) 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) |