2012-04-05 06:12:04 +08:00
|
|
|
# Build for the AddressSanitizer runtime support library.
|
|
|
|
|
2012-06-20 18:18:43 +08:00
|
|
|
set(ASAN_SOURCES
|
|
|
|
asan_allocator.cc
|
2012-12-10 21:52:55 +08:00
|
|
|
asan_allocator2.cc
|
2012-12-10 22:19:15 +08:00
|
|
|
asan_fake_stack.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
asan_globals.cc
|
|
|
|
asan_interceptors.cc
|
|
|
|
asan_linux.cc
|
|
|
|
asan_mac.cc
|
|
|
|
asan_malloc_linux.cc
|
|
|
|
asan_malloc_mac.cc
|
|
|
|
asan_malloc_win.cc
|
|
|
|
asan_new_delete.cc
|
|
|
|
asan_poisoning.cc
|
|
|
|
asan_posix.cc
|
2012-08-09 16:15:46 +08:00
|
|
|
asan_report.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
asan_rtl.cc
|
|
|
|
asan_stack.cc
|
|
|
|
asan_stats.cc
|
|
|
|
asan_thread.cc
|
|
|
|
asan_thread_registry.cc
|
|
|
|
asan_win.cc
|
|
|
|
)
|
2012-04-05 06:12:04 +08:00
|
|
|
|
2012-08-17 17:00:08 +08:00
|
|
|
set(ASAN_DYLIB_SOURCES
|
|
|
|
${ASAN_SOURCES}
|
|
|
|
dynamic/asan_interceptors_dynamic.cc
|
|
|
|
)
|
|
|
|
|
2012-06-25 20:57:43 +08:00
|
|
|
include_directories(..)
|
|
|
|
|
2012-09-05 17:00:03 +08:00
|
|
|
set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
|
|
|
|
2012-09-11 19:55:45 +08:00
|
|
|
if(ANDROID)
|
|
|
|
set(ASAN_COMMON_DEFINITIONS
|
|
|
|
ASAN_HAS_EXCEPTIONS=1
|
|
|
|
ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
|
|
|
|
ASAN_NEEDS_SEGV=0
|
|
|
|
ASAN_LOW_MEMORY=1
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(ASAN_COMMON_DEFINITIONS
|
|
|
|
ASAN_HAS_EXCEPTIONS=1
|
|
|
|
ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
|
|
|
|
ASAN_NEEDS_SEGV=1
|
|
|
|
)
|
|
|
|
endif()
|
2012-08-17 17:00:08 +08:00
|
|
|
|
|
|
|
set(ASAN_DYLIB_DEFINITIONS
|
|
|
|
${ASAN_COMMON_DEFINITIONS}
|
|
|
|
MAC_INTERPOSE_FUNCTIONS=1
|
|
|
|
)
|
|
|
|
|
2013-01-19 00:51:07 +08:00
|
|
|
# Architectures supported by ASan.
|
|
|
|
filter_available_targets(ASAN_SUPPORTED_ARCH
|
|
|
|
x86_64 i386)
|
|
|
|
|
2012-08-10 22:45:52 +08:00
|
|
|
set(ASAN_RUNTIME_LIBRARIES)
|
|
|
|
if(APPLE)
|
|
|
|
# Build universal binary on APPLE.
|
2013-01-21 16:12:20 +08:00
|
|
|
add_compiler_rt_osx_static_runtime(clang_rt.asan_osx
|
|
|
|
ARCH ${ASAN_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${ASAN_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.osx>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
|
|
|
|
CFLAGS ${ASAN_CFLAGS}
|
|
|
|
DEFS ${ASAN_COMMON_DEFINITIONS})
|
2012-08-10 22:45:52 +08:00
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx)
|
2012-09-11 19:55:45 +08:00
|
|
|
elseif(ANDROID)
|
|
|
|
add_library(clang_rt.asan-arm-android SHARED
|
|
|
|
${ASAN_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.arm.android>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.arm.android>
|
|
|
|
)
|
|
|
|
set_target_compile_flags(clang_rt.asan-arm-android
|
2013-01-21 16:12:20 +08:00
|
|
|
${ASAN_CFLAGS})
|
|
|
|
set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY
|
|
|
|
COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS})
|
2012-09-11 19:55:45 +08:00
|
|
|
target_link_libraries(clang_rt.asan-arm-android dl)
|
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
|
2012-08-10 22:45:52 +08:00
|
|
|
else()
|
|
|
|
# Otherwise, build separate libraries for each target.
|
2013-01-19 00:51:07 +08:00
|
|
|
foreach(arch ${ASAN_SUPPORTED_ARCH})
|
2013-01-21 16:12:20 +08:00
|
|
|
add_compiler_rt_static_runtime(clang_rt.asan-${arch} ${arch}
|
|
|
|
SOURCES ${ASAN_SOURCES}
|
|
|
|
$<TARGET_OBJECTS:RTInterception.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
|
|
|
CFLAGS ${ASAN_CFLAGS}
|
|
|
|
DEFS ${ASAN_COMMON_DEFINITIONS})
|
2013-01-19 00:51:07 +08:00
|
|
|
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-${arch})
|
|
|
|
endforeach()
|
2012-04-05 06:12:04 +08:00
|
|
|
endif()
|
2012-06-25 20:57:43 +08:00
|
|
|
|
2012-08-17 17:00:08 +08:00
|
|
|
set(ASAN_DYNAMIC_RUNTIME_LIBRARIES)
|
|
|
|
if(APPLE)
|
|
|
|
# Build universal binary on APPLE.
|
2013-01-21 16:12:20 +08:00
|
|
|
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_DYLIB_DEFINITIONS}
|
|
|
|
LINKFLAGS "-framework Foundation")
|
2012-08-17 17:00:08 +08:00
|
|
|
list(APPEND ASAN_DYNAMIC_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic)
|
|
|
|
endif()
|
|
|
|
|
2012-06-25 20:57:43 +08:00
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2012-07-31 23:43:11 +08:00
|
|
|
|
|
|
|
add_subdirectory(lit_tests)
|