summaryrefslogtreecommitdiff
path: root/test/ubsan/CMakeLists.txt
diff options
context:
space:
mode:
authorDan Liew <dan@su-root.co.uk>2019-06-17 23:37:46 +0000
committerDan Liew <dan@su-root.co.uk>2019-06-17 23:37:46 +0000
commita13574ed32b194d1a7c5bb5fee88d37f9041e196 (patch)
tree92c9fb73995f559b25450a8a41e8809441b92837 /test/ubsan/CMakeLists.txt
parentf8bc43854bda9cd47e76c9bcfd05d0e5a907bcd1 (diff)
downloadcompiler-rt-a13574ed32b194d1a7c5bb5fee88d37f9041e196.tar.gz
[CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2.
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@363633 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/ubsan/CMakeLists.txt')
-rw-r--r--test/ubsan/CMakeLists.txt6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ubsan/CMakeLists.txt b/test/ubsan/CMakeLists.txt
index 60ef84d75..280f96777 100644
--- a/test/ubsan/CMakeLists.txt
+++ b/test/ubsan/CMakeLists.txt
@@ -113,7 +113,11 @@ if(APPLE)
endif()
foreach(platform ${UBSAN_APPLE_PLATFORMS})
foreach(arch ${DARWIN_${platform}_ARCHS})
- set(UBSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_${platform}_SYSROOT}")
+ get_test_cflags_for_apple_platform(
+ "${platform}"
+ "${arch}"
+ UBSAN_TEST_TARGET_CFLAGS
+ )
if (";${UBSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
add_ubsan_device_testsuite("Standalone" ubsan ${platform} ${arch})
endif()