CMakeLists.txt revision e6e564d232f95719277476308937856328c63682
103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# Build system for the common Sanitizer runtime support library components.
203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# These components are shared between AddressSanitizer and ThreadSanitizer.
303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)set(SANITIZER_SOURCES
503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_allocator.cc
603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common.cc
703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_flags.cc
803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_libc.cc
903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_linux.cc
1003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_mac.cc
1103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_platform_limits_linux.cc
1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_platform_limits_posix.cc
1303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_posix.cc
1403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_printf.cc
1503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_stackdepot.cc
1603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_stacktrace.cc
1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_suppressions.cc
1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_itanium.cc
1903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_linux.cc
2003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_mac.cc
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_win.cc
2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_thread_registry.cc
2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_win.cc)
2403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
2503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)set(SANITIZER_LIBCDEP_SOURCES
2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common_libcdep.cc
2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_linux_libcdep.cc
2803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_posix_libcdep.cc
2903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_stoptheworld_linux_libcdep.cc
3003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_libcdep.cc
3103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_linux_libcdep.cc
3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_symbolizer_posix_libcdep.cc)
3303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# Explicitly list all sanitizer_common headers. Not all of these are
3503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# included in sanitizer_common source files, but we need to depend on
3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# headers when building our custom unit tests.
3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)set(SANITIZER_HEADERS
3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_allocator.h
3903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_allocator_internal.h
4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_atomic_clang.h
4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_atomic_msvc.h
4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_atomic.h
4303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common.h
4403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common_interceptors.inc
4503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common_interceptors_ioctl.inc
4603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common_interceptors_scanf.inc
4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_common_syscalls.inc
4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_flags.h
4903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_internal_defs.h
5003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_lfstack.h
5103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_libc.h
5203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_linux.h
5303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_list.h
5403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_mutex.h
5503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_placement_new.h
5603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_platform_interceptors.h
5703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_platform_limits_posix.h
5803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_procmaps.h
5903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_quarantine.h
6003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_report_decorator.h
6103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  sanitizer_stackdepot.h
62  sanitizer_stacktrace.h
63  sanitizer_symbolizer.h
64  sanitizer_thread_registry.h)
65
66set(SANITIZER_CFLAGS
67  ${SANITIZER_COMMON_CFLAGS}
68  -fno-rtti)
69
70set(SANITIZER_RUNTIME_LIBRARIES)
71if(APPLE)
72  # Build universal binary on APPLE.
73  add_compiler_rt_osx_object_library(RTSanitizerCommon
74    ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}
75    SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}
76    CFLAGS ${SANITIZER_CFLAGS})
77  list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx)
78elseif(ANDROID)
79  add_library(RTSanitizerCommon.arm.android OBJECT
80    ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES})
81  set_target_compile_flags(RTSanitizerCommon.arm.android
82    ${SANITIZER_CFLAGS})
83  list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
84else()
85  # Otherwise, build separate libraries for each target.
86  foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
87    add_compiler_rt_object_library(RTSanitizerCommon ${arch}
88      SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
89    add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}
90      SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
91    add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}
92      SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
93              $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
94      CFLAGS ${SANITIZER_CFLAGS})
95    list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch})
96  endforeach()
97endif()
98
99# Unit tests for common sanitizer runtime.
100if(LLVM_INCLUDE_TESTS)
101  add_subdirectory(tests)
102endif()
103