1 # Build system for the common Sanitizer runtime support library components.
2 # These components are shared between AddressSanitizer and ThreadSanitizer.
7 sanitizer_deadlock_detector1.cc
8 sanitizer_deadlock_detector2.cc
11 sanitizer_libignore.cc
14 sanitizer_persistent_allocator.cc
15 sanitizer_platform_limits_linux.cc
16 sanitizer_platform_limits_posix.cc
19 sanitizer_procmaps_linux.cc
20 sanitizer_procmaps_mac.cc
21 sanitizer_stackdepot.cc
22 sanitizer_stacktrace.cc
23 sanitizer_suppressions.cc
24 sanitizer_symbolizer.cc
25 sanitizer_symbolizer_libbacktrace.cc
26 sanitizer_symbolizer_win.cc
27 sanitizer_tls_get_addr.cc
28 sanitizer_thread_registry.cc
31 set(SANITIZER_LIBCDEP_SOURCES
32 sanitizer_common_libcdep.cc
33 sanitizer_coverage_libcdep.cc
34 sanitizer_coverage_mapping_libcdep.cc
35 sanitizer_linux_libcdep.cc
36 sanitizer_posix_libcdep.cc
37 sanitizer_stacktrace_libcdep.cc
38 sanitizer_stoptheworld_linux_libcdep.cc
39 sanitizer_symbolizer_libcdep.cc
40 sanitizer_symbolizer_posix_libcdep.cc)
42 # Explicitly list all sanitizer_common headers. Not all of these are
43 # included in sanitizer_common source files, but we need to depend on
44 # headers when building our custom unit tests.
46 sanitizer_addrhashmap.h
48 sanitizer_allocator_interface.h
49 sanitizer_allocator_internal.h
51 sanitizer_atomic_clang.h
52 sanitizer_atomic_msvc.h
56 sanitizer_common_interceptors.inc
57 sanitizer_common_interceptors_ioctl.inc
58 sanitizer_common_interceptors_format.inc
59 sanitizer_common_syscalls.inc
60 sanitizer_deadlock_detector.h
61 sanitizer_deadlock_detector_interface.h
63 sanitizer_internal_defs.h
71 sanitizer_persistent_allocator.h
72 sanitizer_placement_new.h
74 sanitizer_platform_interceptors.h
75 sanitizer_platform_limits_posix.h
77 sanitizer_quarantine.h
78 sanitizer_report_decorator.h
79 sanitizer_stackdepot.h
80 sanitizer_stackdepotbase.h
81 sanitizer_stacktrace.h
82 sanitizer_stoptheworld.h
83 sanitizer_suppressions.h
84 sanitizer_symbolizer.h
85 sanitizer_symbolizer_libbacktrace.h
86 sanitizer_syscall_generic.inc
87 sanitizer_syscall_linux_x86_64.inc
88 sanitizer_thread_registry.h)
90 set(SANITIZER_COMMON_DEFINITIONS)
93 list(APPEND SANITIZER_COMMON_DEFINITIONS
94 SANITIZER_NEEDS_SEGV=0)
96 list(APPEND SANITIZER_COMMON_DEFINITIONS
97 SANITIZER_NEEDS_SEGV=1)
100 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
101 append_no_rtti_flag(SANITIZER_CFLAGS)
103 append_if(COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG -Wframe-larger-than=512 SANITIZER_CFLAGS)
104 append_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors SANITIZER_CFLAGS)
106 add_custom_target(sanitizer_common)
107 set(SANITIZER_RUNTIME_LIBRARIES)
109 # Build universal binary on APPLE.
110 foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS})
111 add_compiler_rt_darwin_object_library(RTSanitizerCommon ${os}
112 ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}
113 SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}
114 CFLAGS ${SANITIZER_CFLAGS}
115 DEFS ${SANITIZER_COMMON_DEFINITIONS})
116 list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${os})
119 add_library(RTSanitizerCommon.arm.android OBJECT
120 ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES})
121 set_target_compile_flags(RTSanitizerCommon.arm.android
123 set_property(TARGET RTSanitizerCommon.arm.android APPEND PROPERTY
124 COMPILE_DEFINITIONS ${SANITIZER_COMMON_DEFINITIONS})
125 list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
127 # Otherwise, build separate libraries for each target.
128 foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
129 add_compiler_rt_object_library(RTSanitizerCommon ${arch}
130 SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
131 DEFS ${SANITIZER_COMMON_DEFINITIONS})
132 add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}
133 SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS}
134 DEFS ${SANITIZER_COMMON_DEFINITIONS})
135 list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch}
136 RTSanitizerCommonLibc.${arch})
137 add_compiler_rt_runtime(clang_rt.san-${arch} ${arch} STATIC
138 SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
139 $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
140 CFLAGS ${SANITIZER_CFLAGS}
141 DEFS ${SANITIZER_COMMON_DEFINITIONS})
142 add_dependencies(sanitizer_common clang_rt.san-${arch})
146 add_dependencies(compiler-rt sanitizer_common)
148 # Unit tests for common sanitizer runtime.
149 if(COMPILER_RT_INCLUDE_TESTS)
150 add_subdirectory(tests)