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
|
2013-11-15 15:18:15 +08:00
|
|
|
sanitizer_coverage.cc
|
2012-07-10 17:17:06 +08:00
|
|
|
sanitizer_flags.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_libc.cc
|
2013-10-03 21:37:17 +08:00
|
|
|
sanitizer_libignore.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_linux.cc
|
|
|
|
sanitizer_mac.cc
|
2013-09-06 22:20:01 +08:00
|
|
|
sanitizer_platform_limits_linux.cc
|
2013-02-19 17:19:16 +08:00
|
|
|
sanitizer_platform_limits_posix.cc
|
2012-06-20 18:18:43 +08:00
|
|
|
sanitizer_posix.cc
|
|
|
|
sanitizer_printf.cc
|
2013-12-25 16:01:16 +08:00
|
|
|
sanitizer_procmaps_linux.cc
|
|
|
|
sanitizer_procmaps_mac.cc
|
2012-09-11 18:50:32 +08:00
|
|
|
sanitizer_stackdepot.cc
|
2012-08-28 22:11:57 +08:00
|
|
|
sanitizer_stacktrace.cc
|
2013-06-26 23:37:14 +08:00
|
|
|
sanitizer_suppressions.cc
|
2013-10-26 07:03:29 +08:00
|
|
|
sanitizer_symbolizer.cc
|
2014-01-16 21:48:15 +08:00
|
|
|
sanitizer_symbolizer_libbacktrace.cc
|
2012-08-14 21:00:32 +08:00
|
|
|
sanitizer_symbolizer_win.cc
|
2013-03-14 21:54:30 +08:00
|
|
|
sanitizer_thread_registry.cc
|
2013-06-11 16:13:36 +08:00
|
|
|
sanitizer_win.cc)
|
2012-06-20 18:18:43 +08:00
|
|
|
|
2013-05-18 00:17:19 +08:00
|
|
|
set(SANITIZER_LIBCDEP_SOURCES
|
|
|
|
sanitizer_common_libcdep.cc
|
2013-05-20 23:57:44 +08:00
|
|
|
sanitizer_linux_libcdep.cc
|
2013-05-21 18:27:07 +08:00
|
|
|
sanitizer_posix_libcdep.cc
|
2013-11-07 14:33:06 +08:00
|
|
|
sanitizer_stacktrace_libcdep.cc
|
2013-05-21 19:38:39 +08:00
|
|
|
sanitizer_stoptheworld_linux_libcdep.cc
|
2013-10-26 07:03:29 +08:00
|
|
|
sanitizer_symbolizer_libcdep.cc
|
2013-06-11 16:13:36 +08:00
|
|
|
sanitizer_symbolizer_posix_libcdep.cc)
|
2013-05-18 00:17:19 +08:00
|
|
|
|
2012-12-21 22:04:52 +08:00
|
|
|
# Explicitly list all sanitizer_common headers. Not all of these are
|
|
|
|
# included in sanitizer_common source files, but we need to depend on
|
|
|
|
# headers when building our custom unit tests.
|
|
|
|
set(SANITIZER_HEADERS
|
|
|
|
sanitizer_allocator.h
|
2013-05-29 17:15:39 +08:00
|
|
|
sanitizer_allocator_internal.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_atomic.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_atomic_clang.h
|
|
|
|
sanitizer_atomic_msvc.h
|
|
|
|
sanitizer_common.h
|
2013-01-18 21:01:18 +08:00
|
|
|
sanitizer_common_interceptors.inc
|
2013-06-20 17:19:28 +08:00
|
|
|
sanitizer_common_interceptors_ioctl.inc
|
2014-01-21 21:01:20 +08:00
|
|
|
sanitizer_common_interceptors_format.inc
|
2013-04-11 22:37:04 +08:00
|
|
|
sanitizer_common_syscalls.inc
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_flags.h
|
|
|
|
sanitizer_internal_defs.h
|
2013-01-14 16:23:34 +08:00
|
|
|
sanitizer_lfstack.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_libc.h
|
2013-10-03 21:37:17 +08:00
|
|
|
sanitizer_libignore.h
|
2013-02-27 19:22:40 +08:00
|
|
|
sanitizer_linux.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_list.h
|
|
|
|
sanitizer_mutex.h
|
|
|
|
sanitizer_placement_new.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_platform.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_platform_interceptors.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_platform_limits_posix.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_procmaps.h
|
2013-01-11 16:07:43 +08:00
|
|
|
sanitizer_quarantine.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_report_decorator.h
|
|
|
|
sanitizer_stackdepot.h
|
|
|
|
sanitizer_stacktrace.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_stoptheworld.h
|
|
|
|
sanitizer_suppressions.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_symbolizer.h
|
2014-01-16 21:48:15 +08:00
|
|
|
sanitizer_symbolizer_libbacktrace.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_syscall_generic.inc
|
|
|
|
sanitizer_syscall_linux_x86_64.inc
|
2013-06-11 16:13:36 +08:00
|
|
|
sanitizer_thread_registry.h)
|
2012-12-21 22:04:52 +08:00
|
|
|
|
2014-01-28 17:28:57 +08:00
|
|
|
set(SANITIZER_COMMON_DEFINITIONS)
|
|
|
|
|
|
|
|
if(ANDROID)
|
|
|
|
list(APPEND SANITIZER_COMMON_DEFINITIONS
|
2014-01-28 22:17:16 +08:00
|
|
|
SANITIZER_NEEDS_SEGV=0)
|
2014-01-28 17:28:57 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
list(APPEND SANITIZER_COMMON_DEFINITIONS
|
|
|
|
SANITIZER_NEEDS_SEGV=0)
|
|
|
|
else()
|
|
|
|
list(APPEND SANITIZER_COMMON_DEFINITIONS
|
|
|
|
SANITIZER_NEEDS_SEGV=1)
|
|
|
|
endif()
|
|
|
|
|
2013-08-27 09:24:01 +08:00
|
|
|
if (NOT MSVC)
|
|
|
|
set(SANITIZER_CFLAGS
|
|
|
|
${SANITIZER_COMMON_CFLAGS}
|
|
|
|
-fno-rtti)
|
|
|
|
else()
|
|
|
|
set(SANITIZER_CFLAGS
|
|
|
|
${SANITIZER_COMMON_CFLAGS}
|
|
|
|
/GR-)
|
|
|
|
endif()
|
2012-06-25 16:40:10 +08:00
|
|
|
|
2013-09-11 17:57:15 +08:00
|
|
|
if(SUPPORTS_GLOBAL_CONSTRUCTORS_FLAG)
|
|
|
|
list(APPEND SANITIZER_CFLAGS -Wglobal-constructors)
|
|
|
|
endif()
|
|
|
|
|
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.
|
2013-11-07 18:08:19 +08:00
|
|
|
foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS})
|
|
|
|
add_compiler_rt_darwin_object_library(RTSanitizerCommon ${os}
|
|
|
|
ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}
|
2014-01-28 17:28:57 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2013-11-07 18:08:19 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${os})
|
|
|
|
endforeach()
|
2013-01-19 00:05:21 +08:00
|
|
|
elseif(ANDROID)
|
2013-05-18 00:17:19 +08:00
|
|
|
add_library(RTSanitizerCommon.arm.android OBJECT
|
|
|
|
${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES})
|
2013-01-19 00:05:21 +08:00
|
|
|
set_target_compile_flags(RTSanitizerCommon.arm.android
|
|
|
|
${SANITIZER_CFLAGS})
|
2014-01-28 17:28:57 +08:00
|
|
|
set_property(TARGET RTSanitizerCommon.arm.android APPEND PROPERTY
|
|
|
|
COMPILE_DEFINITIONS ${SANITIZER_COMMON_DEFINITIONS})
|
2013-01-19 00:05:21 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.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 ${SANITIZER_COMMON_SUPPORTED_ARCH})
|
|
|
|
add_compiler_rt_object_library(RTSanitizerCommon ${arch}
|
2014-01-28 17:28:57 +08:00
|
|
|
SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2013-05-18 00:17:19 +08:00
|
|
|
add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}
|
2014-01-28 17:28:57 +08:00
|
|
|
SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2013-03-21 07:49:17 +08:00
|
|
|
add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}
|
2013-05-20 03:53:01 +08:00
|
|
|
SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
|
2014-01-28 17:28:57 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2013-09-16 23:43:23 +08:00
|
|
|
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch}
|
|
|
|
RTSanitizerCommonLibc.${arch})
|
2013-01-19 00:51:07 +08:00
|
|
|
endforeach()
|
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)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|