llvm-project/compiler-rt/test
Dan Liew bbde056b88 [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3.
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 third 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.

The second attempt (r363633) had to be reverted (r363779) due to a build
failure. The failed build was using a modified Apple toolchain where the iOS
simulator SDK was missing. This exposed a bug in the existing UBSan test
generation code where it was assumed that `COMPILER_RT_ENABLE_IOS` implied that
the toolchain supported both iOS and the iOS simulator. This is not true. This
has been fixed by using the list `SANITIZER_COMMON_SUPPORTED_OS` for the list
of supported Apple platforms for UBSan. For consistency with the other
Sanitizers we also now intersect the list of architectures with
UBSAN_SUPPORTED_ARCH.

rdar://problem/50124489

Differential Revision: https://reviews.llvm.org/D61242

llvm-svn: 373405
2019-10-01 23:08:18 +00:00
..
BlocksRuntime Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
asan [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3. 2019-10-01 23:08:18 +00:00
builtins builtins test: Move clear_cache_test.c from a mprotect()ed global to a mmap()ed variable 2019-09-25 11:57:51 +00:00
cfi [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.* 2019-06-27 20:56:04 +00:00
crt compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
dfsan compiler-rt: Rename .cc file in test/dfsan to cpp 2019-08-05 13:19:28 +00:00
fuzzer [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3. 2019-10-01 23:08:18 +00:00
gwp_asan compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
hwasan hwasan: Compatibility fixes for short granules. 2019-09-27 01:02:10 +00:00
interception [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.* 2019-06-27 20:56:04 +00:00
lsan [lsan] Fix deadlock in dl_iterate_phdr. 2019-09-19 19:52:57 +00:00
msan [msan] Intercept __getrlimit. 2019-09-30 17:49:48 +00:00
profile Revert "[profile] Add a test dependency on cxx-headers" 2019-09-27 20:24:48 +00:00
safestack compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
sanitizer_common [compiler-rt] Run cpplint only for check-sanitizer 2019-09-12 01:35:11 +00:00
scudo compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
shadowcallstack compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
tsan [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3. 2019-10-01 23:08:18 +00:00
ubsan [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3. 2019-10-01 23:08:18 +00:00
ubsan_minimal compiler-rt: Remove .cc from all lit config files 2019-08-05 19:25:35 +00:00
xray [XRay] Fixing one test case for FreeBSD 2019-08-28 14:18:05 +00:00
.clang-format [compiler-rt] Use "ColumnLimit: 0" instead of "clang-format off" in tests 2018-12-01 01:24:29 +00:00
CMakeLists.txt [compiler-rt] Run cpplint only for check-sanitizer 2019-09-12 01:35:11 +00:00
lit.common.cfg.py compiler-rt: Rename cc files below test/asan to cpp 2019-08-05 16:48:12 +00:00
lit.common.configured.in [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.* 2019-06-27 20:56:04 +00:00