1# Build system for the common Sanitizer runtime support library components. 2# These components are shared between AddressSanitizer and ThreadSanitizer. 3 4set(SANITIZER_SOURCES 5 sanitizer_allocator.cc 6 sanitizer_common.cc 7 sanitizer_deadlock_detector1.cc 8 sanitizer_deadlock_detector2.cc 9 sanitizer_flags.cc 10 sanitizer_flag_parser.cc 11 sanitizer_libc.cc 12 sanitizer_libignore.cc 13 sanitizer_linux.cc 14 sanitizer_mac.cc 15 sanitizer_persistent_allocator.cc 16 sanitizer_platform_limits_linux.cc 17 sanitizer_platform_limits_posix.cc 18 sanitizer_posix.cc 19 sanitizer_printf.cc 20 sanitizer_procmaps_common.cc 21 sanitizer_procmaps_freebsd.cc 22 sanitizer_procmaps_linux.cc 23 sanitizer_procmaps_mac.cc 24 sanitizer_stackdepot.cc 25 sanitizer_stacktrace.cc 26 sanitizer_stacktrace_printer.cc 27 sanitizer_suppressions.cc 28 sanitizer_symbolizer.cc 29 sanitizer_symbolizer_libbacktrace.cc 30 sanitizer_symbolizer_mac.cc 31 sanitizer_symbolizer_win.cc 32 sanitizer_tls_get_addr.cc 33 sanitizer_thread_registry.cc 34 sanitizer_win.cc) 35 36# Libc functions stubs. These sources should be linked instead of 37# SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on 38# libc. 39set(SANITIZER_NOLIBC_SOURCES 40 sanitizer_common_nolibc.cc) 41 42set(SANITIZER_LIBCDEP_SOURCES 43 sanitizer_common_libcdep.cc 44 sanitizer_coverage_libcdep.cc 45 sanitizer_coverage_mapping_libcdep.cc 46 sanitizer_linux_libcdep.cc 47 sanitizer_posix_libcdep.cc 48 sanitizer_stacktrace_libcdep.cc 49 sanitizer_stoptheworld_linux_libcdep.cc 50 sanitizer_symbolizer_libcdep.cc 51 sanitizer_symbolizer_posix_libcdep.cc 52 sanitizer_unwind_linux_libcdep.cc) 53 54# Explicitly list all sanitizer_common headers. Not all of these are 55# included in sanitizer_common source files, but we need to depend on 56# headers when building our custom unit tests. 57set(SANITIZER_HEADERS 58 sanitizer_addrhashmap.h 59 sanitizer_allocator.h 60 sanitizer_allocator_interface.h 61 sanitizer_allocator_internal.h 62 sanitizer_atomic.h 63 sanitizer_atomic_clang.h 64 sanitizer_atomic_msvc.h 65 sanitizer_bitvector.h 66 sanitizer_bvgraph.h 67 sanitizer_common.h 68 sanitizer_common_interceptors.inc 69 sanitizer_common_interceptors_ioctl.inc 70 sanitizer_common_interceptors_format.inc 71 sanitizer_common_syscalls.inc 72 sanitizer_deadlock_detector.h 73 sanitizer_deadlock_detector_interface.h 74 sanitizer_flag_parser.h 75 sanitizer_flags.h 76 sanitizer_flags.inc 77 sanitizer_interface_internal.h 78 sanitizer_internal_defs.h 79 sanitizer_lfstack.h 80 sanitizer_libc.h 81 sanitizer_libignore.h 82 sanitizer_linux.h 83 sanitizer_list.h 84 sanitizer_mac.h 85 sanitizer_mutex.h 86 sanitizer_persistent_allocator.h 87 sanitizer_placement_new.h 88 sanitizer_platform.h 89 sanitizer_platform_interceptors.h 90 sanitizer_platform_limits_posix.h 91 sanitizer_posix.h 92 sanitizer_procmaps.h 93 sanitizer_quarantine.h 94 sanitizer_report_decorator.h 95 sanitizer_stackdepot.h 96 sanitizer_stackdepotbase.h 97 sanitizer_stacktrace.h 98 sanitizer_stacktrace_printer.h 99 sanitizer_stoptheworld.h 100 sanitizer_suppressions.h 101 sanitizer_symbolizer.h 102 sanitizer_symbolizer_internal.h 103 sanitizer_symbolizer_libbacktrace.h 104 sanitizer_symbolizer_mac.h 105 sanitizer_syscall_generic.inc 106 sanitizer_syscall_linux_x86_64.inc 107 sanitizer_syscall_linux_aarch64.inc 108 sanitizer_thread_registry.h) 109 110set(SANITIZER_COMMON_DEFINITIONS) 111 112if(MSVC) 113 list(APPEND SANITIZER_COMMON_DEFINITIONS 114 SANITIZER_NEEDS_SEGV=0) 115else() 116 list(APPEND SANITIZER_COMMON_DEFINITIONS 117 SANITIZER_NEEDS_SEGV=1) 118endif() 119 120include(CheckIncludeFile) 121append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) 122append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) 123 124set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) 125append_no_rtti_flag(SANITIZER_CFLAGS) 126 127append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 128 SANITIZER_CFLAGS) 129append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors 130 SANITIZER_CFLAGS) 131 132if(APPLE) 133 set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS}) 134endif() 135 136add_compiler_rt_object_libraries(RTSanitizerCommon 137 ${OS_OPTION} 138 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 139 SOURCES ${SANITIZER_SOURCES} 140 CFLAGS ${SANITIZER_CFLAGS} 141 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 142add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc 143 ${OS_OPTION} 144 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 145 SOURCES ${SANITIZER_NOLIBC_SOURCES} 146 CFLAGS ${SANITIZER_CFLAGS} 147 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 148add_compiler_rt_object_libraries(RTSanitizerCommonLibc 149 ${OS_OPTION} 150 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 151 SOURCES ${SANITIZER_LIBCDEP_SOURCES} 152 CFLAGS ${SANITIZER_CFLAGS} 153 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 154 155# Unit tests for common sanitizer runtime. 156if(COMPILER_RT_INCLUDE_TESTS) 157 add_subdirectory(tests) 158endif() 159