blob: c5315245066e459ef01914e25ef423b8d6f54d21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
add_compiler_rt_component(gwp_asan)
include_directories(..)
set(GWP_ASAN_SOURCES
platform_specific/mutex_posix.cpp
random.cpp
)
set(GWP_ASAN_HEADERS
mutex.h
random.h
options.h
options.inc
)
# Ensure that GWP-ASan meets the delegated requirements of some supporting
# allocators. Some supporting allocators (e.g. scudo standalone) cannot use any
# parts of the C++ standard library.
set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread)
# Remove -stdlib= which is unused when passing -nostdinc++.
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Options parsing support is optional. GwpAsan is totally independent of
# sanitizer_common, the options parser is not. This is an optional library
# that can be used by an allocator to automatically parse GwpAsan options from
# the environment variable GWP_ASAN_FLAGS, but the allocator can choose to
# implement its own options parsing and populate the Options struct itself.
set(GWP_ASAN_OPTIONS_PARSER_SOURCES
optional/options_parser.cpp
)
set(GWP_ASAN_OPTIONS_PARSER_HEADERS
optional/options_parser.h
options.h
options.inc
)
set(GWP_ASAN_OPTIONS_PARSER_CFLAGS
${GWP_ASAN_CFLAGS}
${SANITIZER_COMMON_CFLAGS})
set(GWP_ASAN_OPTIONS_PARSER_OBJECT_LIBS
RTSanitizerCommon
RTSanitizerCommonNoLibc)
if (COMPILER_RT_HAS_GWP_ASAN)
foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
add_compiler_rt_runtime(
clang_rt.gwp_asan
STATIC
ARCHS ${arch}
SOURCES ${GWP_ASAN_SOURCES}
ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
CFLAGS ${GWP_ASAN_CFLAGS}
PARENT_TARGET gwp_asan
)
endforeach()
add_compiler_rt_object_libraries(RTGwpAsan
ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
SOURCES ${GWP_ASAN_SOURCES}
ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}
CFLAGS ${GWP_ASAN_CFLAGS})
# Note: If you choose to add this as an object library, ensure you also
# include the sanitizer_common flag parsing object lib (generally
# 'RTSanitizerCommonNoTermination').
add_compiler_rt_object_libraries(RTGwpAsanOptionsParser
ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES}
ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS}
CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS})
# Ensure that the build for the options parser succeeds, as
# 'RTGwpAsanOptionsParser' may not be built if it's not needed. This library
# has only a very small amount of logic, all of the testable components are
# exercised in the sanitizer_common test suite.
foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
add_compiler_rt_runtime(
clang_rt.gwp_asan_options_parser
STATIC
ARCHS ${arch}
SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES}
ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS}
CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS}
OBJECT_LIBS ${GWP_ASAN_OPTIONS_PARSER_OBJECT_LIBS}
PARENT_TARGET gwp_asan
)
endforeach()
endif()
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
endif()
|