summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-01-09 03:51:42 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-01-09 03:51:42 +0000
commitae4b8805fdce22aacb5644520c4dc42ce2656ebf (patch)
tree77e6862afbfa593d23c5069cfd364d3334be406a /cmake/Modules
parentcf0113c530ec1a9e44a3fcec909ee10725df5347 (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 'cmake/Modules')
-rw-r--r--cmake/Modules/SanitizerUtils.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake
index c66083c24..3e1a6346e 100644
--- a/cmake/Modules/SanitizerUtils.cmake
+++ b/cmake/Modules/SanitizerUtils.cmake
@@ -46,6 +46,17 @@ macro(add_sanitizer_rt_symbols name)
endforeach()
endmacro()
+# This function is only used on Darwin, where undefined symbols must be specified
+# in the linker invocation.
+function(add_weak_symbols libname linkflags)
+ file(STRINGS "${COMPILER_RT_SOURCE_DIR}/lib/${libname}/weak_symbols.txt" WEAK_SYMBOLS)
+ set(local_linkflags ${${linkflags}})
+ foreach(SYMBOL ${WEAK_SYMBOLS})
+ set(local_linkflags ${local_linkflags} -Wl,-U,${SYMBOL})
+ endforeach()
+ set(${linkflags} ${local_linkflags} PARENT_SCOPE)
+endfunction()
+
macro(add_sanitizer_rt_version_list name)
set(vers ${CMAKE_CURRENT_BINARY_DIR}/${name}.vers)
cmake_parse_arguments(ARG "" "" "LIBS;EXTRA" ${ARGN})