Chandler Carruth | 479d47f | 2012-06-20 10:18:43 +0000 | [diff] [blame] | 1 | # Build system for the common Sanitizer runtime support library components. |
| 2 | # These components are shared between AddressSanitizer and ThreadSanitizer. |
| 3 | |
| 4 | set(SANITIZER_SOURCES |
| 5 | sanitizer_allocator.cc |
| 6 | sanitizer_common.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | sanitizer_deadlock_detector1.cc |
| 8 | sanitizer_deadlock_detector2.cc |
Alexey Samsonov | 9b1b101 | 2012-07-10 09:17:06 +0000 | [diff] [blame] | 9 | sanitizer_flags.cc |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 10 | sanitizer_flag_parser.cc |
Chandler Carruth | 479d47f | 2012-06-20 10:18:43 +0000 | [diff] [blame] | 11 | sanitizer_libc.cc |
Dmitry Vyukov | 4af0f21 | 2013-10-03 13:37:17 +0000 | [diff] [blame] | 12 | sanitizer_libignore.cc |
Chandler Carruth | 479d47f | 2012-06-20 10:18:43 +0000 | [diff] [blame] | 13 | sanitizer_linux.cc |
| 14 | sanitizer_mac.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 15 | sanitizer_persistent_allocator.cc |
Evgeniy Stepanov | 639df40 | 2013-09-06 14:20:01 +0000 | [diff] [blame] | 16 | sanitizer_platform_limits_linux.cc |
Evgeniy Stepanov | 9358c58 | 2013-02-19 09:19:16 +0000 | [diff] [blame] | 17 | sanitizer_platform_limits_posix.cc |
Chandler Carruth | 479d47f | 2012-06-20 10:18:43 +0000 | [diff] [blame] | 18 | sanitizer_posix.cc |
| 19 | sanitizer_printf.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 20 | sanitizer_procmaps_common.cc |
| 21 | sanitizer_procmaps_freebsd.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 22 | sanitizer_procmaps_linux.cc |
| 23 | sanitizer_procmaps_mac.cc |
Alexey Samsonov | 3f3ca96 | 2012-09-11 10:50:32 +0000 | [diff] [blame] | 24 | sanitizer_stackdepot.cc |
Kostya Serebryany | 1b5ea8f | 2012-08-28 14:11:57 +0000 | [diff] [blame] | 25 | sanitizer_stacktrace.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 26 | sanitizer_stacktrace_printer.cc |
Sergey Matveev | a52e5c6 | 2013-06-26 15:37:14 +0000 | [diff] [blame] | 27 | sanitizer_suppressions.cc |
Peter Collingbourne | c1a1ed6 | 2013-10-25 23:03:29 +0000 | [diff] [blame] | 28 | sanitizer_symbolizer.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 29 | sanitizer_symbolizer_libbacktrace.cc |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 30 | sanitizer_symbolizer_mac.cc |
Alexey Samsonov | 6e893b6 | 2012-08-14 13:00:32 +0000 | [diff] [blame] | 31 | sanitizer_symbolizer_win.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 32 | sanitizer_tls_get_addr.cc |
Alexey Samsonov | 6d429cd | 2013-03-14 13:54:30 +0000 | [diff] [blame] | 33 | sanitizer_thread_registry.cc |
Alexey Samsonov | d64bcf4 | 2013-06-11 08:13:36 +0000 | [diff] [blame] | 34 | sanitizer_win.cc) |
Chandler Carruth | 479d47f | 2012-06-20 10:18:43 +0000 | [diff] [blame] | 35 | |
Peter Collingbourne | 0c547de | 2013-05-17 16:17:19 +0000 | [diff] [blame] | 36 | set(SANITIZER_LIBCDEP_SOURCES |
| 37 | sanitizer_common_libcdep.cc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 38 | sanitizer_coverage_libcdep.cc |
| 39 | sanitizer_coverage_mapping_libcdep.cc |
Peter Collingbourne | 088ea2b | 2013-05-20 15:57:44 +0000 | [diff] [blame] | 40 | sanitizer_linux_libcdep.cc |
Peter Collingbourne | 04a2281 | 2013-05-21 10:27:07 +0000 | [diff] [blame] | 41 | sanitizer_posix_libcdep.cc |
Alexey Samsonov | e74968c | 2013-11-07 06:33:06 +0000 | [diff] [blame] | 42 | sanitizer_stacktrace_libcdep.cc |
Peter Collingbourne | 705e310 | 2013-05-21 11:38:39 +0000 | [diff] [blame] | 43 | sanitizer_stoptheworld_linux_libcdep.cc |
Peter Collingbourne | c1a1ed6 | 2013-10-25 23:03:29 +0000 | [diff] [blame] | 44 | sanitizer_symbolizer_libcdep.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 45 | sanitizer_symbolizer_posix_libcdep.cc |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 46 | sanitizer_symbolizer_process_libcdep.cc |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 47 | sanitizer_unwind_posix_libcdep.cc) |
Peter Collingbourne | 0c547de | 2013-05-17 16:17:19 +0000 | [diff] [blame] | 48 | |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 49 | # Explicitly list all sanitizer_common headers. Not all of these are |
| 50 | # included in sanitizer_common source files, but we need to depend on |
| 51 | # headers when building our custom unit tests. |
| 52 | set(SANITIZER_HEADERS |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 53 | sanitizer_addrhashmap.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 54 | sanitizer_allocator.h |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 55 | sanitizer_allocator_interface.h |
Alexey Samsonov | 1f3c2fe | 2013-05-29 09:15:39 +0000 | [diff] [blame] | 56 | sanitizer_allocator_internal.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 57 | sanitizer_atomic.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 58 | sanitizer_atomic_clang.h |
| 59 | sanitizer_atomic_msvc.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 60 | sanitizer_bitvector.h |
| 61 | sanitizer_bvgraph.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 62 | sanitizer_common.h |
Evgeniy Stepanov | 4f32c0b | 2013-01-18 13:01:18 +0000 | [diff] [blame] | 63 | sanitizer_common_interceptors.inc |
Evgeniy Stepanov | 4612aba | 2013-06-20 09:19:28 +0000 | [diff] [blame] | 64 | sanitizer_common_interceptors_ioctl.inc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 65 | sanitizer_common_interceptors_format.inc |
Evgeniy Stepanov | 2887a64 | 2013-04-11 14:37:04 +0000 | [diff] [blame] | 66 | sanitizer_common_syscalls.inc |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 67 | sanitizer_deadlock_detector.h |
| 68 | sanitizer_deadlock_detector_interface.h |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 69 | sanitizer_flag_parser.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 70 | sanitizer_flags.h |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 71 | sanitizer_flags.inc |
| 72 | sanitizer_interface_internal.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 73 | sanitizer_internal_defs.h |
Dmitry Vyukov | b48224c | 2013-01-14 08:23:34 +0000 | [diff] [blame] | 74 | sanitizer_lfstack.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 75 | sanitizer_libc.h |
Dmitry Vyukov | 4af0f21 | 2013-10-03 13:37:17 +0000 | [diff] [blame] | 76 | sanitizer_libignore.h |
Kostya Serebryany | 6fb47af | 2013-02-27 11:22:40 +0000 | [diff] [blame] | 77 | sanitizer_linux.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 78 | sanitizer_list.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 79 | sanitizer_mac.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 80 | sanitizer_mutex.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 81 | sanitizer_persistent_allocator.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 82 | sanitizer_placement_new.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 83 | sanitizer_platform.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 84 | sanitizer_platform_interceptors.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 85 | sanitizer_platform_limits_posix.h |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame] | 86 | sanitizer_posix.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 87 | sanitizer_procmaps.h |
Dmitry Vyukov | 9fc0df8 | 2013-01-11 08:07:43 +0000 | [diff] [blame] | 88 | sanitizer_quarantine.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 89 | sanitizer_report_decorator.h |
| 90 | sanitizer_stackdepot.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 91 | sanitizer_stackdepotbase.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 92 | sanitizer_stacktrace.h |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 93 | sanitizer_stacktrace_printer.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 94 | sanitizer_stoptheworld.h |
| 95 | sanitizer_suppressions.h |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 96 | sanitizer_symbolizer.h |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 97 | sanitizer_symbolizer_internal.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 98 | sanitizer_symbolizer_libbacktrace.h |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 99 | sanitizer_symbolizer_mac.h |
| 100 | sanitizer_symbolizer_win.h |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 101 | sanitizer_syscall_generic.inc |
| 102 | sanitizer_syscall_linux_x86_64.inc |
Alexey Samsonov | d64bcf4 | 2013-06-11 08:13:36 +0000 | [diff] [blame] | 103 | sanitizer_thread_registry.h) |
Alexey Samsonov | 032e833 | 2012-12-21 14:04:52 +0000 | [diff] [blame] | 104 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 105 | set(SANITIZER_COMMON_DEFINITIONS) |
| 106 | |
| 107 | if(MSVC) |
| 108 | list(APPEND SANITIZER_COMMON_DEFINITIONS |
| 109 | SANITIZER_NEEDS_SEGV=0) |
Hans Wennborg | c1f1af7 | 2013-08-27 01:24:01 +0000 | [diff] [blame] | 110 | else() |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 111 | list(APPEND SANITIZER_COMMON_DEFINITIONS |
| 112 | SANITIZER_NEEDS_SEGV=1) |
Hans Wennborg | c1f1af7 | 2013-08-27 01:24:01 +0000 | [diff] [blame] | 113 | endif() |
Chandler Carruth | a765ffc | 2012-06-25 08:40:10 +0000 | [diff] [blame] | 114 | |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame] | 115 | include(CheckIncludeFile) |
| 116 | append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) |
| 117 | append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) |
| 118 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 119 | set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) |
| 120 | append_no_rtti_flag(SANITIZER_CFLAGS) |
Alexey Samsonov | 7a3d5fe | 2013-09-11 09:57:15 +0000 | [diff] [blame] | 121 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 122 | append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 123 | SANITIZER_CFLAGS) |
| 124 | append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors |
| 125 | SANITIZER_CFLAGS) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 126 | |
| 127 | add_custom_target(sanitizer_common) |
Alexey Samsonov | 0b56247 | 2012-08-13 07:41:43 +0000 | [diff] [blame] | 128 | set(SANITIZER_RUNTIME_LIBRARIES) |
Alexey Samsonov | fe51abb | 2012-08-10 14:45:52 +0000 | [diff] [blame] | 129 | if(APPLE) |
| 130 | # Build universal binary on APPLE. |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 131 | |
| 132 | add_compiler_rt_object_libraries(RTSanitizerCommon |
| 133 | OS ${SANITIZER_COMMON_SUPPORTED_OS} |
| 134 | ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH} |
| 135 | SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES} |
| 136 | CFLAGS ${SANITIZER_CFLAGS} |
| 137 | DEFS ${SANITIZER_COMMON_DEFINITIONS}) |
| 138 | foreach(os ${SANITIZER_COMMON_SUPPORTED_OS}) |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 139 | list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${os}) |
| 140 | endforeach() |
Alexey Samsonov | fe51abb | 2012-08-10 14:45:52 +0000 | [diff] [blame] | 141 | else() |
| 142 | # Otherwise, build separate libraries for each target. |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 143 | |
| 144 | add_compiler_rt_object_libraries(RTSanitizerCommon |
| 145 | ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH} |
| 146 | SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS} |
| 147 | DEFS ${SANITIZER_COMMON_DEFINITIONS}) |
| 148 | add_compiler_rt_object_libraries(RTSanitizerCommonLibc |
| 149 | ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH} |
| 150 | SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS} |
| 151 | DEFS ${SANITIZER_COMMON_DEFINITIONS}) |
Alexey Samsonov | 43b4b9c | 2013-01-18 16:51:07 +0000 | [diff] [blame] | 152 | foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH}) |
Alexey Samsonov | 7bb2f9b | 2013-09-16 15:43:23 +0000 | [diff] [blame] | 153 | list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch} |
| 154 | RTSanitizerCommonLibc.${arch}) |
Alexey Samsonov | 43b4b9c | 2013-01-18 16:51:07 +0000 | [diff] [blame] | 155 | endforeach() |
Alexey Samsonov | fe51abb | 2012-08-10 14:45:52 +0000 | [diff] [blame] | 156 | endif() |
Alexey Samsonov | 8fc90f6 | 2012-08-08 09:46:51 +0000 | [diff] [blame] | 157 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 158 | add_dependencies(compiler-rt sanitizer_common) |
| 159 | |
Alexey Samsonov | 3f3ca96 | 2012-09-11 10:50:32 +0000 | [diff] [blame] | 160 | # Unit tests for common sanitizer runtime. |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 161 | if(COMPILER_RT_INCLUDE_TESTS) |
Alexey Samsonov | 3f3ca96 | 2012-09-11 10:50:32 +0000 | [diff] [blame] | 162 | add_subdirectory(tests) |
| 163 | endif() |