iphonesim: support iOS simulator builds on Apple Silicon (HXCPP_ARM64)#1343
Open
AxGord wants to merge 1 commit into
Open
iphonesim: support iOS simulator builds on Apple Silicon (HXCPP_ARM64)#1343AxGord wants to merge 1 commit into
AxGord wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
iphonesim-toolchain.xmlandfinish-setup.xmlcurrently only emit-arch i386/-arch x86_64for iOS simulator builds. On AppleSilicon Macs (M1/M2/M3) the simulator runs natively at arm64 — there
is no
x86_64simulator slice available unless you launch thesimulator under Rosetta. As a result, OpenFL/Lime native apps cannot
target the iOS simulator on Apple Silicon without an arm64 simulator
build, and the current toolchain does not produce one.
This PR adds first-class
HXCPP_ARM64simulator support:-target arm64-apple-ios${version}-simulator(instead of-arch),which is the only correct way to ask clang for an Apple Silicon
simulator binary —
-arch arm64alone yields a device slice thatthe simulator refuses to load.
.iphonesim-arm64LIBEXTRAso arm64-sim binaries don'tcollide with
x86_64/i386simulator binaries inLIBEXTRA=.iphonesim*.obj/iphonesim*-64/object directory for arm64-sim soparallel builds for different sim slices don't trash each other's
intermediate objects.
-arch arm64for the dynamic library on Apple Siliconsimulator.
<section unless="HXCPP_ARM64">, so existing builds on Intel Macsand the existing
HXCPP_M64flow are unchanged.We've been carrying this patch in our
soccertutor/hxcppfork for~1.5 years, used in production OpenFL+AIR apps that ship to iPad. Built
and tested on Apple Silicon (M1 Pro) against Xcode 15/16 SDKs, iOS
simulator runtimes 16/17/18.
Why the
-targettriple instead of-arch arm64-arch arm64by itself produces a device slice. The simulator looksat the binary's
LC_BUILD_VERSIONload command — forarm64itexpects platform 7 (
PLATFORM_IOSSIMULATOR), and clang only sets thatcorrectly when you ask via
-target arm64-apple-ios<x>-simulator.This is the same approach Xcode itself uses internally for arm64-sim
builds and matches the recommendation in Apple's TN3144 / docs.
Files
xmllint --nooutconfirms both files are well-formed.Use
The resulting
.iphonesim-arm64.dylibloads cleanly on an Apple SiliconiOS simulator runtime.
Risk
unless=\"HXCPP_ARM64\"guards on the existing x86_64/i386 sectionsmean the legacy path is byte-identical when
HXCPP_ARM64is unset.HXCPP_ARM64unset, iOS simulatorbuilds on Intel Macs are unchanged.
LIBEXTRAandobjdir, so callers that hard-code.iphonesim/obj/iphonesimpaths need to queryLIBEXTRAinstead.Anything going through
haxelib run hxcpp/limealready does.Context for follow-up
This unblocks an Apple Silicon support PR we have queued for
openfl/lime(NDLL fallback chain, auto-OpenAL backend selection, etc., which depend
on the iOS sim arm64 slice produced by this patch).
Happy to add an entry under
docs/Defines.mdforHXCPP_ARM64ifdesired — wasn't sure if that flag is documented elsewhere already.