Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / gwp_asan / tests / CMakeLists.txt
blob4915c83d49ca9e31416d3f7d2e5f3d5e089aee0c
1 include(CompilerRTCompile)
3 set(GWP_ASAN_UNITTEST_CFLAGS
4   ${COMPILER_RT_UNITTEST_CFLAGS}
5   ${COMPILER_RT_GTEST_CFLAGS}
6   ${SANITIZER_TEST_CXX_CFLAGS}
7   -std=c++17
8   -I${COMPILER_RT_SOURCE_DIR}/lib/
9   -O2
10   -g
11   -fno-omit-frame-pointer)
13 file(GLOB GWP_ASAN_HEADERS ../*.h)
14 set(GWP_ASAN_UNITTESTS
15   platform_specific/printf_sanitizer_common.cpp
16   alignment.cpp
17   backtrace.cpp
18   basic.cpp
19   compression.cpp
20   iterate.cpp
21   crash_handler_api.cpp
22   driver.cpp
23   mutex_test.cpp
24   slot_reuse.cpp
25   thread_contention.cpp
26   harness.cpp
27   enable_disable.cpp
28   late_init.cpp
29   options.cpp
30   recoverable.cpp
31   never_allocated.cpp)
33 set(GWP_ASAN_UNIT_TEST_HEADERS
34   ${GWP_ASAN_HEADERS}
35   harness.h)
37 add_custom_target(GwpAsanUnitTests)
38 set_target_properties(GwpAsanUnitTests PROPERTIES FOLDER "Compiler-RT Tests")
40 set(GWP_ASAN_UNITTEST_LINK_FLAGS
41   ${COMPILER_RT_UNITTEST_LINK_FLAGS} -ldl
42   ${COMPILER_RT_UNWINDER_LINK_LIBS}
43   ${SANITIZER_TEST_CXX_LIBRARIES})
44 list(APPEND GWP_ASAN_UNITTEST_LINK_FLAGS --driver-mode=g++)
45 if(NOT WIN32)
46   list(APPEND GWP_ASAN_UNITTEST_LINK_FLAGS -pthread)
47 endif()
49 if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST GWP_ASAN_SUPPORTED_ARCH)
50   # GWP-ASan unit tests are only run on the host machine.
51   set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})
53   set(GWP_ASAN_TEST_RUNTIME RTGwpAsanTest.${arch})
55   set(GWP_ASAN_TEST_RUNTIME_OBJECTS
56     $<TARGET_OBJECTS:RTGwpAsan.${arch}>
57     $<TARGET_OBJECTS:RTGwpAsanBacktraceSanitizerCommon.${arch}>
58     $<TARGET_OBJECTS:RTGwpAsanSegvHandler.${arch}>
59     $<TARGET_OBJECTS:RTGwpAsanOptionsParser.${arch}>
60     $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
61     $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
62     $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
63     $<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.${arch}>)
65   add_library(${GWP_ASAN_TEST_RUNTIME} STATIC
66     ${GWP_ASAN_TEST_RUNTIME_OBJECTS})
68   set_target_properties(${GWP_ASAN_TEST_RUNTIME} PROPERTIES
69     ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
70     FOLDER "Compiler-RT Runtime tests")
72   set(GwpAsanTestObjects)
73   generate_compiler_rt_tests(GwpAsanTestObjects
74     GwpAsanUnitTests "GwpAsan-${arch}-Test" ${arch}
75     SOURCES ${GWP_ASAN_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
76     RUNTIME ${GWP_ASAN_TEST_RUNTIME}
77     DEPS llvm_gtest ${GWP_ASAN_UNIT_TEST_HEADERS}
78     CFLAGS ${GWP_ASAN_UNITTEST_CFLAGS}
79     LINK_FLAGS ${GWP_ASAN_UNITTEST_LINK_FLAGS})
80   set_target_properties(GwpAsanUnitTests PROPERTIES
81     RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
82 endif()