[compiler-rt] r288186 - [sanitizer] Add macOS minimum deployment target to all compiler invocations in lit tests

Kuba Mracek via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 11:25:53 PST 2016


Author: kuba.brecka
Date: Tue Nov 29 13:25:53 2016
New Revision: 288186

URL: http://llvm.org/viewvc/llvm-project?rev=288186&view=rev
Log:
[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


Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/test/asan/CMakeLists.txt
    compiler-rt/trunk/test/dfsan/CMakeLists.txt
    compiler-rt/trunk/test/lsan/CMakeLists.txt
    compiler-rt/trunk/test/msan/CMakeLists.txt
    compiler-rt/trunk/test/profile/CMakeLists.txt
    compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
    compiler-rt/trunk/test/tsan/CMakeLists.txt
    compiler-rt/trunk/test/ubsan/CMakeLists.txt
    compiler-rt/trunk/test/xray/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Nov 29 13:25:53 2016
@@ -128,6 +128,24 @@ function(get_target_flags_for_arch arch
   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)

Modified: compiler-rt/trunk/test/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/asan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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()

Modified: compiler-rt/trunk/test/dfsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/dfsan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/dfsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/dfsan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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)
 

Modified: compiler-rt/trunk/test/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/lsan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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)

Modified: compiler-rt/trunk/test/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/msan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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)
 

Modified: compiler-rt/trunk/test/profile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/profile/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/profile/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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

Modified: compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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

Modified: compiler-rt/trunk/test/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/tsan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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)

Modified: compiler-rt/trunk/test/ubsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/ubsan/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -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};")

Modified: compiler-rt/trunk/test/xray/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/CMakeLists.txt?rev=288186&r1=288185&r2=288186&view=diff
==============================================================================
--- compiler-rt/trunk/test/xray/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/xray/CMakeLists.txt Tue Nov 29 13:25:53 2016
@@ -14,17 +14,7 @@ if (COMPILER_RT_BUILD_XRAY AND COMPILER_
   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)
 




More information about the llvm-commits mailing list