[compiler-rt] r363779 - Revert r363633 "[CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2."
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 02:09:39 PDT 2019
Author: hans
Date: Wed Jun 19 02:09:39 2019
New Revision: 363779
URL: http://llvm.org/viewvc/llvm-project?rev=363779&view=rev
Log:
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
Modified:
compiler-rt/trunk/cmake/config-ix.cmake
compiler-rt/trunk/test/asan/CMakeLists.txt
compiler-rt/trunk/test/fuzzer/CMakeLists.txt
compiler-rt/trunk/test/tsan/CMakeLists.txt
compiler-rt/trunk/test/ubsan/CMakeLists.txt
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=363779&r1=363778&r2=363779&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Wed Jun 19 02:09:39 2019
@@ -208,32 +208,6 @@ macro(get_test_cc_for_arch arch cc_out c
endif()
endmacro()
-# Returns CFLAGS that should be used to run tests for the
-# specific apple platform and architecture.
-function(get_test_cflags_for_apple_platform platform arch cflags_out)
- is_valid_apple_platform("${platform}" is_valid_platform)
- if (NOT is_valid_platform)
- message(FATAL_ERROR "\"${platform}\" is not a valid apple platform")
- endif()
- set(test_cflags "")
- get_target_flags_for_arch(${arch} test_cflags)
- list(APPEND test_cflags ${DARWIN_${platform}_CFLAGS})
- string(REPLACE ";" " " test_cflags_str "${test_cflags}")
- string(APPEND test_cflags_str "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(${cflags_out} "${test_cflags_str}" PARENT_SCOPE)
-endfunction()
-
-function(is_valid_apple_platform platform is_valid_out)
- set(is_valid FALSE)
- if ("${platform}" STREQUAL "")
- message(FATAL_ERROR "platform cannot be empty")
- endif()
- if ("${platform}" MATCHES "^(osx|((ios|watchos|tvos)(sim)?))$")
- set(is_valid TRUE)
- endif()
- set(${is_valid_out} ${is_valid} PARENT_SCOPE)
-endfunction()
-
set(ARM64 aarch64)
set(ARM32 arm armhf)
set(HEXAGON hexagon)
Modified: compiler-rt/trunk/test/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/CMakeLists.txt?rev=363779&r1=363778&r2=363779&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/asan/CMakeLists.txt Wed Jun 19 02:09:39 2019
@@ -81,22 +81,15 @@ endforeach()
# variable to select which iOS device or simulator to use, e.g.:
# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
if(APPLE)
- # FIXME(dliew): This logic should be refactored to the way UBSan Darwin
- # testing is done.
set(EXCLUDE_FROM_ALL ON)
set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
set(ASAN_TEST_DYNAMIC True)
- list_intersect(ASAN_TEST_IOSSIM_ARCHS ASAN_SUPPORTED_ARCH DARWIN_iossim_ARCHS)
- foreach(arch ${ASAN_TEST_IOSSIM_ARCHS})
+ foreach(arch ${DARWIN_iossim_ARCHS})
set(ASAN_TEST_APPLE_PLATFORM "iossim")
set(ASAN_TEST_TARGET_ARCH ${arch})
- get_test_cflags_for_apple_platform(
- "${ASAN_TEST_APPLE_PLATFORM}"
- "${ASAN_TEST_TARGET_ARCH}"
- ASAN_TEST_TARGET_CFLAGS
- )
+ set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}")
get_bits_for_arch(${arch} ASAN_TEST_BITS)
string(TOUPPER ${arch} ARCH_UPPER_CASE)
@@ -110,14 +103,10 @@ if(APPLE)
DEPENDS ${ASAN_TEST_DEPS})
endforeach()
- list_intersect(ASAN_TEST_IOS_ARCHS ASAN_SUPPORTED_ARCH DARWIN_ios_ARCHS)
- foreach (arch ${ASAN_TEST_IOS_ARCHS})
+ foreach (arch ${DARWIN_ios_ARCHS})
set(ASAN_TEST_APPLE_PLATFORM "ios")
set(ASAN_TEST_TARGET_ARCH ${arch})
- get_test_cflags_for_apple_platform(
- "${ASAN_TEST_APPLE_PLATFORM}"
- "${arch}"
- ASAN_TEST_TARGET_CFLAGS)
+ set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}")
get_bits_for_arch(${arch} ASAN_TEST_BITS)
string(TOUPPER ${arch} ARCH_UPPER_CASE)
Modified: compiler-rt/trunk/test/fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/CMakeLists.txt?rev=363779&r1=363778&r2=363779&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/fuzzer/CMakeLists.txt Wed Jun 19 02:09:39 2019
@@ -89,19 +89,12 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linu
endif()
if (APPLE)
- # FIXME(dliew): This logic should be refactored to the way UBSan Darwin
- # testing is done.
set(EXCLUDE_FROM_ALL ON)
- list_intersect(FUZZER_TEST_IOS_ARCHS FUZZER_SUPPORTED_ARCH DARWIN_ios_ARCHS)
- foreach(arch ${FUZZER_TEST_IOS_ARCHS})
+ foreach(arch ${DARWIN_ios_ARCHS})
set(LIBFUZZER_TEST_APPLE_PLATFORM "ios")
set(LIBFUZZER_TEST_TARGET_ARCH ${arch})
- get_test_cflags_for_apple_platform(
- "${LIBFUZZER_TEST_APPLE_PLATFORM}"
- "${LIBFUZZER_TEST_TARGET_ARCH}"
- LIBFUZZER_TEST_FLAGS
- )
+ set(LIBFUZZER_TEST_FLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${LIBFUZZER_TEST_APPLE_PLATFORM}")
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
Modified: compiler-rt/trunk/test/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/CMakeLists.txt?rev=363779&r1=363778&r2=363779&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/tsan/CMakeLists.txt Wed Jun 19 02:09:39 2019
@@ -49,53 +49,39 @@ endforeach()
# variable to select which iOS device or simulator to use, e.g.:
# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
if(APPLE)
- # FIXME(dliew): This logic should be refactored to the way UBSan Darwin
- # testing is done.
set(EXCLUDE_FROM_ALL ON)
set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
- list_intersect(TSAN_TEST_IOSSIM_ARCHS TSAN_SUPPORTED_ARCH DARWIN_iossim_ARCHS)
- foreach(arch ${TSAN_TEST_IOSSIM_ARCHS})
- set(TSAN_TEST_APPLE_PLATFORM "iossim")
- set(TSAN_TEST_TARGET_ARCH ${arch})
- get_test_cflags_for_apple_platform(
- "${TSAN_TEST_APPLE_PLATFORM}"
- "${TSAN_TEST_TARGET_ARCH}"
- TSAN_TEST_TARGET_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})
- endforeach()
+ 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})
- list_intersect(TSAN_TEST_IOS_ARCHS TSAN_SUPPORTED_ARCH DARWIN_ios_ARCHS)
- foreach(arch ${TSAN_TEST_IOS_ARCHS})
- set(TSAN_TEST_APPLE_PLATFORM "ios")
- set(TSAN_TEST_TARGET_ARCH ${arch})
- get_test_cflags_for_apple_platform(
- "${TSAN_TEST_APPLE_PLATFORM}"
- "${TSAN_TEST_TARGET_ARCH}"
- TSAN_TEST_TARGET_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 ${arch} tests"
- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
- DEPENDS ${TSAN_TEST_DEPS})
- endforeach()
+ 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})
set(EXCLUDE_FROM_ALL OFF)
endif()
Modified: compiler-rt/trunk/test/ubsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/CMakeLists.txt?rev=363779&r1=363778&r2=363779&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/ubsan/CMakeLists.txt Wed Jun 19 02:09:39 2019
@@ -113,11 +113,7 @@ if(APPLE)
endif()
foreach(platform ${UBSAN_APPLE_PLATFORMS})
foreach(arch ${DARWIN_${platform}_ARCHS})
- get_test_cflags_for_apple_platform(
- "${platform}"
- "${arch}"
- UBSAN_TEST_TARGET_CFLAGS
- )
+ set(UBSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_${platform}_SYSROOT}")
if (";${UBSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
add_ubsan_device_testsuite("Standalone" ubsan ${platform} ${arch})
endif()
More information about the llvm-commits
mailing list