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