Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -245,6 +245,24 @@ -stdlib=libc++ -lc++ -lc++abi) + + set(DARWIN_WEAK_SYMBOLS + ___asan_default_options + ___asan_default_suppressions + ___asan_on_error + ___lsan_default_suppressions + ___lsan_is_turned_off + ___sanitizer_free_hook + ___sanitizer_malloc_hook + ___sanitizer_symbolize_code + ___sanitizer_symbolize_data + ___sanitizer_symbolize_demangle + ___sanitizer_symbolize_flush + ___ubsan_default_options) + + foreach(SYMBOL ${DARWIN_WEAK_SYMBOLS}) + set(DARWIN_COMMON_LINKFLAGS ${DARWIN_COMMON_LINKFLAGS} -Wl,-U,${SYMBOL}) + endforeach() check_linker_flag("-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION) if(COMPILER_RT_HAS_APP_EXTENSION) Index: lib/lsan/CMakeLists.txt =================================================================== --- lib/lsan/CMakeLists.txt +++ lib/lsan/CMakeLists.txt @@ -23,9 +23,8 @@ CFLAGS ${LSAN_CFLAGS}) if(COMPILER_RT_HAS_LSAN) + add_compiler_rt_component(lsan) foreach(arch ${LSAN_SUPPORTED_ARCH}) - add_compiler_rt_component(lsan) - add_compiler_rt_runtime(clang_rt.lsan STATIC ARCHS ${arch} Index: lib/lsan/lsan_allocator.cc =================================================================== --- lib/lsan/lsan_allocator.cc +++ lib/lsan/lsan_allocator.cc @@ -258,4 +258,17 @@ uptr __sanitizer_get_allocated_size(const void *p) { return GetMallocUsableSize(p); } + +#if !SANITIZER_SUPPORTS_WEAK_HOOKS +// Provide default (no-op) implementation of malloc hooks. +SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE +void __sanitizer_malloc_hook(void *ptr, uptr size) { + (void)ptr; + (void)size; +} +SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE +void __sanitizer_free_hook(void *ptr) { + (void)ptr; +} +#endif } // extern "C" Index: lib/lsan/lsan_common.cc =================================================================== --- lib/lsan/lsan_common.cc +++ lib/lsan/lsan_common.cc @@ -758,5 +758,10 @@ int __lsan_is_turned_off() { return 0; } + +SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE +const char *__lsan_default_suppressions() { + return ""; +} #endif } // extern "C"