1 # Build system for the common Sanitizer runtime support library components.
2 # These components are shared between AddressSanitizer and ThreadSanitizer.
4 set(SANITIZER_SOURCES_NOTERMINATION
5 sanitizer_allocator.cpp
7 sanitizer_deadlock_detector1.cpp
8 sanitizer_deadlock_detector2.cpp
12 sanitizer_flag_parser.cpp
15 sanitizer_libignore.cpp
17 sanitizer_linux_s390.cpp
21 sanitizer_platform_limits_freebsd.cpp
22 sanitizer_platform_limits_linux.cpp
23 sanitizer_platform_limits_netbsd.cpp
24 sanitizer_platform_limits_posix.cpp
25 sanitizer_platform_limits_solaris.cpp
28 sanitizer_procmaps_common.cpp
29 sanitizer_procmaps_bsd.cpp
30 sanitizer_procmaps_fuchsia.cpp
31 sanitizer_procmaps_linux.cpp
32 sanitizer_procmaps_mac.cpp
33 sanitizer_procmaps_solaris.cpp
35 sanitizer_stoptheworld_fuchsia.cpp
36 sanitizer_stoptheworld_mac.cpp
37 sanitizer_stoptheworld_win.cpp
38 sanitizer_suppressions.cpp
39 sanitizer_tls_get_addr.cpp
40 sanitizer_thread_registry.cpp
41 sanitizer_type_traits.cpp
46 ${SANITIZER_SOURCES_NOTERMINATION}
47 sanitizer_termination.cpp
50 # Libc functions stubs. These sources should be linked instead of
51 # SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
53 set(SANITIZER_NOLIBC_SOURCES
54 sanitizer_common_nolibc.cpp
57 set(SANITIZER_LIBCDEP_SOURCES
58 sanitizer_common_libcdep.cpp
59 sanitizer_allocator_checks.cpp
60 sanitizer_linux_libcdep.cpp
61 sanitizer_mac_libcdep.cpp
62 sanitizer_posix_libcdep.cpp
63 sanitizer_stoptheworld_linux_libcdep.cpp
64 sanitizer_stoptheworld_netbsd_libcdep.cpp
67 set(SANITIZER_COVERAGE_SOURCES
69 sanitizer_coverage_fuchsia.cpp
70 sanitizer_coverage_libcdep_new.cpp
71 sanitizer_coverage_win_sections.cpp
74 set(SANITIZER_SYMBOLIZER_SOURCES
75 sanitizer_allocator_report.cpp
76 sanitizer_chained_origin_depot.cpp
77 sanitizer_stack_store.cpp
78 sanitizer_stackdepot.cpp
79 sanitizer_stacktrace.cpp
80 sanitizer_stacktrace_libcdep.cpp
81 sanitizer_stacktrace_printer.cpp
82 sanitizer_stacktrace_sparc.cpp
83 sanitizer_symbolizer.cpp
84 sanitizer_symbolizer_libbacktrace.cpp
85 sanitizer_symbolizer_libcdep.cpp
86 sanitizer_symbolizer_mac.cpp
87 sanitizer_symbolizer_markup.cpp
88 sanitizer_symbolizer_posix_libcdep.cpp
89 sanitizer_symbolizer_report.cpp
90 sanitizer_symbolizer_win.cpp
91 sanitizer_unwind_linux_libcdep.cpp
92 sanitizer_unwind_win.cpp
95 # Explicitly list all sanitizer_common headers. Not all of these are
96 # included in sanitizer_common source files, but we need to depend on
97 # headers when building our custom unit tests.
98 set(SANITIZER_IMPL_HEADERS
101 sanitizer_addrhashmap.h
102 sanitizer_allocator.h
103 sanitizer_allocator_checks.h
104 sanitizer_allocator_combined.h
105 sanitizer_allocator_dlsym.h
106 sanitizer_allocator_interface.h
107 sanitizer_allocator_internal.h
108 sanitizer_allocator_local_cache.h
109 sanitizer_allocator_primary32.h
110 sanitizer_allocator_primary64.h
111 sanitizer_allocator_report.h
112 sanitizer_allocator_secondary.h
113 sanitizer_allocator_size_class_map.h
114 sanitizer_allocator_stats.h
117 sanitizer_atomic_clang.h
118 sanitizer_atomic_clang_mips.h
119 sanitizer_atomic_clang_other.h
120 sanitizer_atomic_clang_x86.h
121 sanitizer_atomic_msvc.h
122 sanitizer_bitvector.h
124 sanitizer_chained_origin_depot.h
126 sanitizer_common_interceptors.inc
127 sanitizer_common_interceptors_format.inc
128 sanitizer_common_interceptors_ioctl.inc
129 sanitizer_common_interface.inc
130 sanitizer_common_interface_posix.inc
131 sanitizer_common_syscalls.inc
132 sanitizer_coverage_interface.inc
134 sanitizer_deadlock_detector.h
135 sanitizer_deadlock_detector_interface.h
136 sanitizer_dense_map.h
137 sanitizer_dense_map_info.h
139 sanitizer_errno_codes.h
141 sanitizer_flag_parser.h
147 sanitizer_getauxval.h
149 sanitizer_interceptors_ioctl_netbsd.inc
150 sanitizer_interface_internal.h
151 sanitizer_internal_defs.h
155 sanitizer_libignore.h
158 sanitizer_local_address_space_view.h
161 sanitizer_malloc_mac.inc
163 sanitizer_placement_new.h
165 sanitizer_platform_interceptors.h
166 sanitizer_platform_limits_netbsd.h
167 sanitizer_platform_limits_posix.h
168 sanitizer_platform_limits_solaris.h
172 sanitizer_quarantine.h
173 sanitizer_report_decorator.h
174 sanitizer_ring_buffer.h
175 sanitizer_signal_interceptors.inc
176 sanitizer_stack_store.h
177 sanitizer_stackdepot.h
178 sanitizer_stackdepotbase.h
179 sanitizer_stacktrace.h
180 sanitizer_stacktrace_printer.h
181 sanitizer_stoptheworld.h
182 sanitizer_suppressions.h
183 sanitizer_symbolizer.h
184 sanitizer_symbolizer_fuchsia.h
185 sanitizer_symbolizer_internal.h
186 sanitizer_symbolizer_libbacktrace.h
187 sanitizer_symbolizer_mac.h
188 sanitizer_syscall_generic.inc
189 sanitizer_syscall_linux_aarch64.inc
190 sanitizer_syscall_linux_arm.inc
191 sanitizer_syscall_linux_x86_64.inc
192 sanitizer_syscall_linux_riscv64.inc
193 sanitizer_syscalls_netbsd.inc
194 sanitizer_thread_registry.h
195 sanitizer_thread_safety.h
196 sanitizer_tls_get_addr.h
200 sanitizer_win_dll_thunk.h
201 sanitizer_win_weak_interception.h
204 include_directories(..)
206 set(SANITIZER_COMMON_DEFINITIONS
207 HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
209 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
211 # Too many existing bugs, needs cleanup.
212 append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SANITIZER_CFLAGS)
214 append_rtti_flag(OFF SANITIZER_CFLAGS)
216 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570
218 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
222 set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
225 add_compiler_rt_object_libraries(RTSanitizerCommon
227 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
228 SOURCES ${SANITIZER_SOURCES}
229 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
230 CFLAGS ${SANITIZER_CFLAGS}
231 DEFS ${SANITIZER_COMMON_DEFINITIONS})
232 add_compiler_rt_object_libraries(RTSanitizerCommonNoTermination
234 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
235 SOURCES ${SANITIZER_SOURCES_NOTERMINATION}
236 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
237 CFLAGS ${SANITIZER_CFLAGS}
238 DEFS ${SANITIZER_COMMON_DEFINITIONS})
239 add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc
241 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
242 SOURCES ${SANITIZER_NOLIBC_SOURCES}
243 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
244 CFLAGS ${SANITIZER_CFLAGS}
245 DEFS ${SANITIZER_COMMON_DEFINITIONS})
246 add_compiler_rt_object_libraries(RTSanitizerCommonLibc
248 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
249 SOURCES ${SANITIZER_LIBCDEP_SOURCES}
250 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
251 CFLAGS ${SANITIZER_CFLAGS}
252 DEFS ${SANITIZER_COMMON_DEFINITIONS})
253 add_compiler_rt_object_libraries(RTSanitizerCommonCoverage
255 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
256 SOURCES ${SANITIZER_COVERAGE_SOURCES}
257 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
258 CFLAGS ${SANITIZER_CFLAGS}
259 DEFS ${SANITIZER_COMMON_DEFINITIONS})
260 add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizer
262 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
263 SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
264 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
265 CFLAGS ${SANITIZER_CFLAGS}
266 DEFS ${SANITIZER_COMMON_DEFINITIONS})
268 set(SANITIZER_NO_WEAK_HOOKS_CFLAGS ${SANITIZER_CFLAGS})
269 list(APPEND SANITIZER_NO_WEAK_HOOKS_CFLAGS "-DSANITIZER_SUPPORTS_WEAK_HOOKS=0")
270 add_compiler_rt_object_libraries(RTSanitizerCommonNoHooks
272 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
273 SOURCES ${SANITIZER_SOURCES}
274 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
275 CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
276 DEFS ${SANITIZER_COMMON_DEFINITIONS})
277 add_compiler_rt_object_libraries(RTSanitizerCommonLibcNoHooks
279 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
280 SOURCES ${SANITIZER_LIBCDEP_SOURCES}
281 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
282 CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
283 DEFS ${SANITIZER_COMMON_DEFINITIONS})
284 add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizerNoHooks
286 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
287 SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
288 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
289 CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
290 DEFS ${SANITIZER_COMMON_DEFINITIONS})
293 add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
294 ${SANITIZER_COMMON_SUPPORTED_OS}
295 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
297 sanitizer_win_weak_interception.cpp
298 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
299 DEFS ${SANITIZER_COMMON_DEFINITIONS})
300 add_compiler_rt_object_libraries(SancovWeakInterception
301 ${SANITIZER_COMMON_SUPPORTED_OS}
302 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
304 sanitizer_coverage_win_weak_interception.cpp
305 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
306 DEFS ${SANITIZER_COMMON_DEFINITIONS})
308 add_compiler_rt_object_libraries(SanitizerCommonDllThunk
309 ${SANITIZER_COMMON_SUPPORTED_OS}
310 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
312 sanitizer_win_dll_thunk.cpp
313 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
314 DEFS ${SANITIZER_COMMON_DEFINITIONS})
315 add_compiler_rt_object_libraries(SancovDllThunk
316 ${SANITIZER_COMMON_SUPPORTED_OS}
317 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
319 sanitizer_coverage_win_dll_thunk.cpp
320 sanitizer_coverage_win_sections.cpp
321 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
322 DEFS ${SANITIZER_COMMON_DEFINITIONS})
324 set(DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK")
326 list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl")
327 elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
328 list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs")
330 add_compiler_rt_object_libraries(SanitizerCommonDynamicRuntimeThunk
331 ${SANITIZER_COMMON_SUPPORTED_OS}
332 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
334 sanitizer_win_dynamic_runtime_thunk.cpp
335 CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
336 DEFS ${SANITIZER_COMMON_DEFINITIONS})
337 add_compiler_rt_object_libraries(SancovDynamicRuntimeThunk
338 ${SANITIZER_COMMON_SUPPORTED_OS}
339 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
341 sanitizer_coverage_win_dynamic_runtime_thunk.cpp
342 sanitizer_coverage_win_sections.cpp
343 CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
344 DEFS ${SANITIZER_COMMON_DEFINITIONS})
347 # Unit tests for common sanitizer runtime.
348 if(COMPILER_RT_INCLUDE_TESTS)
349 add_subdirectory(tests)