diff options
author | Francis Ricci <francisjricci@gmail.com> | 2017-01-09 03:51:42 +0000 |
---|---|---|
committer | Francis Ricci <francisjricci@gmail.com> | 2017-01-09 03:51:42 +0000 |
commit | ae4b8805fdce22aacb5644520c4dc42ce2656ebf (patch) | |
tree | 77e6862afbfa593d23c5069cfd364d3334be406a /lib/tsan | |
parent | cf0113c530ec1a9e44a3fcec909ee10725df5347 (diff) |
Enable weak hooks on darwin
Summary:
By default, darwin requires a definition for weak interface functions at
link time. Adding the '-U' link flag with each weak function allows these
weak interface functions to be used without definitions, which mirrors
behavior on linux and windows.
Reviewers: compnerd, eugenis
Subscribers: kubabrecka, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D28203
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan')
-rw-r--r-- | lib/tsan/CMakeLists.txt | 5 | ||||
-rw-r--r-- | lib/tsan/tests/CMakeLists.txt | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt index b26a884b1..75d26349a 100644 --- a/lib/tsan/CMakeLists.txt +++ b/lib/tsan/CMakeLists.txt @@ -107,6 +107,10 @@ if(APPLE) # Pass ASM file directly to the C++ compiler. set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES LANGUAGE C) endif() + + add_weak_symbols("ubsan" WEAK_SYMBOL_LINKFLAGS) + add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINKFLAGS) + add_compiler_rt_runtime(clang_rt.tsan SHARED OS ${TSAN_SUPPORTED_OS} @@ -117,6 +121,7 @@ if(APPLE) RTSanitizerCommonLibc RTUbsan CFLAGS ${TSAN_RTL_CFLAGS} + LINKFLAGS ${WEAK_SYMBOL_LINKFLAGS} PARENT_TARGET tsan) add_compiler_rt_object_libraries(RTTsan_dynamic OS ${TSAN_SUPPORTED_OS} diff --git a/lib/tsan/tests/CMakeLists.txt b/lib/tsan/tests/CMakeLists.txt index 4587e47ba..ac7412940 100644 --- a/lib/tsan/tests/CMakeLists.txt +++ b/lib/tsan/tests/CMakeLists.txt @@ -76,14 +76,18 @@ macro(add_tsan_unittest testname) ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) list(APPEND TEST_OBJECTS lib${TSAN_TEST_RUNTIME}.a) list(APPEND TEST_DEPS ${TSAN_TEST_RUNTIME}) + + add_weak_symbols("ubsan" WEAK_SYMBOL_LINKFLAGS) + add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINKFLAGS) + # Intentionally do *not* link with `-fsanitize=thread`. We already link # against a static version of the runtime, and we don't want the dynamic # one. add_compiler_rt_test(TsanUnitTests "${testname}-${arch}-Test" OBJECTS ${TEST_OBJECTS} DEPS ${TEST_DEPS} - LINK_FLAGS ${TARGET_LINK_FLAGS} ${DARWIN_osx_LINKFLAGS} - -lc++) + LINK_FLAGS ${TARGET_LINK_FLAGS} ${DARWIN_osx_LINK_FLAGS} + ${WEAK_SYMBOL_LINKFLAGS} -lc++) endif() endforeach() endif() |