From ff1bd20ded4dced833a5268a6a40b27cf065d907 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Tue, 29 Nov 2016 19:25:53 +0000 Subject: [PATCH] [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 llvm-svn: 288186 --- compiler-rt/cmake/config-ix.cmake | 18 ++++++++++++++++++ compiler-rt/test/asan/CMakeLists.txt | 10 +--------- compiler-rt/test/dfsan/CMakeLists.txt | 11 +---------- compiler-rt/test/lsan/CMakeLists.txt | 11 +---------- compiler-rt/test/msan/CMakeLists.txt | 11 +---------- compiler-rt/test/profile/CMakeLists.txt | 8 +------- compiler-rt/test/sanitizer_common/CMakeLists.txt | 9 +-------- compiler-rt/test/tsan/CMakeLists.txt | 10 +--------- compiler-rt/test/ubsan/CMakeLists.txt | 8 +------- compiler-rt/test/xray/CMakeLists.txt | 12 +----------- 10 files changed, 27 insertions(+), 81 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 19288c2..f796fe1 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/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/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt index cb32cfb..637c5b8 100644 --- a/compiler-rt/test/asan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/dfsan/CMakeLists.txt b/compiler-rt/test/dfsan/CMakeLists.txt index c2baf93..04035fa 100644 --- a/compiler-rt/test/dfsan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/lsan/CMakeLists.txt b/compiler-rt/test/lsan/CMakeLists.txt index e3d363a..3324928 100644 --- a/compiler-rt/test/lsan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/msan/CMakeLists.txt b/compiler-rt/test/msan/CMakeLists.txt index 176fb4a..171bcb9 100644 --- a/compiler-rt/test/msan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/profile/CMakeLists.txt b/compiler-rt/test/profile/CMakeLists.txt index 0eb2b89..5a4cfa1 100644 --- a/compiler-rt/test/profile/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt index 218fbf0..9b4070b 100644 --- a/compiler-rt/test/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/tsan/CMakeLists.txt b/compiler-rt/test/tsan/CMakeLists.txt index e05b100..2db6ce0 100644 --- a/compiler-rt/test/tsan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt index 7b14a70..f4b73e8 100644 --- a/compiler-rt/test/ubsan/CMakeLists.txt +++ b/compiler-rt/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/compiler-rt/test/xray/CMakeLists.txt b/compiler-rt/test/xray/CMakeLists.txt index e58032d..def0f44c 100644 --- a/compiler-rt/test/xray/CMakeLists.txt +++ b/compiler-rt/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) -- 2.7.4