From be7ae6684f0937b1c922ecbbf03c3705846bced9 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Wed, 26 Oct 2016 23:23:38 +0000 Subject: [PATCH] [sanitizers] Set Darwin specific linker and compiler flags for all tests 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 | 5 +++++ compiler-rt/lib/tsan/tests/CMakeLists.txt | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt index 0a828dc..b66f756 100644 --- a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt @@ -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. diff --git a/compiler-rt/lib/tsan/tests/CMakeLists.txt b/compiler-rt/lib/tsan/tests/CMakeLists.txt index d1b1e96..4587e47 100644 --- a/compiler-rt/lib/tsan/tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/tests/CMakeLists.txt @@ -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() -- 2.7.4