brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · 7596e20 Raw
117 lines · plain
1set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})2 3set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})4 5set(SANITIZER_COMMON_TESTSUITES)6 7# FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of8# the hard coded `SUPPORTED_TOOLS_INIT` list once we know that the other9# sanitizers work.10set(SUPPORTED_TOOLS_INIT asan lsan hwasan msan tsan ubsan)11set(SUPPORTED_TOOLS)12  foreach(SANITIZER_TOOL ${SUPPORTED_TOOLS_INIT})13    string(TOUPPER ${SANITIZER_TOOL} SANITIZER_TOOL_UPPER)14    if (COMPILER_RT_HAS_${SANITIZER_TOOL_UPPER})15      list(APPEND SUPPORTED_TOOLS ${SANITIZER_TOOL})16    endif()17  endforeach()18 19# FIXME(dliew): Remove this.20# Temporary helper for https://reviews.llvm.org/D5574021message(22  STATUS23  "Generated Sanitizer SUPPORTED_TOOLS list on \"${CMAKE_SYSTEM_NAME}\" is"24  " \"${SUPPORTED_TOOLS}\"")25 26# FIXME(dliew): These tests should be made to work on all platforms.27# Use the legacy list for now.28if (ANDROID OR WINDOWS)29  set(OLD_SUPPORTED_TOOLS ${SUPPORTED_TOOLS})30  if (ANDROID)31    set(SUPPORTED_TOOLS asan)32  elseif (WINDOWS)33    set(SUPPORTED_TOOLS "")34  else()35    message(FATAL_ERROR "Unhandled platform")36  endif()37	message(38		AUTHOR_WARNING39    "Replacing Sanitizer SUPPORTED_TOOLS list (${OLD_SUPPORTED_TOOLS}) with "40    "\"${SUPPORTED_TOOLS}\"")41  unset(OLD_SUPPORTED_TOOLS)42endif()43 44# FIXME(dliew): Remove this.45# Temporary helper for https://reviews.llvm.org/D5574046message(47  STATUS48  "sanitizer_common tests on \"${CMAKE_SYSTEM_NAME}\" will run against "49  "\"${SUPPORTED_TOOLS}\"")50 51# Create a separate config for each tool we support.52foreach(tool ${SUPPORTED_TOOLS})53  string(TOUPPER ${tool} tool_toupper)54  if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD)55    list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool})56  endif()57  set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH})58  if(APPLE)59    darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH)60  endif()61  if(${tool} STREQUAL "asan")62    list(REMOVE_ITEM TEST_ARCH sparcv9)63  endif()64  if(OS_NAME MATCHES "SunOS" AND ${tool} STREQUAL "asan")65    list(REMOVE_ITEM TEST_ARCH x86_64)66  endif()67 68  # TODO(dliew): We should iterate over the different69  # Apple platforms, not just macOS.70  foreach(arch ${TEST_ARCH})71    set(SANITIZER_COMMON_LIT_TEST_MODE ${tool})72    set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch})73    get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS)74    set(CONFIG_NAME ${tool}-${arch}-${OS_NAME})75 76    # ARM on Linux might use the slow unwinder as default and the unwind table is77    # required to get a complete stacktrace.78    if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT ANDROID)79      list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS -funwind-tables)80      if(CMAKE_SYSROOT)81        list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS "--sysroot=${CMAKE_SYSROOT}")82      endif()83      string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS84                             "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")85    endif()86 87    configure_lit_site_cfg(88      ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in89      ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)90    # FIXME(dliew): LSan i386 on Darwin is completely broken right now.91    # so don't run the tests by default.92    # Tests fail on arm64, see https://github.com/llvm/llvm-project/issues/13167893    if (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND94             ${tool} STREQUAL "lsan" AND95             (${arch} STREQUAL "i386" OR ${arch} MATCHES "arm64")))96      list(APPEND SANITIZER_COMMON_TESTSUITES97           ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})98    endif()99  endforeach()100endforeach()101 102# Unit tests.103configure_lit_site_cfg(104  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in105  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)106# FIXME: support unit test in the android test runner107if (NOT ANDROID)108  list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)109  list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)110endif()111 112if(SANITIZER_COMMON_TESTSUITES)113  add_lit_testsuite(check-sanitizer "Running sanitizer_common tests"114    ${SANITIZER_COMMON_TESTSUITES}115    DEPENDS ${SANITIZER_COMMON_TEST_DEPS})116endif()117