File: CMakeLists.txt

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (119 lines) | stat: -rw-r--r-- 4,312 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
set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})

set(SANITIZER_COMMON_TESTSUITES)

# FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of
# the hard coded `SUPPORTED_TOOLS_INIT` list once we know that the other
# sanitizers work.
set(SUPPORTED_TOOLS_INIT asan lsan hwasan msan tsan ubsan)
set(SUPPORTED_TOOLS)
  foreach(SANITIZER_TOOL ${SUPPORTED_TOOLS_INIT})
    string(TOUPPER ${SANITIZER_TOOL} SANITIZER_TOOL_UPPER)
    if (COMPILER_RT_HAS_${SANITIZER_TOOL_UPPER})
      list(APPEND SUPPORTED_TOOLS ${SANITIZER_TOOL})
    endif()
  endforeach()

# FIXME(dliew): Remove this.
# Temporary helper for https://reviews.llvm.org/D55740
message(
  STATUS
  "Generated Sanitizer SUPPORTED_TOOLS list on \"${CMAKE_SYSTEM_NAME}\" is"
  " \"${SUPPORTED_TOOLS}\"")

# FIXME(dliew): These tests should be made to work on all platforms.
# Use the legacy list for now.
if (ANDROID OR WINDOWS)
  set(OLD_SUPPORTED_TOOLS ${SUPPORTED_TOOLS})
  if (ANDROID)
    set(SUPPORTED_TOOLS asan)
  elseif (WINDOWS)
    set(SUPPORTED_TOOLS "")
  else()
    message(FATAL_ERROR "Unhandled platform")
  endif()
	message(
		AUTHOR_WARNING
    "Replacing Sanitizer SUPPORTED_TOOLS list (${OLD_SUPPORTED_TOOLS}) with "
    "\"${SUPPORTED_TOOLS}\"")
  unset(OLD_SUPPORTED_TOOLS)
endif()

# FIXME(dliew): Remove this.
# Temporary helper for https://reviews.llvm.org/D55740
message(
  STATUS
  "sanitizer_common tests on \"${CMAKE_SYSTEM_NAME}\" will run against "
  "\"${SUPPORTED_TOOLS}\"")

# Create a separate config for each tool we support.
foreach(tool ${SUPPORTED_TOOLS})
  string(TOUPPER ${tool} tool_toupper)
  if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD)
    list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool})
  endif()
  set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH})
  if(APPLE)
    darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)
  endif()
  if(${tool} STREQUAL "asan")
    list(REMOVE_ITEM TEST_ARCH sparc sparcv9)
  endif()
  if(OS_NAME MATCHES "SunOS" AND ${tool} STREQUAL "asan")
    list(REMOVE_ITEM TEST_ARCH x86_64)
  endif()

  # TODO(dliew): We should iterate over the different
  # Apple platforms, not just macOS.
  foreach(arch ${TEST_ARCH})
    set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})
    set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})
    get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)
    set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})

    # ARM on Linux might use the slow unwinder as default and the unwind table is
    # required to get a complete stacktrace.
    if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT ANDROID)
      list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS -funwind-tables)
      if(CMAKE_SYSROOT)
        list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS "--sysroot=${CMAKE_SYSROOT}")
      endif()
      string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS
                             "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
    endif()

    configure_lit_site_cfg(
      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
    # FIXME(dliew): LSan i386 on Darwin is completely broken right now.
    # so don't run the tests by default.
    if (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND
             ${tool} STREQUAL "lsan" AND
             ${arch} STREQUAL "i386"))
      list(APPEND SANITIZER_COMMON_TESTSUITES
           ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
    endif()
  endforeach()
endforeach()

# Unit tests.
if(COMPILER_RT_INCLUDE_TESTS)
  configure_lit_site_cfg(
    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)
  # FIXME: support unit test in the android test runner
  if (NOT ANDROID)
    list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
    list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
  endif()
endif()

if(SANITIZER_COMMON_TESTSUITES)
  add_lit_testsuite(check-sanitizer "Running sanitizer_common tests"
    ${SANITIZER_COMMON_TESTSUITES}
    DEPENDS ${SANITIZER_COMMON_TEST_DEPS})
  set_target_properties(check-sanitizer PROPERTIES FOLDER
                        "Compiler-RT Misc")
endif()