Skip to content

Commit

Permalink
Fix error when building for simulator on Apple silicon with Xcode 13.3
Browse files Browse the repository at this point in the history
Additional workaround for https://bugs.swift.org/browse/SR-16010.

There's no such a simulator on Apple silicon Macs with a minimum OS
version before ABI stability, so it's unnecessary to bundle the original
Swift runtime here. This avoids error when we thin the dylibs later,
because the original Swift dylibs don't contains arm64 slice for
simulator.
  • Loading branch information
thii committed Mar 23, 2022
1 parent 07f5f2d commit 9ddc6a0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apple/internal/partials/swift_dylibs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def _swift_dylib_action(
xcode_path_wrapper = platform_prerequisites.xcode_path_wrapper,
)

def _target_platform_is_arm_simulator(platform_prerequisites):
"""Returns True if the target platform is a simulator with arm64 architecture, otherwise False.
Args:
platform_prerequisites: Struct containing information on the platform being targeted.
"""

return (platform_prerequisites.apple_fragment.single_arch_cpu == "arm64" and
not platform_prerequisites.platform.is_device)

def _swift_dylibs_partial_impl(
*,
actions,
Expand Down Expand Up @@ -166,7 +176,13 @@ def _swift_dylibs_partial_impl(
swift_min_os = _MIN_OS_PLATFORM_SWIFT_PRESENCE[str(platform_prerequisites.platform_type)]
swift_dylibs_path_prefix = "Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-"
swift_dylibs_paths = [swift_dylibs_path_prefix + "5.5"]
if target_min_os < swift_min_os:

# Workaround for https://bugs.swift.org/browse/SR-16010.
if (target_min_os < swift_min_os and
# There's no such a simulator on Apple silicon Macs with a minimum OS
# version before ABI stability, so it's unnecessary to bundle the
# original Swift runtime here.
not _target_platform_is_arm_simulator(platform_prerequisites)):
swift_dylibs_paths.append(swift_dylibs_path_prefix + "5.0")

transitive_binaries = depset(
Expand Down

0 comments on commit 9ddc6a0

Please sign in to comment.