diff --git a/compiler-rt/lib/Makefile.mk b/compiler-rt/lib/Makefile.mk index 8b912c43cf30..8054c35aa362 100644 --- a/compiler-rt/lib/Makefile.mk +++ b/compiler-rt/lib/Makefile.mk @@ -21,6 +21,7 @@ SubDirs += sanitizer_common SubDirs += tsan SubDirs += msan SubDirs += ubsan +SubDirs += lsan # Define the variables for this specific directory. Sources := $(foreach file,$(wildcard $(Dir)/*.c),$(notdir $(file))) diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index 98544a418e24..a567a4d3e970 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -85,7 +85,7 @@ else() $ $ $ - #$ + $ CFLAGS ${ASAN_CFLAGS} DEFS ${ASAN_COMMON_DEFINITIONS} SYMS asan.syms) diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index 79fda78cd7ac..4c57affbb396 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -768,7 +768,7 @@ u32 LsanMetadata::stack_trace_id() const { template void ForEachChunk(Callable const &callback) { __asan::allocator.ForEachChunk(callback); } -#if 0 +#if CAN_SANITIZE_LEAKS template void ForEachChunk( ProcessPlatformSpecificAllocationsCb const &callback); template void ForEachChunk(PrintLeakedCb const &callback); diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 539ed9b8c5b6..f989c5c0d2a5 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -560,12 +560,12 @@ void __asan_init() { InitializeAllocator(); -#if 0 +#if CAN_SANITIZE_LEAKS __lsan::InitCommonLsan(); if (flags()->detect_leaks) { Atexit(__lsan::DoLeakCheck); } -#endif +#endif // CAN_SANITIZE_LEAKS if (flags()->verbosity) { Report("AddressSanitizer Init done\n"); diff --git a/compiler-rt/lib/lsan/Makefile.mk b/compiler-rt/lib/lsan/Makefile.mk new file mode 100644 index 000000000000..aae5c32fd32f --- /dev/null +++ b/compiler-rt/lib/lsan/Makefile.mk @@ -0,0 +1,23 @@ +#===- lib/lsan/Makefile.mk ---------------------------------*- Makefile -*--===# +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# + +ModuleName := lsan_common +SubDirs := + +Sources := $(foreach file,$(wildcard $(Dir)/lsan_common*.cc),$(notdir $(file))) +ObjNames := $(Sources:%.cc=%.o) + +Implementation := Generic + +# FIXME: use automatic dependencies? +Dependencies := $(wildcard $(Dir)/*.h) +Dependencies += $(wildcard $(Dir)/../sanitizer_common/*.h) + +# Define a convenience variable for all the asan functions. +LsanCommonFunctions := $(Sources:%.cc=%) diff --git a/compiler-rt/make/platform/clang_linux.mk b/compiler-rt/make/platform/clang_linux.mk index 985e485985ac..05efdb6d67ea 100644 --- a/compiler-rt/make/platform/clang_linux.mk +++ b/compiler-rt/make/platform/clang_linux.mk @@ -130,7 +130,7 @@ FUNCTIONS.san-x86_64 := $(SanitizerCommonFunctions) FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions) \ - $(SanitizerCommonFunctions) + $(SanitizerCommonFunctions) $(LsanCommonFunctions) FUNCTIONS.asan-arm-android := $(AsanFunctions) $(InterceptionFunctions) \ $(SanitizerCommonFunctions) FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions) \