[clang] Handle __declspec() attributes in using
[llvm-project.git] / compiler-rt / lib / gwp_asan / CMakeLists.txt
blobbb5b2902f99dbf9b1909253c57b3819b78d532b3
1 add_compiler_rt_component(gwp_asan)
3 include_directories(..)
5 set(GWP_ASAN_SOURCES
6   common.cpp
7   crash_handler.cpp
8   platform_specific/common_posix.cpp
9   platform_specific/guarded_pool_allocator_posix.cpp
10   platform_specific/mutex_posix.cpp
11   platform_specific/utilities_posix.cpp
12   guarded_pool_allocator.cpp
13   stack_trace_compressor.cpp
16 set(GWP_ASAN_HEADERS
17   common.h
18   crash_handler.h
19   definitions.h
20   guarded_pool_allocator.h
21   mutex.h
22   options.h
23   options.inc
24   platform_specific/guarded_pool_allocator_fuchsia.h
25   platform_specific/guarded_pool_allocator_posix.h
26   platform_specific/guarded_pool_allocator_tls.h
27   platform_specific/mutex_fuchsia.h
28   platform_specific/mutex_posix.h
29   stack_trace_compressor.h
30   utilities.h
33 # Ensure that GWP-ASan meets the delegated requirements of some supporting
34 # allocators. Some supporting allocators (e.g. scudo standalone) cannot use any
35 # parts of the C++ standard library.
36 set(GWP_ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS} -fno-rtti -fno-exceptions
37     -nostdinc++ -pthread -fno-omit-frame-pointer)
38 append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS)
39 # append_list_if(COMPILER_RT_HAS_SANITIZER_COMMON ${SANITIZER_COMMON_CFLAGS} GWP_ASAN_CFLAGS)
41 # Remove -stdlib= which is unused when passing -nostdinc++.
42 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
44 # Options parsing support is optional. This is an optional library that can be
45 # used by an allocator to automatically parse GwpAsan options from the
46 # environment variable GWP_ASAN_FLAGS, but the allocator can choose to implement
47 # its own options parsing and populate the Options struct itself.
48 set(GWP_ASAN_OPTIONS_PARSER_SOURCES
49   optional/options_parser.cpp
51 set(GWP_ASAN_OPTIONS_PARSER_HEADERS
52   optional/options_parser.h
53   options.h
54   options.inc
56 set(GWP_ASAN_BACKTRACE_HEADERS
57   optional/backtrace.h
58   options.h
59   options.inc
61 set(GWP_ASAN_SEGV_HANDLER_HEADERS
62   optional/segv_handler.h
63   options.h)
65 set(GWP_ASAN_OPTIONS_PARSER_CFLAGS
66     ${GWP_ASAN_CFLAGS})
68 if (COMPILER_RT_HAS_GWP_ASAN)
69   foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
70     add_compiler_rt_runtime(
71       clang_rt.gwp_asan
72       STATIC
73       ARCHS ${arch}
74       SOURCES ${GWP_ASAN_SOURCES}
75       ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
76       CFLAGS ${GWP_ASAN_CFLAGS}
77       PARENT_TARGET gwp_asan
78     )
79   endforeach()
81   add_compiler_rt_object_libraries(RTGwpAsan
82       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
83       SOURCES ${GWP_ASAN_SOURCES}
84       ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
85       CFLAGS ${GWP_ASAN_CFLAGS})
87   add_compiler_rt_object_libraries(RTGwpAsanOptionsParser
88       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
89       SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES}
90       ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS}
91       CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS})
93   # As above, build the pre-implemented optional backtrace support libraries.
94   add_compiler_rt_object_libraries(RTGwpAsanBacktraceLibc
95       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
96       SOURCES optional/backtrace_linux_libc.cpp
97       ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
98       CFLAGS ${GWP_ASAN_CFLAGS})
99   add_compiler_rt_object_libraries(RTGwpAsanSegvHandler
100       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
101       SOURCES optional/segv_handler_posix.cpp
102       ADDITIONAL_HEADERS ${GWP_ASAN_SEGV_HANDLER_HEADERS}
103       CFLAGS ${GWP_ASAN_CFLAGS})
104   add_compiler_rt_object_libraries(RTGwpAsanBacktraceSanitizerCommon
105       ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
106       SOURCES optional/backtrace_sanitizer_common.cpp
107       ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
108       CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})
109 endif()
111 if(COMPILER_RT_INCLUDE_TESTS)
112   add_subdirectory(tests)
113 endif()