112 lines · plain
1add_compiler_rt_component(gwp_asan)2 3include_directories(..)4 5set(GWP_ASAN_SOURCES6 common.cpp7 crash_handler.cpp8 platform_specific/common_posix.cpp9 platform_specific/guarded_pool_allocator_posix.cpp10 platform_specific/mutex_posix.cpp11 platform_specific/utilities_posix.cpp12 guarded_pool_allocator.cpp13 stack_trace_compressor.cpp14)15 16set(GWP_ASAN_HEADERS17 common.h18 crash_handler.h19 definitions.h20 guarded_pool_allocator.h21 mutex.h22 options.h23 options.inc24 platform_specific/guarded_pool_allocator_fuchsia.h25 platform_specific/guarded_pool_allocator_posix.h26 platform_specific/guarded_pool_allocator_tls.h27 platform_specific/mutex_fuchsia.h28 platform_specific/mutex_posix.h29 stack_trace_compressor.h30 utilities.h31)32 33# Ensure that GWP-ASan meets the delegated requirements of some supporting34# allocators. Some supporting allocators (e.g. scudo standalone) cannot use any35# parts of the C++ standard library.36set(GWP_ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS} -fno-rtti -fno-exceptions37 -nostdinc++ -pthread -fno-omit-frame-pointer)38append_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)40 41# Remove -stdlib= which is unused when passing -nostdinc++.42string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")43 44# Options parsing support is optional. This is an optional library that can be45# used by an allocator to automatically parse GwpAsan options from the46# environment variable GWP_ASAN_FLAGS, but the allocator can choose to implement47# its own options parsing and populate the Options struct itself.48set(GWP_ASAN_OPTIONS_PARSER_SOURCES49 optional/options_parser.cpp50)51set(GWP_ASAN_OPTIONS_PARSER_HEADERS52 optional/options_parser.h53 options.h54 options.inc55)56set(GWP_ASAN_BACKTRACE_HEADERS57 optional/backtrace.h58 options.h59 options.inc60)61set(GWP_ASAN_SEGV_HANDLER_HEADERS62 optional/segv_handler.h63 options.h)64 65set(GWP_ASAN_OPTIONS_PARSER_CFLAGS66 ${GWP_ASAN_CFLAGS})67 68foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})69 add_compiler_rt_runtime(70 clang_rt.gwp_asan71 STATIC72 ARCHS ${arch}73 SOURCES ${GWP_ASAN_SOURCES}74 ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}75 CFLAGS ${GWP_ASAN_CFLAGS}76 PARENT_TARGET gwp_asan77 )78endforeach()79 80add_compiler_rt_object_libraries(RTGwpAsan81 ARCHS ${GWP_ASAN_SUPPORTED_ARCH}82 SOURCES ${GWP_ASAN_SOURCES}83 ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS}84 CFLAGS ${GWP_ASAN_CFLAGS})85 86add_compiler_rt_object_libraries(RTGwpAsanOptionsParser87 ARCHS ${GWP_ASAN_SUPPORTED_ARCH}88 SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES}89 ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS}90 CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS})91 92# As above, build the pre-implemented optional backtrace support libraries.93add_compiler_rt_object_libraries(RTGwpAsanBacktraceLibc94 ARCHS ${GWP_ASAN_SUPPORTED_ARCH}95 SOURCES optional/backtrace_linux_libc.cpp96 ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}97 CFLAGS ${GWP_ASAN_CFLAGS})98add_compiler_rt_object_libraries(RTGwpAsanSegvHandler99 ARCHS ${GWP_ASAN_SUPPORTED_ARCH}100 SOURCES optional/segv_handler_posix.cpp101 ADDITIONAL_HEADERS ${GWP_ASAN_SEGV_HANDLER_HEADERS}102 CFLAGS ${GWP_ASAN_CFLAGS})103add_compiler_rt_object_libraries(RTGwpAsanBacktraceSanitizerCommon104 ARCHS ${GWP_ASAN_SUPPORTED_ARCH}105 SOURCES optional/backtrace_sanitizer_common.cpp106 ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}107 CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})108 109if(COMPILER_RT_INCLUDE_TESTS)110 add_subdirectory(tests)111endif()112