[sanitizers] Set Darwin specific linker and compiler flags for all tests
authorAnna Zaks <ganna@apple.com>
Wed, 26 Oct 2016 23:23:38 +0000 (23:23 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 26 Oct 2016 23:23:38 +0000 (23:23 +0000)
Looks like we are missing these flags only in tsan and sanitizer-common.

This results in linker warnings in some settings as it can cause the Unit
tests to be built with a different SDK version than that was used to build
the runtime. For example, we are not setting the minimal deployment target
on the tests but are setting the minimal deployment target for the sanitizer
library, which leads to the following warning on some bots: ld: warning:
object file (sanitizer_posix_test.cc.i386.o) was built for newer OSX version
(10.12) than being linked (10.11).

Differential Revision: https://reviews.llvm.org/D25860  https://reviews.llvm.org/D25352

llvm-svn: 285255

compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
compiler-rt/lib/tsan/tests/CMakeLists.txt

index 0a828dc..b66f756 100644 (file)
@@ -78,6 +78,11 @@ if(ANDROID)
   list(APPEND SANITIZER_TEST_LINK_FLAGS_COMMON -pie)
 endif()
 
+if(APPLE)
+  list(APPEND SANITIZER_TEST_CFLAGS_COMMON ${DARWIN_osx_CFLAGS})
+  list(APPEND SANITIZER_TEST_LINK_FLAGS_COMMON ${DARWIN_osx_LINKFLAGS})
+endif()
+
 # MSVC linker is allocating 1M for the stack by default, which is not
 # enough for the unittests. Some unittests require more than 2M.
 # The default stack size for clang is 8M.
index d1b1e96..4587e47 100644 (file)
@@ -12,6 +12,10 @@ set(TSAN_UNITTEST_CFLAGS
   -I${COMPILER_RT_SOURCE_DIR}/lib/tsan/rtl
   -DGTEST_HAS_RTTI=0)
 
+if(APPLE)
+  list(APPEND TSAN_UNITTEST_CFLAGS ${DARWIN_osx_CFLAGS})
+endif()
+
 set(TSAN_RTL_HEADERS)
 foreach (header ${TSAN_HEADERS})
   list(APPEND TSAN_RTL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../${header})
@@ -78,7 +82,7 @@ macro(add_tsan_unittest testname)
         add_compiler_rt_test(TsanUnitTests "${testname}-${arch}-Test"
                 OBJECTS ${TEST_OBJECTS}
                 DEPS ${TEST_DEPS}
-                LINK_FLAGS ${TARGET_LINK_FLAGS}
+                LINK_FLAGS ${TARGET_LINK_FLAGS} ${DARWIN_osx_LINKFLAGS}
                            -lc++)
       endif()
     endforeach()