2012-06-20 18:18:43 +08:00
|
|
|
# Build system for the common Sanitizer runtime support library components.
|
|
|
|
# These components are shared between AddressSanitizer and ThreadSanitizer.
|
|
|
|
|
|
|
|
set(SANITIZER_SOURCES
|
|
|
|
sanitizer_allocator.cc
|
|
|
|
sanitizer_common.cc
|
2012-07-10 17:17:06 +08:00
|
|
|
sanitizer_flags.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_libc.cc
|
|
|
|
sanitizer_linux.cc
|
|
|
|
sanitizer_mac.cc
|
|
|
|
sanitizer_posix.cc
|
|
|
|
sanitizer_printf.cc
|
2012-09-11 18:50:32 +08:00
|
|
|
sanitizer_stackdepot.cc
|
2012-08-28 22:11:57 +08:00
|
|
|
sanitizer_stacktrace.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_symbolizer.cc
|
2012-08-14 21:00:32 +08:00
|
|
|
sanitizer_symbolizer_linux.cc
|
|
|
|
sanitizer_symbolizer_mac.cc
|
|
|
|
sanitizer_symbolizer_win.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_win.cc
|
|
|
|
)
|
|
|
|
|
2012-09-05 17:00:03 +08:00
|
|
|
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
2012-06-25 16:40:10 +08:00
|
|
|
|
2012-08-13 15:41:43 +08:00
|
|
|
set(SANITIZER_RUNTIME_LIBRARIES)
|
2012-08-10 22:45:52 +08:00
|
|
|
if(APPLE)
|
|
|
|
# Build universal binary on APPLE.
|
|
|
|
add_library(RTSanitizerCommon.osx OBJECT ${SANITIZER_SOURCES})
|
|
|
|
set_target_compile_flags(RTSanitizerCommon.osx ${SANITIZER_CFLAGS})
|
|
|
|
filter_available_targets(SANITIZER_TARGETS x86_64 i386)
|
|
|
|
set_target_properties(RTSanitizerCommon.osx PROPERTIES
|
|
|
|
OSX_ARCHITECTURES "${SANITIZER_TARGETS}")
|
2012-08-13 15:41:43 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx)
|
2012-08-10 22:45:52 +08:00
|
|
|
else()
|
|
|
|
# Otherwise, build separate libraries for each target.
|
|
|
|
if(CAN_TARGET_X86_64)
|
|
|
|
add_library(RTSanitizerCommon.x86_64 OBJECT ${SANITIZER_SOURCES})
|
|
|
|
set_target_compile_flags(RTSanitizerCommon.x86_64
|
|
|
|
${SANITIZER_CFLAGS} ${TARGET_X86_64_CFLAGS})
|
2012-08-13 15:41:43 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.x86_64)
|
2012-08-10 22:45:52 +08:00
|
|
|
endif()
|
|
|
|
if(CAN_TARGET_I386)
|
|
|
|
add_library(RTSanitizerCommon.i386 OBJECT ${SANITIZER_SOURCES})
|
|
|
|
set_target_compile_flags(RTSanitizerCommon.i386
|
|
|
|
${SANITIZER_CFLAGS} ${TARGET_I386_CFLAGS})
|
2012-08-13 15:41:43 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.i386)
|
2012-08-10 22:45:52 +08:00
|
|
|
endif()
|
2012-08-27 22:28:27 +08:00
|
|
|
if(CAN_TARGET_ARM_ANDROID)
|
|
|
|
add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES})
|
|
|
|
set_target_compile_flags(RTSanitizerCommon.arm.android
|
|
|
|
${SANITIZER_CFLAGS} ${TARGET_ARM_ANDROID_CFLAGS})
|
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
|
|
|
|
endif()
|
2012-06-20 18:18:43 +08:00
|
|
|
endif()
|
2012-08-10 22:45:52 +08:00
|
|
|
|
2012-09-11 18:50:32 +08:00
|
|
|
# Unit tests for common sanitizer runtime.
|
|
|
|
if(LLVM_INCLUDE_TESTS)
|
|
|
|
# Build stand-alone static sanitizer runtime for use in unit tests.
|
|
|
|
add_library(RTSanitizerCommon.test STATIC ${SANITIZER_SOURCES})
|
|
|
|
# Build test library with debug info.
|
|
|
|
set_target_compile_flags(RTSanitizerCommon.test
|
|
|
|
${SANITIZER_CFLAGS} -g -Werror)
|
|
|
|
set_target_properties(RTSanitizerCommon.test PROPERTIES
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
2012-08-13 15:41:43 +08:00
|
|
|
|
2012-09-11 18:50:32 +08:00
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|