File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,32 @@ if (LIBCXX_COVERAGE_LIBRARY)
68
68
endif ()
69
69
target_link_libraries (cxx ${libraries} )
70
70
71
+ if (APPLE AND LLVM_USE_SANITIZER )
72
+ if ("${LLVM_USE_SANITIZER} " STREQUAL "Address" )
73
+ set (LIBFILE "libclang_rt.asan_osx_dynamic.dylib" )
74
+ elseif ("${LLVM_USE_SANITIZER} " STREQUAL "Undefined" )
75
+ set (LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib" )
76
+ else ()
77
+ message (WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X" )
78
+ endif ()
79
+ if (LIBFILE )
80
+ execute_process (COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result )
81
+ if (NOT ${Result} EQUAL "0" )
82
+ message (FATAL "Failed to find library resource directory" )
83
+ endif ()
84
+ string (STRIP "${LIBDIR} " LIBDIR )
85
+ set (LIBDIR "${LIBDIR} /darwin/" )
86
+ if (NOT IS_DIRECTORY "${LIBDIR} " )
87
+ message (FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER" )
88
+ endif ()
89
+ set (LIBCXX_SANITIZER_LIBRARY "${LIBDIR} /${LIBFILE} " )
90
+ set (LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY} " PARENT_SCOPE )
91
+ message (STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY} " )
92
+ target_link_libraries (cxx "${LIBCXX_SANITIZER_LIBRARY} " )
93
+ target_link_libraries (cxx "-Wl,-rpath,${LIBDIR} " )
94
+ endif ()
95
+ endif ()
96
+
71
97
72
98
# Setup flags.
73
99
append_if (LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC )
Original file line number Diff line number Diff line change @@ -623,13 +623,19 @@ def configure_sanitizer(self):
623
623
'-fno-sanitize-recover' ]
624
624
self .cxx .compile_flags += ['-O3' ]
625
625
self .config .available_features .add ('ubsan' )
626
+ if self .target_info .platform () == 'darwin' :
627
+ self .config .available_features .add ('sanitizer-new-delete' )
626
628
elif san == 'Thread' :
627
629
self .cxx .flags += ['-fsanitize=thread' ]
628
630
self .config .available_features .add ('tsan' )
629
631
self .config .available_features .add ('sanitizer-new-delete' )
630
632
else :
631
633
self .lit_config .fatal ('unsupported value for '
632
634
'use_sanitizer: {0}' .format (san ))
635
+ san_lib = self .get_lit_conf ('sanitizer_library' )
636
+ if san_lib :
637
+ self .cxx .link_flags += [
638
+ san_lib , '-Wl,-rpath,%s' % os .path .dirname (san_lib )]
633
639
634
640
def configure_coverage (self ):
635
641
self .generate_coverage = self .get_lit_bool ('generate_coverage' , False )
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ config.enable_thread_unsafe_c_functions = "@LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTI
16
16
config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
17
17
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
18
18
config.use_sanitizer = "@LLVM_USE_SANITIZER@"
19
+ config.sanitizer_library = "@LIBCXX_SANITIZER_LIBRARY@"
19
20
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
20
21
config.configuration_variant = "@LIBCXX_LIT_VARIANT@"
21
22
config.target_triple = "@LIBCXX_TARGET_TRIPLE@"
You can’t perform that action at this time.
0 commit comments