1# Build system for the common Sanitizer runtime support library components. 2# These components are shared between AddressSanitizer and ThreadSanitizer. 3 4set(SANITIZER_SOURCES_NOTERMINATION 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_linux_s390.cc 15 sanitizer_mac.cc 16 sanitizer_persistent_allocator.cc 17 sanitizer_platform_limits_linux.cc 18 sanitizer_platform_limits_posix.cc 19 sanitizer_posix.cc 20 sanitizer_printf.cc 21 sanitizer_procmaps_common.cc 22 sanitizer_procmaps_freebsd.cc 23 sanitizer_procmaps_linux.cc 24 sanitizer_procmaps_mac.cc 25 sanitizer_stackdepot.cc 26 sanitizer_stacktrace.cc 27 sanitizer_stacktrace_printer.cc 28 sanitizer_suppressions.cc 29 sanitizer_symbolizer.cc 30 sanitizer_symbolizer_libbacktrace.cc 31 sanitizer_symbolizer_mac.cc 32 sanitizer_symbolizer_win.cc 33 sanitizer_tls_get_addr.cc 34 sanitizer_thread_registry.cc 35 sanitizer_win.cc) 36 37if(UNIX AND NOT APPLE) 38 list(APPEND SANITIZER_SOURCES_NOTERMINATION 39 sanitizer_linux_x86_64.S) 40endif() 41 42set(SANITIZER_SOURCES 43 ${SANITIZER_SOURCES_NOTERMINATION} sanitizer_termination.cc) 44 45# Libc functions stubs. These sources should be linked instead of 46# SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on 47# libc. 48set(SANITIZER_NOLIBC_SOURCES 49 sanitizer_common_nolibc.cc) 50 51set(SANITIZER_LIBCDEP_SOURCES 52 sanitizer_common_libcdep.cc 53 sanitizer_coverage_libcdep.cc 54 sanitizer_coverage_mapping_libcdep.cc 55 sanitizer_linux_libcdep.cc 56 sanitizer_posix_libcdep.cc 57 sanitizer_stacktrace_libcdep.cc 58 sanitizer_stoptheworld_linux_libcdep.cc 59 sanitizer_symbolizer_libcdep.cc 60 sanitizer_symbolizer_posix_libcdep.cc 61 sanitizer_unwind_linux_libcdep.cc) 62 63# Explicitly list all sanitizer_common headers. Not all of these are 64# included in sanitizer_common source files, but we need to depend on 65# headers when building our custom unit tests. 66set(SANITIZER_HEADERS 67 sanitizer_addrhashmap.h 68 sanitizer_allocator.h 69 sanitizer_allocator_interface.h 70 sanitizer_allocator_internal.h 71 sanitizer_atomic.h 72 sanitizer_atomic_clang.h 73 sanitizer_atomic_msvc.h 74 sanitizer_bitvector.h 75 sanitizer_bvgraph.h 76 sanitizer_common.h 77 sanitizer_common_interceptors.inc 78 sanitizer_common_interceptors_ioctl.inc 79 sanitizer_common_interceptors_format.inc 80 sanitizer_common_syscalls.inc 81 sanitizer_deadlock_detector.h 82 sanitizer_deadlock_detector_interface.h 83 sanitizer_flag_parser.h 84 sanitizer_flags.h 85 sanitizer_flags.inc 86 sanitizer_interface_internal.h 87 sanitizer_internal_defs.h 88 sanitizer_lfstack.h 89 sanitizer_libc.h 90 sanitizer_libignore.h 91 sanitizer_linux.h 92 sanitizer_list.h 93 sanitizer_mac.h 94 sanitizer_mutex.h 95 sanitizer_persistent_allocator.h 96 sanitizer_placement_new.h 97 sanitizer_platform.h 98 sanitizer_platform_interceptors.h 99 sanitizer_platform_limits_posix.h 100 sanitizer_posix.h 101 sanitizer_procmaps.h 102 sanitizer_quarantine.h 103 sanitizer_report_decorator.h 104 sanitizer_stackdepot.h 105 sanitizer_stackdepotbase.h 106 sanitizer_stacktrace.h 107 sanitizer_stacktrace_printer.h 108 sanitizer_stoptheworld.h 109 sanitizer_suppressions.h 110 sanitizer_symbolizer.h 111 sanitizer_symbolizer_internal.h 112 sanitizer_symbolizer_libbacktrace.h 113 sanitizer_symbolizer_mac.h 114 sanitizer_syscall_generic.inc 115 sanitizer_syscall_linux_x86_64.inc 116 sanitizer_syscall_linux_aarch64.inc 117 sanitizer_thread_registry.h) 118 119set(SANITIZER_COMMON_DEFINITIONS) 120 121if(MSVC) 122 list(APPEND SANITIZER_COMMON_DEFINITIONS 123 SANITIZER_NEEDS_SEGV=0) 124else() 125 list(APPEND SANITIZER_COMMON_DEFINITIONS 126 SANITIZER_NEEDS_SEGV=1) 127endif() 128 129include(CheckIncludeFile) 130append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) 131append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) 132 133set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) 134append_rtti_flag(OFF SANITIZER_CFLAGS) 135 136append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 137 SANITIZER_CFLAGS) 138append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors 139 SANITIZER_CFLAGS) 140 141if (LLVM_ENABLE_PEDANTIC AND UNIX AND NOT APPLE) 142 # With -pedantic, our .S files raise warnings about empty macro arguments 143 # from __USER_LABEL_PREFIX__ being an empty arg to GLUE(). Unfortunately, 144 # there is no simple way to test for an empty define, nor to disable just 145 # that warning or to disable -pedantic. There is also no simple way to 146 # remove -pedantic from just this file (we'd have to remove from 147 # CMAKE_C*_FLAGS and re-add as a source property to all the non-.S files). 148 set_source_files_properties(sanitizer_linux_x86_64.S 149 PROPERTIES COMPILE_FLAGS "-w") 150endif () 151 152if(APPLE) 153 set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS}) 154endif() 155 156add_compiler_rt_object_libraries(RTSanitizerCommon 157 ${OS_OPTION} 158 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 159 SOURCES ${SANITIZER_SOURCES} 160 CFLAGS ${SANITIZER_CFLAGS} 161 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 162add_compiler_rt_object_libraries(RTSanitizerCommonNoTermination 163 ${OS_OPTION} 164 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 165 SOURCES ${SANITIZER_SOURCES_NOTERMINATION} 166 CFLAGS ${SANITIZER_CFLAGS} 167 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 168add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc 169 ${OS_OPTION} 170 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 171 SOURCES ${SANITIZER_NOLIBC_SOURCES} 172 CFLAGS ${SANITIZER_CFLAGS} 173 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 174add_compiler_rt_object_libraries(RTSanitizerCommonLibc 175 ${OS_OPTION} 176 ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH} 177 SOURCES ${SANITIZER_LIBCDEP_SOURCES} 178 CFLAGS ${SANITIZER_CFLAGS} 179 DEFS ${SANITIZER_COMMON_DEFINITIONS}) 180 181# Unit tests for common sanitizer runtime. 182if(COMPILER_RT_INCLUDE_TESTS) 183 add_subdirectory(tests) 184endif() 185