File: CMakeLists.txt

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (113 lines) | stat: -rw-r--r-- 3,696 bytes parent folder | download | duplicates (9)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
add_compiler_rt_component(gwp_asan)

include_directories(..)

set(GWP_ASAN_SOURCES
  common.cpp
  crash_handler.cpp
  platform_specific/common_posix.cpp
  platform_specific/guarded_pool_allocator_posix.cpp
  platform_specific/mutex_posix.cpp
  platform_specific/utilities_posix.cpp
  guarded_pool_allocator.cpp
  stack_trace_compressor.cpp
)

set(GWP_ASAN_HEADERS
  common.h
  crash_handler.h
  definitions.h
  guarded_pool_allocator.h
  mutex.h
  options.h
  options.inc
  platform_specific/guarded_pool_allocator_fuchsia.h
  platform_specific/guarded_pool_allocator_posix.h
  platform_specific/guarded_pool_allocator_tls.h
  platform_specific/mutex_fuchsia.h
  platform_specific/mutex_posix.h
  stack_trace_compressor.h
  utilities.h
)

# 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 ${SANITIZER_COMMON_CFLAGS} -fno-rtti -fno-exceptions
    -nostdinc++ -pthread -fno-omit-frame-pointer)
append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS)
# append_list_if(COMPILER_RT_HAS_SANITIZER_COMMON ${SANITIZER_COMMON_CFLAGS} GWP_ASAN_CFLAGS)

# 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. 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_BACKTRACE_HEADERS
  optional/backtrace.h
  options.h
  options.inc
)
set(GWP_ASAN_SEGV_HANDLER_HEADERS
  optional/segv_handler.h
  options.h)

set(GWP_ASAN_OPTIONS_PARSER_CFLAGS
    ${GWP_ASAN_CFLAGS})

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})

  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})

  # As above, build the pre-implemented optional backtrace support libraries.
  add_compiler_rt_object_libraries(RTGwpAsanBacktraceLibc
      ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
      SOURCES optional/backtrace_linux_libc.cpp
      ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
      CFLAGS ${GWP_ASAN_CFLAGS})
  add_compiler_rt_object_libraries(RTGwpAsanSegvHandler
      ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
      SOURCES optional/segv_handler_posix.cpp
      ADDITIONAL_HEADERS ${GWP_ASAN_SEGV_HANDLER_HEADERS}
      CFLAGS ${GWP_ASAN_CFLAGS})
  add_compiler_rt_object_libraries(RTGwpAsanBacktraceSanitizerCommon
      ARCHS ${GWP_ASAN_SUPPORTED_ARCH}
      SOURCES optional/backtrace_sanitizer_common.cpp
      ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS}
      CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS})
endif()

if(COMPILER_RT_INCLUDE_TESTS)
  add_subdirectory(tests)
endif()