diff options
author | Mitch Phillips <mitchphillips@outlook.com> | 2019-06-04 17:01:11 +0000 |
---|---|---|
committer | Mitch Phillips <mitchphillips@outlook.com> | 2019-06-04 17:01:11 +0000 |
commit | b85ba80b0dd2863792b32a6230279297cda84bfd (patch) | |
tree | 7bdc2e56e30ac2c45e3032fe5c709410e98958eb /lib/gwp_asan/CMakeLists.txt | |
parent | f1468283045d8c825e45d861b68a1cb01ab7676f (diff) | |
download | compiler-rt-b85ba80b0dd2863792b32a6230279297cda84bfd.tar.gz |
[GWP-ASan] Configuration options [3].
Summary:
See D60593 for further information.
This patch introduces the configuration options for GWP-ASan. In general, we expect the supporting allocator to populate the options struct, and give that to GWP-ASan during initialisation. For allocators that are okay with pulling in sanitizer_common, we also provide an optional parser that populates the gwp_asan::Options struct with values provided in the GWP_ASAN_OPTIONS environment variable.
This patch contains very little logic, and all of the testable components (i.e. the optional parser's internal logic) is tested as part of the sanitizer_common testbed.
Reviewers: vlad.tsyrklevich, morehouse, jfb
Reviewed By: morehouse
Subscribers: dexonsmith, kubamracek, mgorny, #sanitizers, llvm-commits, vitalybuka
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D62698
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@362527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/gwp_asan/CMakeLists.txt')
-rw-r--r-- | lib/gwp_asan/CMakeLists.txt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/gwp_asan/CMakeLists.txt b/lib/gwp_asan/CMakeLists.txt index 6c83d86c6..771192f23 100644 --- a/lib/gwp_asan/CMakeLists.txt +++ b/lib/gwp_asan/CMakeLists.txt @@ -10,6 +10,8 @@ set(GWP_ASAN_SOURCES set(GWP_ASAN_HEADERS mutex.h random.h + options.h + options.inc ) # Ensure that GWP-ASan meets the delegated requirements of some supporting @@ -20,6 +22,26 @@ 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( @@ -38,6 +60,32 @@ if (COMPILER_RT_HAS_GWP_ASAN) 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 + SHARED + 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) |