diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index a30dc1d207e3..595b722e74fc 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -465,9 +465,11 @@ void __asan_init() { Atexit(asan_atexit); } +#if CAN_SANITIZE_LEAKS if (flags()->detect_leaks) { Atexit(__lsan::DoLeakCheck); } +#endif // interceptors InitializeAsanInterceptors(); @@ -548,7 +550,9 @@ void __asan_init() { main_thread->ThreadStart(internal_getpid()); force_interface_symbols(); // no-op. +#if CAN_SANITIZE_LEAKS __lsan::InitCommonLsan(); +#endif InitializeAllocator(); diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 18d913dfbc5f..480b6c4eaf2c 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -20,8 +20,9 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "sanitizer_common/sanitizer_stoptheworld.h" -namespace __lsan { #if CAN_SANITIZE_LEAKS +namespace __lsan { + Flags lsan_flags; static void InitializeFlags() { @@ -381,8 +382,6 @@ void LeakReport::PrintLargest(uptr max_leaks) { remaining > 1 ? "s" : ""); } } -#else // CAN_SANITIZE_LEAKS -void InitCommonLsan() {} -void DoLeakCheck() {} -#endif // CAN_SANITIZE_LEAKS + } // namespace __lsan +#endif // CAN_SANITIZE_LEAKS