[PATCH] D61242: [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2.

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 09:31:43 PDT 2019


delcypher created this revision.
delcypher added reviewers: kubamracek, yln, vsk, juliehockett, phosek.
Herald added subscribers: Sanitizers, kristof.beyls, javed.absar, mgorny.
Herald added projects: LLVM, Sanitizers.

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


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D61242

Files:
  cmake/config-ix.cmake
  test/asan/CMakeLists.txt
  test/fuzzer/CMakeLists.txt
  test/tsan/CMakeLists.txt
  test/ubsan/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61242.197033.patch
Type: text/x-patch
Size: 8800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190428/0c0a708f/attachment.bin>


More information about the llvm-commits mailing list