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 (129 lines) | stat: -rw-r--r-- 3,800 bytes parent folder | download | duplicates (3)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
include_directories(..)

add_custom_target(ScudoUnitTests)
set_target_properties(ScudoUnitTests PROPERTIES
  FOLDER "Compiler-RT Tests")

set(SCUDO_UNITTEST_CFLAGS
  ${COMPILER_RT_UNITTEST_CFLAGS}
  ${COMPILER_RT_GTEST_CFLAGS}
  ${SANITIZER_TEST_CXX_CFLAGS}
  -I${COMPILER_RT_SOURCE_DIR}/include
  -I${COMPILER_RT_SOURCE_DIR}/lib
  -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone
  -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone/include
  -DGTEST_HAS_RTTI=0
  -g
  # Extra flags for the C++ tests
  # TODO(kostyak): find a way to make -fsized-deallocation work
  -Wno-mismatched-new-delete)

if(COMPILER_RT_DEBUG)
  list(APPEND SCUDO_UNITTEST_CFLAGS -DSCUDO_DEBUG=1)
endif()

if(ANDROID)
  list(APPEND SCUDO_UNITTEST_CFLAGS -fno-emulated-tls)
endif()

if (COMPILER_RT_HAS_GWP_ASAN)
  list(APPEND SCUDO_UNITTEST_CFLAGS -DGWP_ASAN_HOOKS -fno-omit-frame-pointer
       -mno-omit-leaf-frame-pointer)
endif()

set(SCUDO_TEST_ARCH ${SCUDO_STANDALONE_SUPPORTED_ARCH})

# gtests requires c++
set(SCUDO_UNITTEST_LINK_FLAGS
  ${COMPILER_RT_UNITTEST_LINK_FLAGS}
  ${COMPILER_RT_UNWINDER_LINK_LIBS}
  ${SANITIZER_TEST_CXX_LIBRARIES})
list(APPEND SCUDO_UNITTEST_LINK_FLAGS -pthread -no-pie)
# Linking against libatomic is required with some compilers
check_library_exists(atomic __atomic_load_8 "" COMPILER_RT_HAS_LIBATOMIC)
if (COMPILER_RT_HAS_LIBATOMIC)
  list(APPEND SCUDO_UNITTEST_LINK_FLAGS -latomic)
endif()

set(SCUDO_TEST_HEADERS
  scudo_unit_test.h
  )
foreach (header ${SCUDO_HEADERS})
  list(APPEND SCUDO_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../${header})
endforeach()

macro(add_scudo_unittest testname)
  cmake_parse_arguments(TEST "" "" "SOURCES;ADDITIONAL_RTOBJECTS" ${ARGN})
  if (COMPILER_RT_HAS_GWP_ASAN)
    list(APPEND TEST_ADDITIONAL_RTOBJECTS
         RTGwpAsan RTGwpAsanBacktraceLibc RTGwpAsanSegvHandler)
  endif()

  if(COMPILER_RT_HAS_SCUDO_STANDALONE)
    foreach(arch ${SCUDO_TEST_ARCH})
      # Additional runtime objects get added along RTScudoStandalone
      set(SCUDO_TEST_RTOBJECTS $<TARGET_OBJECTS:RTScudoStandalone.${arch}>)
      foreach(rtobject ${TEST_ADDITIONAL_RTOBJECTS})
        list(APPEND SCUDO_TEST_RTOBJECTS $<TARGET_OBJECTS:${rtobject}.${arch}>)
      endforeach()
      # Add the static runtime library made of all the runtime objects
      set(RUNTIME RT${testname}.${arch})
      add_library(${RUNTIME} STATIC ${SCUDO_TEST_RTOBJECTS})
      set(ScudoUnitTestsObjects)
      generate_compiler_rt_tests(ScudoUnitTestsObjects ScudoUnitTests
        "${testname}-${arch}-Test" ${arch}
        SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
        COMPILE_DEPS ${SCUDO_TEST_HEADERS}
        DEPS llvm_gtest scudo_standalone
        RUNTIME ${RUNTIME}
        CFLAGS ${SCUDO_UNITTEST_CFLAGS}
        LINK_FLAGS ${SCUDO_UNITTEST_LINK_FLAGS})
    endforeach()
  endif()
endmacro()

set(SCUDO_UNIT_TEST_SOURCES
  atomic_test.cpp
  bytemap_test.cpp
  checksum_test.cpp
  chunk_test.cpp
  combined_test.cpp
  common_test.cpp
  flags_test.cpp
  list_test.cpp
  map_test.cpp
  memtag_test.cpp
  mutex_test.cpp
  primary_test.cpp
  quarantine_test.cpp
  release_test.cpp
  report_test.cpp
  secondary_test.cpp
  size_class_map_test.cpp
  stats_test.cpp
  strings_test.cpp
  tsd_test.cpp
  vector_test.cpp
  scudo_unit_test_main.cpp
  )

add_scudo_unittest(ScudoUnitTest
  SOURCES ${SCUDO_UNIT_TEST_SOURCES})

set(SCUDO_C_UNIT_TEST_SOURCES
  wrappers_c_test.cpp
  scudo_unit_test_main.cpp
  )

add_scudo_unittest(ScudoCUnitTest
  SOURCES ${SCUDO_C_UNIT_TEST_SOURCES}
  ADDITIONAL_RTOBJECTS RTScudoStandaloneCWrappers)

set(SCUDO_CXX_UNIT_TEST_SOURCES
  wrappers_cpp_test.cpp
  scudo_unit_test_main.cpp
  )

add_scudo_unittest(ScudoCxxUnitTest
  SOURCES ${SCUDO_CXX_UNIT_TEST_SOURCES}
  ADDITIONAL_RTOBJECTS RTScudoStandaloneCWrappers RTScudoStandaloneCxxWrappers)