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
36 sanitizer_stoptheworld_fuchsia.cpp
37 sanitizer_stoptheworld_mac.cpp
38 sanitizer_stoptheworld_win.cpp
39 sanitizer_suppressions.cpp
40 sanitizer_tls_get_addr.cpp
41 sanitizer_thread_arg_retval.cpp
42 sanitizer_thread_registry.cpp
43 sanitizer_type_traits.cpp
48 ${SANITIZER_SOURCES_NOTERMINATION}
49 sanitizer_termination.cpp
52 # Libc functions stubs. These sources should be linked instead of
53 # SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
55 set(SANITIZER_NOLIBC_SOURCES
56 sanitizer_common_nolibc.cpp
59 set(SANITIZER_LIBCDEP_SOURCES
60 sanitizer_common_libcdep.cpp
61 sanitizer_allocator_checks.cpp
62 sanitizer_linux_libcdep.cpp
63 sanitizer_mac_libcdep.cpp
64 sanitizer_posix_libcdep.cpp
65 sanitizer_stoptheworld_linux_libcdep.cpp
66 sanitizer_stoptheworld_netbsd_libcdep.cpp
69 set(SANITIZER_COVERAGE_SOURCES
71 sanitizer_coverage_fuchsia.cpp
72 sanitizer_coverage_libcdep_new.cpp
73 sanitizer_coverage_win_sections.cpp
76 set(SANITIZER_SYMBOLIZER_SOURCES
77 sanitizer_allocator_report.cpp
78 sanitizer_chained_origin_depot.cpp
79 sanitizer_stack_store.cpp
80 sanitizer_stackdepot.cpp
81 sanitizer_stacktrace.cpp
82 sanitizer_stacktrace_libcdep.cpp
83 sanitizer_stacktrace_printer.cpp
84 sanitizer_stacktrace_sparc.cpp
85 sanitizer_symbolizer.cpp
86 sanitizer_symbolizer_libbacktrace.cpp
87 sanitizer_symbolizer_libcdep.cpp
88 sanitizer_symbolizer_mac.cpp
89 sanitizer_symbolizer_markup.cpp
90 sanitizer_symbolizer_posix_libcdep.cpp
91 sanitizer_symbolizer_report.cpp
92 sanitizer_symbolizer_win.cpp
93 sanitizer_unwind_linux_libcdep.cpp
94 sanitizer_unwind_win.cpp
97 # Explicitly list all sanitizer_common headers. Not all of these are
98 # included in sanitizer_common source files, but we need to depend on
99 # headers when building our custom unit tests.
100 set(SANITIZER_IMPL_HEADERS
103 sanitizer_addrhashmap.h
104 sanitizer_allocator.h
105 sanitizer_allocator_checks.h
106 sanitizer_allocator_combined.h
107 sanitizer_allocator_dlsym.h
108 sanitizer_allocator_interface.h
109 sanitizer_allocator_internal.h
110 sanitizer_allocator_local_cache.h
111 sanitizer_allocator_primary32.h
112 sanitizer_allocator_primary64.h
113 sanitizer_allocator_report.h
114 sanitizer_allocator_secondary.h
115 sanitizer_allocator_size_class_map.h
116 sanitizer_allocator_stats.h
117 sanitizer_array_ref.h
120 sanitizer_atomic_clang.h
121 sanitizer_atomic_clang_mips.h
122 sanitizer_atomic_clang_other.h
123 sanitizer_atomic_clang_x86.h
124 sanitizer_atomic_msvc.h
125 sanitizer_bitvector.h
127 sanitizer_chained_origin_depot.h
129 sanitizer_common_interceptors.inc
130 sanitizer_common_interceptors_format.inc
131 sanitizer_common_interceptors_ioctl.inc
132 sanitizer_common_interceptors_memintrinsics.inc
133 sanitizer_common_interface.inc
134 sanitizer_common_interface_posix.inc
135 sanitizer_common_syscalls.inc
136 sanitizer_coverage_interface.inc
138 sanitizer_deadlock_detector.h
139 sanitizer_deadlock_detector_interface.h
140 sanitizer_dense_map.h
141 sanitizer_dense_map_info.h
143 sanitizer_errno_codes.h
145 sanitizer_flag_parser.h
151 sanitizer_getauxval.h
153 sanitizer_interceptors_ioctl_netbsd.inc
154 sanitizer_interface_internal.h
155 sanitizer_internal_defs.h
159 sanitizer_libignore.h
162 sanitizer_local_address_space_view.h
165 sanitizer_malloc_mac.inc
167 sanitizer_placement_new.h
169 sanitizer_platform_interceptors.h
170 sanitizer_platform_limits_netbsd.h
171 sanitizer_platform_limits_posix.h
172 sanitizer_platform_limits_solaris.h
176 sanitizer_quarantine.h
178 sanitizer_redefine_builtins.h
179 sanitizer_report_decorator.h
180 sanitizer_ring_buffer.h
181 sanitizer_signal_interceptors.inc
182 sanitizer_stack_store.h
183 sanitizer_stackdepot.h
184 sanitizer_stackdepotbase.h
185 sanitizer_stacktrace.h
186 sanitizer_stacktrace_printer.h
187 sanitizer_stoptheworld.h
188 sanitizer_suppressions.h
189 sanitizer_symbolizer.h
190 sanitizer_symbolizer_fuchsia.h
191 sanitizer_symbolizer_internal.h
192 sanitizer_symbolizer_libbacktrace.h
193 sanitizer_symbolizer_mac.h
194 sanitizer_syscall_generic.inc
195 sanitizer_syscall_linux_aarch64.inc
196 sanitizer_syscall_linux_arm.inc
197 sanitizer_syscall_linux_x86_64.inc
198 sanitizer_syscall_linux_riscv64.inc
199 sanitizer_syscall_linux_loongarch64.inc
200 sanitizer_syscalls_netbsd.inc
201 sanitizer_thread_registry.h
202 sanitizer_thread_safety.h
203 sanitizer_tls_get_addr.h
207 sanitizer_win_dll_thunk.h
208 sanitizer_win_weak_interception.h
211 include_directories(..)
213 set(SANITIZER_COMMON_DEFINITIONS
214 HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
216 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
218 # Too many existing bugs, needs cleanup.
219 append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SANITIZER_CFLAGS)
221 append_rtti_flag(OFF SANITIZER_CFLAGS)
223 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570
225 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
229 set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
232 add_compiler_rt_object_libraries(RTSanitizerCommon
234 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
235 SOURCES ${SANITIZER_SOURCES}
236 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
237 CFLAGS ${SANITIZER_CFLAGS}
238 DEFS ${SANITIZER_COMMON_DEFINITIONS})
239 add_compiler_rt_object_libraries(RTSanitizerCommonNoTermination
241 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
242 SOURCES ${SANITIZER_SOURCES_NOTERMINATION}
243 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
244 CFLAGS ${SANITIZER_CFLAGS}
245 DEFS ${SANITIZER_COMMON_DEFINITIONS})
246 add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc
248 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
249 SOURCES ${SANITIZER_NOLIBC_SOURCES}
250 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
251 CFLAGS ${SANITIZER_CFLAGS}
252 DEFS ${SANITIZER_COMMON_DEFINITIONS})
253 add_compiler_rt_object_libraries(RTSanitizerCommonLibc
255 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
256 SOURCES ${SANITIZER_LIBCDEP_SOURCES}
257 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
258 CFLAGS ${SANITIZER_CFLAGS}
259 DEFS ${SANITIZER_COMMON_DEFINITIONS})
260 add_compiler_rt_object_libraries(RTSanitizerCommonCoverage
262 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
263 SOURCES ${SANITIZER_COVERAGE_SOURCES}
264 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
265 CFLAGS ${SANITIZER_CFLAGS}
266 DEFS ${SANITIZER_COMMON_DEFINITIONS})
267 add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizer
269 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
270 SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
271 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
272 CFLAGS ${SANITIZER_CFLAGS}
273 DEFS ${SANITIZER_COMMON_DEFINITIONS})
275 set(SANITIZER_NO_WEAK_HOOKS_CFLAGS ${SANITIZER_CFLAGS})
276 list(APPEND SANITIZER_NO_WEAK_HOOKS_CFLAGS "-DSANITIZER_SUPPORTS_WEAK_HOOKS=0")
277 add_compiler_rt_object_libraries(RTSanitizerCommonNoHooks
279 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
280 SOURCES ${SANITIZER_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(RTSanitizerCommonLibcNoHooks
286 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
287 SOURCES ${SANITIZER_LIBCDEP_SOURCES}
288 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
289 CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
290 DEFS ${SANITIZER_COMMON_DEFINITIONS})
291 add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizerNoHooks
293 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
294 SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
295 ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
296 CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
297 DEFS ${SANITIZER_COMMON_DEFINITIONS})
300 add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
301 ${SANITIZER_COMMON_SUPPORTED_OS}
302 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
304 sanitizer_win_weak_interception.cpp
305 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
306 DEFS ${SANITIZER_COMMON_DEFINITIONS})
307 add_compiler_rt_object_libraries(SancovWeakInterception
308 ${SANITIZER_COMMON_SUPPORTED_OS}
309 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
311 sanitizer_coverage_win_weak_interception.cpp
312 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
313 DEFS ${SANITIZER_COMMON_DEFINITIONS})
315 add_compiler_rt_object_libraries(SanitizerCommonDllThunk
316 ${SANITIZER_COMMON_SUPPORTED_OS}
317 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
319 sanitizer_win_dll_thunk.cpp
320 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
321 DEFS ${SANITIZER_COMMON_DEFINITIONS})
322 add_compiler_rt_object_libraries(SancovDllThunk
323 ${SANITIZER_COMMON_SUPPORTED_OS}
324 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
326 sanitizer_coverage_win_dll_thunk.cpp
327 sanitizer_coverage_win_sections.cpp
328 CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
329 DEFS ${SANITIZER_COMMON_DEFINITIONS})
331 set(DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK")
333 list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl")
334 elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
335 list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs")
337 add_compiler_rt_object_libraries(SanitizerCommonDynamicRuntimeThunk
338 ${SANITIZER_COMMON_SUPPORTED_OS}
339 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
341 sanitizer_win_dynamic_runtime_thunk.cpp
342 CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
343 DEFS ${SANITIZER_COMMON_DEFINITIONS})
344 add_compiler_rt_object_libraries(SancovDynamicRuntimeThunk
345 ${SANITIZER_COMMON_SUPPORTED_OS}
346 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
348 sanitizer_coverage_win_dynamic_runtime_thunk.cpp
349 sanitizer_coverage_win_sections.cpp
350 CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
351 DEFS ${SANITIZER_COMMON_DEFINITIONS})
354 # Unit tests for common sanitizer runtime.
355 if(COMPILER_RT_INCLUDE_TESTS)
356 add_subdirectory(tests)
360 foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
361 # Library implementing InternalSymbolizer. Empty by default.
362 add_library(RTSanitizerCommonSymbolizerInternal.${arch}
363 OBJECT IMPORTED GLOBAL)
366 if (COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
367 add_subdirectory(symbolizer)