diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -250,7 +250,28 @@ endif() set(test_cflags "") get_target_flags_for_arch(${arch} test_cflags) - list(APPEND test_cflags ${DARWIN_${platform}_CFLAGS}) + + if (NOT "${arch}" STREQUAL "arm64e") + list(APPEND test_cflags ${DARWIN_${platform}_CFLAGS}) + else() + # arm64e is not currently ABI stable so we need to build for the + # OS version being tested. Rather than querying the device under test + # we use the SDK version which "should" be the same as the + # device under test (it is a configuration error for these not to match). + # FIXME(dliew): We can remove this if we build the runtimes with the appropriate + # deployment target for arm64e. + foreach (flag ${DARWIN_${platform}_CFLAGS}) + if ("${flag}" MATCHES "^${DARWIN_${platform}_MIN_VER_FLAG}=.+") + # Patch flag with correct deployment target + set(replacement_flag "${DARWIN_${platform}_MIN_VER_FLAG}=${DARWIN_${platform}_SDK_VERSION}") + list(APPEND test_cflags "${replacement_flag}") + else() + # Copy through + list(APPEND test_cflags "${flag}") + endif() + endforeach() + endif() + 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) @@ -292,6 +313,14 @@ find_darwin_sdk_dir(DARWIN_tvossim_SYSROOT appletvsimulator) find_darwin_sdk_dir(DARWIN_tvos_SYSROOT appletvos) + find_darwin_sdk_version(DARWIN_osx_SDK_VERSION macosx) + find_darwin_sdk_version(DARWIN_iossim_SDK_VERSION iphonesimulator) + find_darwin_sdk_version(DARWIN_ios_SDK_VERSION iphoneos) + find_darwin_sdk_version(DARWIN_watchossim_SDK_VERSION watchsimulator) + find_darwin_sdk_version(DARWIN_watchos_SDK_VERSION watchos) + find_darwin_sdk_version(DARWIN_tvossim_SDK_VERSION appletvsimulator) + find_darwin_sdk_version(DARWIN_tvos_SDK_VERSION appletvos) + if(NOT DARWIN_osx_SYSROOT) message(WARNING "Could not determine OS X sysroot, trying /usr/include") if(EXISTS /usr/include)