[clang][extract-api] Emit "navigator" property of "name" in SymbolGraph
[llvm-project.git] / compiler-rt / lib / sanitizer_common / CMakeLists.txt
blob6c4c1c1849a1d93a735777fe4e81e7012117f2a7
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
6   sanitizer_common.cpp
7   sanitizer_deadlock_detector1.cpp
8   sanitizer_deadlock_detector2.cpp
9   sanitizer_errno.cpp
10   sanitizer_file.cpp
11   sanitizer_flags.cpp
12   sanitizer_flag_parser.cpp
13   sanitizer_fuchsia.cpp
14   sanitizer_libc.cpp
15   sanitizer_libignore.cpp
16   sanitizer_linux.cpp
17   sanitizer_linux_s390.cpp
18   sanitizer_mac.cpp
19   sanitizer_mutex.cpp
20   sanitizer_netbsd.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
26   sanitizer_posix.cpp
27   sanitizer_printf.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
34   sanitizer_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
42   sanitizer_win.cpp
43   )
45 set(SANITIZER_SOURCES
46   ${SANITIZER_SOURCES_NOTERMINATION}
47   sanitizer_termination.cpp
48   )
50 # Libc functions stubs. These sources should be linked instead of
51 # SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
52 # libc.
53 set(SANITIZER_NOLIBC_SOURCES
54   sanitizer_common_nolibc.cpp
55   )
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
65   )
67 set(SANITIZER_COVERAGE_SOURCES
68   sancov_flags.cpp
69   sanitizer_coverage_fuchsia.cpp
70   sanitizer_coverage_libcdep_new.cpp
71   sanitizer_coverage_win_sections.cpp
72   )
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
93   )
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
99   sancov_flags.h
100   sancov_flags.inc
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
115   sanitizer_asm.h
116   sanitizer_atomic.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
123   sanitizer_bvgraph.h
124   sanitizer_chained_origin_depot.h
125   sanitizer_common.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
133   sanitizer_dbghelp.h
134   sanitizer_deadlock_detector.h
135   sanitizer_deadlock_detector_interface.h
136   sanitizer_dense_map.h
137   sanitizer_dense_map_info.h
138   sanitizer_errno.h
139   sanitizer_errno_codes.h
140   sanitizer_file.h
141   sanitizer_flag_parser.h
142   sanitizer_flags.h
143   sanitizer_flags.inc
144   sanitizer_flat_map.h
145   sanitizer_freebsd.h
146   sanitizer_fuchsia.h
147   sanitizer_getauxval.h
148   sanitizer_hash.h
149   sanitizer_interceptors_ioctl_netbsd.inc
150   sanitizer_interface_internal.h
151   sanitizer_internal_defs.h
152   sanitizer_leb128.h
153   sanitizer_lfstack.h
154   sanitizer_libc.h
155   sanitizer_libignore.h
156   sanitizer_linux.h
157   sanitizer_list.h
158   sanitizer_local_address_space_view.h
159   sanitizer_lzw.h
160   sanitizer_mac.h
161   sanitizer_malloc_mac.inc
162   sanitizer_mutex.h
163   sanitizer_placement_new.h
164   sanitizer_platform.h
165   sanitizer_platform_interceptors.h
166   sanitizer_platform_limits_netbsd.h
167   sanitizer_platform_limits_posix.h
168   sanitizer_platform_limits_solaris.h
169   sanitizer_posix.h
170   sanitizer_procmaps.h
171   sanitizer_ptrauth.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
197   sanitizer_vector.h
198   sanitizer_win.h
199   sanitizer_win_defs.h
200   sanitizer_win_dll_thunk.h
201   sanitizer_win_weak_interception.h
202   )
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
217                SANITIZER_CFLAGS)
218 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
219                SANITIZER_CFLAGS)
221 if(APPLE)
222   set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
223 endif()
225 add_compiler_rt_object_libraries(RTSanitizerCommon
226   ${OS_OPTION}
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
233   ${OS_OPTION}
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
240   ${OS_OPTION}
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
247   ${OS_OPTION}
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
254   ${OS_OPTION}
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
261   ${OS_OPTION}
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
271   ${OS_OPTION}
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
278   ${OS_OPTION}
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
285   ${OS_OPTION}
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})
292 if(WIN32)
293   add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
294     ${SANITIZER_COMMON_SUPPORTED_OS}
295     ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
296     SOURCES
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}
303     SOURCES
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}
311     SOURCES
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}
318     SOURCES
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")
325   if(MSVC)
326     list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl")
327   elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
328     list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs")
329   endif()
330   add_compiler_rt_object_libraries(SanitizerCommonDynamicRuntimeThunk
331     ${SANITIZER_COMMON_SUPPORTED_OS}
332     ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
333     SOURCES
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}
340     SOURCES
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})
345 endif()
347 # Unit tests for common sanitizer runtime.
348 if(COMPILER_RT_INCLUDE_TESTS)
349   add_subdirectory(tests)
350 endif()