diff options
Diffstat (limited to 'lib/asan/CMakeLists.txt')
-rw-r--r-- | lib/asan/CMakeLists.txt | 95 |
1 files changed, 38 insertions, 57 deletions
diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 92cba6dee622..a567a4d3e970 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -1,7 +1,6 @@ # Build for the AddressSanitizer runtime support library. set(ASAN_SOURCES - asan_allocator.cc asan_allocator2.cc asan_fake_stack.cc asan_globals.cc @@ -14,60 +13,58 @@ set(ASAN_SOURCES asan_new_delete.cc asan_poisoning.cc asan_posix.cc + asan_preinit.cc asan_report.cc asan_rtl.cc asan_stack.cc asan_stats.cc asan_thread.cc - asan_thread_registry.cc asan_win.cc ) set(ASAN_DYLIB_SOURCES ${ASAN_SOURCES} - dynamic/asan_interceptors_dynamic.cc ) include_directories(..) -set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) +set(ASAN_CFLAGS + ${SANITIZER_COMMON_CFLAGS} + -fno-rtti) + +set(ASAN_COMMON_DEFINITIONS + ASAN_HAS_EXCEPTIONS=1) if(ANDROID) - set(ASAN_COMMON_DEFINITIONS - ASAN_HAS_EXCEPTIONS=1 + list(APPEND ASAN_COMMON_DEFINITIONS ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 ASAN_NEEDS_SEGV=0 - ASAN_LOW_MEMORY=1 - ) + ASAN_LOW_MEMORY=1) else() - set(ASAN_COMMON_DEFINITIONS - ASAN_HAS_EXCEPTIONS=1 - ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 - ASAN_NEEDS_SEGV=1 - ) + list(APPEND ASAN_COMMON_DEFINITIONS + ASAN_FLEXIBLE_MAPPING_AND_OFFSET=1 + ASAN_NEEDS_SEGV=1) endif() -set(ASAN_DYLIB_DEFINITIONS - ${ASAN_COMMON_DEFINITIONS} - MAC_INTERPOSE_FUNCTIONS=1 - ) - # Architectures supported by ASan. filter_available_targets(ASAN_SUPPORTED_ARCH - x86_64 i386) + x86_64 i386 powerpc64 powerpc) set(ASAN_RUNTIME_LIBRARIES) if(APPLE) # Build universal binary on APPLE. - add_library(clang_rt.asan_osx STATIC - ${ASAN_SOURCES} - $<TARGET_OBJECTS:RTInterception.osx> - $<TARGET_OBJECTS:RTSanitizerCommon.osx> - ) - set_target_compile_flags(clang_rt.asan_osx ${ASAN_CFLAGS}) - set_target_properties(clang_rt.asan_osx PROPERTIES - OSX_ARCHITECTURES "${ASAN_SUPPORTED_ARCH}") - list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx) + add_compiler_rt_osx_dynamic_runtime(clang_rt.asan_osx_dynamic + ARCH ${ASAN_SUPPORTED_ARCH} + SOURCES ${ASAN_DYLIB_SOURCES} + $<TARGET_OBJECTS:RTInterception.osx> + $<TARGET_OBJECTS:RTSanitizerCommon.osx> + CFLAGS ${ASAN_CFLAGS} + DEFS ${ASAN_COMMON_DEFINITIONS} + # Dynamic lookup is needed because shadow scale and offset are + # provided by the instrumented modules. + LINKFLAGS "-framework Foundation" + "-undefined dynamic_lookup") + list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic) elseif(ANDROID) add_library(clang_rt.asan-arm-android SHARED ${ASAN_SOURCES} @@ -75,44 +72,28 @@ elseif(ANDROID) $<TARGET_OBJECTS:RTSanitizerCommon.arm.android> ) set_target_compile_flags(clang_rt.asan-arm-android - ${ASAN_CFLAGS} - ) + ${ASAN_CFLAGS}) + set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY + COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS}) target_link_libraries(clang_rt.asan-arm-android dl) list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android) else() # Otherwise, build separate libraries for each target. foreach(arch ${ASAN_SUPPORTED_ARCH}) - add_library(clang_rt.asan-${arch} STATIC - ${ASAN_SOURCES} - $<TARGET_OBJECTS:RTInterception.${arch}> - $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>) - set_target_compile_flags(clang_rt.asan-${arch} - ${ASAN_CFLAGS} ${TARGET_${arch}_CFLAGS}) + add_compiler_rt_static_runtime(clang_rt.asan-${arch} ${arch} + SOURCES ${ASAN_SOURCES} + $<TARGET_OBJECTS:RTInterception.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> + $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> + $<TARGET_OBJECTS:RTLSanCommon.${arch}> + CFLAGS ${ASAN_CFLAGS} + DEFS ${ASAN_COMMON_DEFINITIONS} + SYMS asan.syms) list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-${arch}) endforeach() endif() -set_property(TARGET ${ASAN_RUNTIME_LIBRARIES} APPEND PROPERTY - COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS}) -add_clang_compiler_rt_libraries(${ASAN_RUNTIME_LIBRARIES}) - -set(ASAN_DYNAMIC_RUNTIME_LIBRARIES) -if(APPLE) - # Build universal binary on APPLE. - add_library(clang_rt.asan_osx_dynamic SHARED - ${ASAN_DYLIB_SOURCES} - $<TARGET_OBJECTS:RTInterception.osx> - $<TARGET_OBJECTS:RTSanitizerCommon.osx> - ) - set_target_compile_flags(clang_rt.asan_osx_dynamic ${ASAN_CFLAGS}) - set_target_properties(clang_rt.asan_osx_dynamic PROPERTIES - COMPILE_DEFINITIONS "${ASAN_DYLIB_DEFINITIONS}" - OSX_ARCHITECTURES "${ASAN_SUPPORTED_ARCH}" - LINK_FLAGS "-framework Foundation") - list(APPEND ASAN_DYNAMIC_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic) -endif() -add_clang_compiler_rt_libraries(${ASAN_DYNAMIC_RUNTIME_LIBRARIES}) - +add_compiler_rt_resource_file(asan_blacklist asan_blacklist.txt) if(LLVM_INCLUDE_TESTS) add_subdirectory(tests) |