2017-07-10 23:00:55 +08:00
|
|
|
set(TSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
2014-02-20 17:47:18 +08:00
|
|
|
set(TSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
|
2015-12-09 05:54:39 +08:00
|
|
|
if(${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "x86_64")
|
2015-04-10 17:45:22 +08:00
|
|
|
list(APPEND TSAN_TEST_DEPS GotsanRuntimeCheck)
|
|
|
|
endif()
|
2014-02-20 17:47:18 +08:00
|
|
|
if(NOT COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
list(APPEND TSAN_TEST_DEPS tsan)
|
|
|
|
endif()
|
2017-12-12 09:20:52 +08:00
|
|
|
if(COMPILER_RT_LIBCXX_PATH AND
|
2019-02-17 20:16:20 +08:00
|
|
|
COMPILER_RT_LIBCXXABI_PATH AND
|
2015-11-09 17:53:38 +08:00
|
|
|
COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
|
2017-10-12 05:22:45 +08:00
|
|
|
AND NOT APPLE AND NOT ANDROID)
|
2014-05-14 06:30:16 +08:00
|
|
|
list(APPEND TSAN_TEST_DEPS libcxx_tsan)
|
|
|
|
set(TSAN_HAS_LIBCXX True)
|
|
|
|
else()
|
|
|
|
set(TSAN_HAS_LIBCXX False)
|
|
|
|
endif()
|
|
|
|
|
2016-02-03 02:43:53 +08:00
|
|
|
set(TSAN_TESTSUITES)
|
|
|
|
|
2016-02-03 06:42:25 +08:00
|
|
|
set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH})
|
|
|
|
if(APPLE)
|
|
|
|
darwin_filter_host_archs(TSAN_SUPPORTED_ARCH TSAN_TEST_ARCH)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${TSAN_TEST_ARCH})
|
2018-06-20 21:33:42 +08:00
|
|
|
set(TSAN_TEST_APPLE_PLATFORM "osx")
|
2017-07-10 23:00:55 +08:00
|
|
|
|
2016-02-23 09:34:17 +08:00
|
|
|
set(TSAN_TEST_TARGET_ARCH ${arch})
|
2016-02-03 02:43:53 +08:00
|
|
|
string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
|
2016-11-30 03:25:53 +08:00
|
|
|
get_test_cc_for_arch(${arch} TSAN_TEST_TARGET_CC TSAN_TEST_TARGET_CFLAGS)
|
2016-02-03 02:43:53 +08:00
|
|
|
|
2019-04-04 09:10:07 +08:00
|
|
|
string(REPLACE ";" " " LIBDISPATCH_CFLAGS_STRING " ${COMPILER_RT_TEST_LIBDISPATCH_CFLAGS}")
|
|
|
|
string(APPEND TSAN_TEST_TARGET_CFLAGS ${LIBDISPATCH_CFLAGS_STRING})
|
2019-03-16 01:52:27 +08:00
|
|
|
|
2016-02-03 02:43:53 +08:00
|
|
|
string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
|
|
|
set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
|
|
|
|
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
|
|
|
|
list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
|
|
|
|
endforeach()
|
2014-02-14 22:35:48 +08:00
|
|
|
|
2017-07-10 23:00:55 +08:00
|
|
|
# iOS and iOS simulator test suites
|
2017-07-13 05:02:48 +08:00
|
|
|
# These are not added into "check-all", in order to run these tests, use
|
|
|
|
# "check-tsan-iossim-x86_64" and similar. They also require an extra environment
|
2017-07-10 23:00:55 +08:00
|
|
|
# variable to select which iOS device or simulator to use, e.g.:
|
2017-07-13 05:02:48 +08:00
|
|
|
# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
|
2017-07-10 23:00:55 +08:00
|
|
|
if(APPLE)
|
2017-07-13 05:02:48 +08:00
|
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
|
|
|
2017-07-10 23:00:55 +08:00
|
|
|
set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
|
|
|
|
|
Revert r363633 "[CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2."
This caused Chromium's clang package to stop building, see comment on
https://reviews.llvm.org/D61242 for details.
> Summary:
> The main problem here is that `-*-version_min=` was not being passed to
> the compiler when building test cases. This can cause problems when
> testing on devices running older OSs because Clang would previously
> assume the minimum deployment target is the the latest OS in the SDK
> which could be much newer than what the device is running.
>
> Previously the generated value looked like this:
>
> `-arch arm64 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> With this change it now looks like:
>
> `-arch arm64 -stdlib=libc++ -miphoneos-version-min=8.0 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> This mirrors the setting of `config.target_cflags` on macOS.
>
> This change is made for ASan, LibFuzzer, TSan, and UBSan.
>
> To implement this a new `get_test_cflags_for_apple_platform()` function
> has been added that when given an Apple platform name and architecture
> returns a string containing the C compiler flags to use when building
> tests. This also calls a new helper function `is_valid_apple_platform()`
> that validates Apple platform names.
>
> This is the second attempt at landing the patch. The first attempt (r359305)
> had to be reverted (r359327) due to a buildbot failure. The problem was
> that calling `get_test_cflags_for_apple_platform()` can trigger a CMake
> error if the provided architecture is not supported by the current
> CMake configuration. Previously, this could be triggered by passing
> `-DCOMPILER_RT_ENABLE_IOS=OFF` to CMake. The root cause is that we were
> generating test configurations for a list of architectures without
> checking if the relevant Sanitizer actually supported that architecture.
> We now intersect the list of architectures for an Apple platform
> with `<SANITIZER>_SUPPORTED_ARCH` (where `<SANITIZER>` is a Sanitizer
> name) to iterate through the correct list of architectures.
>
> rdar://problem/50124489
>
> Reviewers: kubamracek, yln, vsk, juliehockett, phosek
>
> Subscribers: mgorny, javed.absar, kristof.beyls, #sanitizers, llvm-commits
>
> Tags: #llvm, #sanitizers
>
> Differential Revision: https://reviews.llvm.org/D61242
llvm-svn: 363779
2019-06-19 17:09:39 +08:00
|
|
|
set(TSAN_TEST_APPLE_PLATFORM "iossim")
|
|
|
|
set(arch "x86_64")
|
|
|
|
set(TSAN_TEST_TARGET_ARCH ${arch})
|
|
|
|
set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
|
|
|
|
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
|
|
|
|
string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
|
|
|
set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
|
|
|
|
)
|
|
|
|
add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
|
|
|
|
DEPENDS ${TSAN_TEST_DEPS})
|
2017-07-10 23:00:55 +08:00
|
|
|
|
Revert r363633 "[CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2."
This caused Chromium's clang package to stop building, see comment on
https://reviews.llvm.org/D61242 for details.
> Summary:
> The main problem here is that `-*-version_min=` was not being passed to
> the compiler when building test cases. This can cause problems when
> testing on devices running older OSs because Clang would previously
> assume the minimum deployment target is the the latest OS in the SDK
> which could be much newer than what the device is running.
>
> Previously the generated value looked like this:
>
> `-arch arm64 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> With this change it now looks like:
>
> `-arch arm64 -stdlib=libc++ -miphoneos-version-min=8.0 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> This mirrors the setting of `config.target_cflags` on macOS.
>
> This change is made for ASan, LibFuzzer, TSan, and UBSan.
>
> To implement this a new `get_test_cflags_for_apple_platform()` function
> has been added that when given an Apple platform name and architecture
> returns a string containing the C compiler flags to use when building
> tests. This also calls a new helper function `is_valid_apple_platform()`
> that validates Apple platform names.
>
> This is the second attempt at landing the patch. The first attempt (r359305)
> had to be reverted (r359327) due to a buildbot failure. The problem was
> that calling `get_test_cflags_for_apple_platform()` can trigger a CMake
> error if the provided architecture is not supported by the current
> CMake configuration. Previously, this could be triggered by passing
> `-DCOMPILER_RT_ENABLE_IOS=OFF` to CMake. The root cause is that we were
> generating test configurations for a list of architectures without
> checking if the relevant Sanitizer actually supported that architecture.
> We now intersect the list of architectures for an Apple platform
> with `<SANITIZER>_SUPPORTED_ARCH` (where `<SANITIZER>` is a Sanitizer
> name) to iterate through the correct list of architectures.
>
> rdar://problem/50124489
>
> Reviewers: kubamracek, yln, vsk, juliehockett, phosek
>
> Subscribers: mgorny, javed.absar, kristof.beyls, #sanitizers, llvm-commits
>
> Tags: #llvm, #sanitizers
>
> Differential Revision: https://reviews.llvm.org/D61242
llvm-svn: 363779
2019-06-19 17:09:39 +08:00
|
|
|
set(TSAN_TEST_APPLE_PLATFORM "ios")
|
|
|
|
set(arch "arm64")
|
|
|
|
set(TSAN_TEST_TARGET_ARCH ${arch})
|
|
|
|
set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
|
|
|
|
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
|
|
|
|
string(TOUPPER ${arch} ARCH_UPPER_CASE)
|
|
|
|
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
|
|
|
|
)
|
|
|
|
add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS Simulator ${arch} tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
|
|
|
|
DEPENDS ${TSAN_TEST_DEPS})
|
2017-07-13 05:02:48 +08:00
|
|
|
|
|
|
|
set(EXCLUDE_FROM_ALL OFF)
|
2017-07-10 23:00:55 +08:00
|
|
|
endif()
|
|
|
|
|
2014-02-19 19:18:47 +08:00
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
2014-02-14 22:35:48 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
|
|
|
|
list(APPEND TSAN_TEST_DEPS TsanUnitTests)
|
2016-02-18 03:35:51 +08:00
|
|
|
list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
|
2014-02-14 22:35:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
|
2016-02-18 03:35:51 +08:00
|
|
|
${TSAN_TESTSUITES}
|
2014-02-14 22:35:48 +08:00
|
|
|
DEPENDS ${TSAN_TEST_DEPS})
|
2016-07-12 05:51:56 +08:00
|
|
|
set_target_properties(check-tsan PROPERTIES FOLDER "Compiler-RT Tests")
|