-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Add support for DarwinArchs when assembling macOS App.framework #81243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
26454e6
to
eebf222
Compare
flutter#81205 This can be used to specify target architectures and produce fat binaries.
even though TargetPlatform is called darwin
2fabd56
to
03b23e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have some example unit tests for the iOS lipo you could copy from for the macOS example
I'll look at the tests for lipo. Also debug build only produces x86_64 framework, I'll fix that too. |
@@ -311,7 +311,7 @@ class AOTSnapshotter { | |||
TargetPlatform.android_arm64, | |||
TargetPlatform.android_x64, | |||
TargetPlatform.ios, | |||
TargetPlatform.darwin_x64, | |||
TargetPlatform.darwin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you in #81205 (comment)
It does feel a bit off that there is
TargetPlatform.ios
and--define=IosArchs=...
and thenTargetPlatform.darwin
. But iOS is darwin. It really should beTargetPlatform.macOS
and--define=MacOSArchs=...
.
Just glancing at this I wouldn't be sure which to use (the confusion predates this PR). This also gets hairier when we start targeting iOS apps as native ARM mac apps for the unfortunately named "Mac Designed for iPad" #66184.
I'd be supportive if you wanted to rename this macos
instead of darwin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be supportive if you wanted to rename this macos instead of darwin.
I'll keep that in mind, but I'm not sure I'd want to do it in this PR.
I added lipo tests for both framework thinning and universal binary. |
@@ -103,6 +103,14 @@ enum HostArtifact { | |||
pubExecutable, | |||
} | |||
|
|||
// TODO(knopp): Remove once darwin artifacts are moved out of darwin-x64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we're going to move darwin artifacts out of darwin-x64. We'll still have different engine builds for darwin-x64 and darwin-arm - the target platform is best though of as a convenience for how the engine builds think of targets that was incorrectly extended to how our users interact with the platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need different engine builds? Can you just have universal FlutterMacOS.framework (just like you have universal Flutter.framework for ios)? The PR already implements framework thinning.
I assumed that all the artifacts would be distributed as universal in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No better answer than "that is how the engine builds are configured currently".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, sure, but I assumed that at some point there's going to be work done to build the engine for darwin-x64, darwin-arm64 and lipo them together. Isn't that the whole purpose of not having separate TargetPlatform.darwin_x64
and .darwin_arm64
?
Somehow this is done for iOS, why can't it be done for macOS? (plus flutter_tester, font-subset and gen_snapshot).
CachedArtifacts
doesn't know about DarwinArchs
so I don't quite see how it would choose the right folder if you want to distribute darwin-arm64 build separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could certainly do that work, but there is no point in changing the cache structure in the tool before that is done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't assume this would happen before having universal artifacts. There's no point in doing that. I'll clarify that in the TODO comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quasi related for distribution but I suggested combining the macOS framework into the iOS Flutter.xcframework #70413 though considering how unfortunately different the two platform projects look, and how manual it was to get the right framework slice out of the iOS xcframework, I'm not now sure if that will be very valuable. In any case, we should distribute a universal macOS framework. But no one has worked on that yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I have no clue how flutter builds work on server side so I'm not sure I can help with that :) However with recent changes landed in buildroot and engine it is now possible to cross compile flutter for darwin-arm64. But it requires manually editing args.gn
. I think the next step would be to add darwin cross compilation to flutter/tools/gn
. I'll open an issue for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if LG to @jmagman
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @knopp!
@knopp @jonahwilliams @jmagman I'm having a bit of trouble following the discussion and determining what the missing pieces are. This PR seems to be making some assumptions about how the arm64 artifacts will be supplied and consumed. Can someone ELI5 what those are for me? (e.g. libflutter.so) |
So IIRC the idea was that we'd change how we were handling architecture - instead of having platform + arch in one enum this changes macos to be more like ios where the platform and arch are separate flags. I don't remember if any additional work was done to support arm64 builds. |
Exactly, instead of macOS platform being specified @zanderso I can do the outstanding in the tool to stop using Rosetta once there's an arm FlutterMacOS.framework, if that's what you're exploring. I already had to do it for iOS, and it'll be easier with macOS since it's the same artifact paths, but with an extra architecture lipo'd in. |
This is similar to how iOS work. Flutter tool can produce fat binaries for
|
Actually, it can be both x86_64 and arm64. Tool should build snapshot for all architectures and then lipo them together. |
How about |
Yes, I meant the targeted platform can be described as darwin+x86_64 or darwin+arm64. |
If the same |
Why couldn't |
#81205
This can be used to specify target architectures and produce fat binaries.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.