Skip to content

Commit

Permalink
[Apple Silicon] Simulator support for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
shahmishal committed Jul 3, 2020
1 parent 8364ec9 commit 795c363
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 7 deletions.
25 changes: 21 additions & 4 deletions cmake/modules/DarwinSDKs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ option(SWIFT_ENABLE_IOS32

if(SWIFT_ENABLE_IOS32)
set(SUPPORTED_IOS_ARCHS "armv7;armv7s;arm64;arm64e")
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64")
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
else()
set(SUPPORTED_IOS_ARCHS "arm64;arm64e")
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64")
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64;arm64")
endif()

set(SUPPORTED_TVOS_ARCHS "arm64")
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64")
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
set(SUPPORTED_WATCHOS_ARCHS "armv7k")
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386")
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")

# Get the SDK version from SDKSettings.
execute_process(
COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "Version"
OUTPUT_VARIABLE SWIFT_OSX_SDK_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Remove the last component, if any. e.g. 10.15.26 -> 10.15
string(REGEX REPLACE "\([0-9]*[.][0-9]*\)[.][0-9]*" "\\1"
SWIFT_OSX_SDK_VERSION "${SWIFT_OSX_SDK_VERSION}")

if (${SWIFT_OSX_SDK_VERSION} STREQUAL "10.14" OR
${SWIFT_OSX_SDK_VERSION} STREQUAL "10.15")
set(SUPPORTED_OSX_ARCHS "x86_64")
else()
set(SUPPORTED_OSX_ARCHS "x86_64;arm64e")
endif()

is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx)
configure_sdk_darwin(
Expand Down
48 changes: 48 additions & 0 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,16 @@ function verify_host_is_supported() {
| macosx-arm64e \
| iphonesimulator-i386 \
| iphonesimulator-x86_64 \
| iphonesimulator-arm64 \
| iphoneos-armv7 \
| iphoneos-armv7s \
| iphoneos-arm64 \
| iphoneos-arm64e \
| appletvsimulator-x86_64 \
| appletvsimulator-arm64 \
| appletvos-arm64 \
| watchsimulator-i386 \
| watchsimulator-arm64 \
| watchos-armv7k \
| android-armv7 \
| android-aarch64)
Expand Down Expand Up @@ -527,6 +530,21 @@ function set_build_options_for_host() {
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
cmake_osx_deployment_target=""
;;
iphonesimulator-arm64)
xcrun_sdk_name="iphonesimulator"
llvm_target_arch="AArch64"
SWIFT_HOST_TRIPLE="arm64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator"
SWIFT_HOST_VARIANT="iphonesimulator"
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="arm64"

cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
iphoneos-armv7)
SWIFT_HOST_TRIPLE="armv7-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
llvm_target_arch="ARM"
Expand Down Expand Up @@ -562,6 +580,21 @@ function set_build_options_for_host() {
SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR"
cmake_osx_deployment_target=""
;;
appletvsimulator-arm64)
xcrun_sdk_name="appletvsimulator"
llvm_target_arch="AArch64"
SWIFT_HOST_TRIPLE="arm64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator"
SWIFT_HOST_VARIANT="appletvsimulator"
SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="arm64"

cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
appletvos-arm64)
SWIFT_HOST_TRIPLE="arm64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}"
llvm_target_arch="AArch64"
Expand All @@ -576,6 +609,21 @@ function set_build_options_for_host() {
SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR"
cmake_osx_deployment_target=""
;;
watchsimulator-arm64)
xcrun_sdk_name="watchsimulator"
llvm_target_arch="AArch64"
SWIFT_HOST_TRIPLE="arm64-apple-watchos${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator"
SWIFT_HOST_VARIANT="watchsimulator"
SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR"
SWIFT_HOST_VARIANT_ARCH="arm64"

cmake_osx_deployment_target=""
cmark_cmake_options=(
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"
-DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)"
)
;;
watchos-armv7k)
SWIFT_HOST_TRIPLE="armv7k-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
llvm_target_arch="ARM"
Expand Down
7 changes: 4 additions & 3 deletions utils/swift_build_support/swift_build_support/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class StdlibDeploymentTarget(object):

iOS = DarwinPlatform("iphoneos", archs=["armv7", "armv7s", "arm64", "arm64e"],
sdk_name="IOS")
iOSSimulator = DarwinPlatform("iphonesimulator", archs=["i386", "x86_64"],
iOSSimulator = DarwinPlatform("iphonesimulator", archs=["i386", "x86_64", "arm64"],
sdk_name="IOS_SIMULATOR",
is_simulator=True)

Expand All @@ -168,13 +168,14 @@ class StdlibDeploymentTarget(object):

AppleTV = DarwinPlatform("appletvos", archs=["arm64"],
sdk_name="TVOS")
AppleTVSimulator = DarwinPlatform("appletvsimulator", archs=["x86_64"],
AppleTVSimulator = DarwinPlatform("appletvsimulator", archs=["x86_64", "arm64"],
sdk_name="TVOS_SIMULATOR",
is_simulator=True)

AppleWatch = DarwinPlatform("watchos", archs=["armv7k"],
sdk_name="WATCHOS")
AppleWatchSimulator = DarwinPlatform("watchsimulator", archs=["i386"],

AppleWatchSimulator = DarwinPlatform("watchsimulator", archs=["i386", "arm64"],
sdk_name="WATCHOS_SIMULATOR",
is_simulator=True)

Expand Down

0 comments on commit 795c363

Please sign in to comment.