annotate compiler-rt/test/sanitizer_common/CMakeLists.txt @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 if(CMAKE_HOST_UNIX)
anatofuz
parents:
diff changeset
6 list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerLintCheck)
anatofuz
parents:
diff changeset
7 endif()
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 set(SANITIZER_COMMON_TESTSUITES)
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 # FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of
anatofuz
parents:
diff changeset
12 # the hard coded `SUPPORTED_TOOLS_INIT` list once we know that the other
anatofuz
parents:
diff changeset
13 # sanitizers work.
anatofuz
parents:
diff changeset
14 set(SUPPORTED_TOOLS_INIT asan lsan msan tsan ubsan)
anatofuz
parents:
diff changeset
15 set(SUPPORTED_TOOLS)
anatofuz
parents:
diff changeset
16 foreach(SANITIZER_TOOL ${SUPPORTED_TOOLS_INIT})
anatofuz
parents:
diff changeset
17 string(TOUPPER ${SANITIZER_TOOL} SANITIZER_TOOL_UPPER)
anatofuz
parents:
diff changeset
18 if (COMPILER_RT_HAS_${SANITIZER_TOOL_UPPER})
anatofuz
parents:
diff changeset
19 list(APPEND SUPPORTED_TOOLS ${SANITIZER_TOOL})
anatofuz
parents:
diff changeset
20 endif()
anatofuz
parents:
diff changeset
21 endforeach()
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 # FIXME(dliew): Remove this.
anatofuz
parents:
diff changeset
24 # Temporary helper for https://reviews.llvm.org/D55740
anatofuz
parents:
diff changeset
25 message(
anatofuz
parents:
diff changeset
26 STATUS
anatofuz
parents:
diff changeset
27 "Generated Sanitizer SUPPORTED_TOOLS list on \"${CMAKE_SYSTEM_NAME}\" is"
anatofuz
parents:
diff changeset
28 " \"${SUPPORTED_TOOLS}\"")
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 # FIXME(dliew): These tests should be made to work on all platforms.
anatofuz
parents:
diff changeset
31 # Use the legacy list for now.
anatofuz
parents:
diff changeset
32 if (ANDROID OR WINDOWS)
anatofuz
parents:
diff changeset
33 set(OLD_SUPPORTED_TOOLS ${SUPPORTED_TOOLS})
anatofuz
parents:
diff changeset
34 if (ANDROID)
anatofuz
parents:
diff changeset
35 set(SUPPORTED_TOOLS asan)
anatofuz
parents:
diff changeset
36 elseif (WINDOWS)
anatofuz
parents:
diff changeset
37 set(SUPPORTED_TOOLS "")
anatofuz
parents:
diff changeset
38 else()
anatofuz
parents:
diff changeset
39 message(FATAL_ERROR "Unhandled platform")
anatofuz
parents:
diff changeset
40 endif()
anatofuz
parents:
diff changeset
41 message(
anatofuz
parents:
diff changeset
42 AUTHOR_WARNING
anatofuz
parents:
diff changeset
43 "Replacing Sanitizer SUPPORTED_TOOLS list (${OLD_SUPPORTED_TOOLS}) with "
anatofuz
parents:
diff changeset
44 "\"${SUPPORTED_TOOLS}\"")
anatofuz
parents:
diff changeset
45 unset(OLD_SUPPORTED_TOOLS)
anatofuz
parents:
diff changeset
46 endif()
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 # FIXME(dliew): Remove this.
anatofuz
parents:
diff changeset
49 # Temporary helper for https://reviews.llvm.org/D55740
anatofuz
parents:
diff changeset
50 message(
anatofuz
parents:
diff changeset
51 STATUS
anatofuz
parents:
diff changeset
52 "sanitizer_common tests on \"${CMAKE_SYSTEM_NAME}\" will run against "
anatofuz
parents:
diff changeset
53 "\"${SUPPORTED_TOOLS}\"")
anatofuz
parents:
diff changeset
54
anatofuz
parents:
diff changeset
55 # Create a separate config for each tool we support.
anatofuz
parents:
diff changeset
56 foreach(tool ${SUPPORTED_TOOLS})
anatofuz
parents:
diff changeset
57 string(TOUPPER ${tool} tool_toupper)
anatofuz
parents:
diff changeset
58 if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD)
anatofuz
parents:
diff changeset
59 list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool})
anatofuz
parents:
diff changeset
60 endif()
anatofuz
parents:
diff changeset
61 set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH})
anatofuz
parents:
diff changeset
62 if(APPLE)
anatofuz
parents:
diff changeset
63 darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)
anatofuz
parents:
diff changeset
64 endif()
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
65 if(${tool} STREQUAL "asan")
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
66 list(REMOVE_ITEM TEST_ARCH sparc sparcv9)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
67 endif()
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
68 if(OS_NAME MATCHES "SunOS" AND ${tool} STREQUAL "asan")
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
69 list(REMOVE_ITEM TEST_ARCH x86_64)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
70 endif()
150
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 # TODO(dliew): We should iterate over the different
anatofuz
parents:
diff changeset
73 # Apple platforms, not just macOS.
anatofuz
parents:
diff changeset
74 foreach(arch ${TEST_ARCH})
anatofuz
parents:
diff changeset
75 set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})
anatofuz
parents:
diff changeset
76 set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})
anatofuz
parents:
diff changeset
77 get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)
anatofuz
parents:
diff changeset
78 set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
79
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
80 # ARM on Linux might use the slow unwinder as default and the unwind table is
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
81 # required to get a complete stacktrace.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
82 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT ANDROID)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
83 list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS -funwind-tables)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
84 string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
85 "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
86 endif()
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
87
150
anatofuz
parents:
diff changeset
88 configure_lit_site_cfg(
anatofuz
parents:
diff changeset
89 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
anatofuz
parents:
diff changeset
90 ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
anatofuz
parents:
diff changeset
91 # FIXME(dliew): LSan i386 on Darwin is completly broken right now.
anatofuz
parents:
diff changeset
92 # so don't run the tests by default.
anatofuz
parents:
diff changeset
93 if (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
anatofuz
parents:
diff changeset
94 ${tool} STREQUAL "lsan" AND
anatofuz
parents:
diff changeset
95 ${arch} STREQUAL "i386"))
anatofuz
parents:
diff changeset
96 list(APPEND SANITIZER_COMMON_TESTSUITES
anatofuz
parents:
diff changeset
97 ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
anatofuz
parents:
diff changeset
98 endif()
anatofuz
parents:
diff changeset
99 endforeach()
anatofuz
parents:
diff changeset
100 endforeach()
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 # Unit tests.
anatofuz
parents:
diff changeset
103 if(COMPILER_RT_INCLUDE_TESTS)
anatofuz
parents:
diff changeset
104 configure_lit_site_cfg(
anatofuz
parents:
diff changeset
105 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
anatofuz
parents:
diff changeset
106 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)
anatofuz
parents:
diff changeset
107 # FIXME: support unit test in the android test runner
anatofuz
parents:
diff changeset
108 if (NOT ANDROID)
anatofuz
parents:
diff changeset
109 list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
anatofuz
parents:
diff changeset
110 list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
anatofuz
parents:
diff changeset
111 endif()
anatofuz
parents:
diff changeset
112 endif()
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 if(SANITIZER_COMMON_TESTSUITES)
anatofuz
parents:
diff changeset
115 add_lit_testsuite(check-sanitizer "Running sanitizer_common tests"
anatofuz
parents:
diff changeset
116 ${SANITIZER_COMMON_TESTSUITES}
anatofuz
parents:
diff changeset
117 DEPENDS ${SANITIZER_COMMON_TEST_DEPS})
anatofuz
parents:
diff changeset
118 set_target_properties(check-sanitizer PROPERTIES FOLDER
anatofuz
parents:
diff changeset
119 "Compiler-RT Misc")
anatofuz
parents:
diff changeset
120 endif()