Skip to content
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

Support --local-engine when for single CPU architecture AOT builds on macOS #100804

Closed
jason-simmons opened this issue Mar 25, 2022 · 10 comments
Closed
Assignees
Labels
a: build Building flutter applications with the tool platform-mac Building on or for macOS specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@jason-simmons
Copy link
Member

I'm seeing errors when I run flutter run --local-engine host_profile --profile on a Mac x64 host using the current engine and flutter_tools.

flutter_tools reports that it can't find gen_snapshot_x64 or gen_snapshot_arm64 and that the FlutterMacOS.framework binaries are x64 only.

This is related to some of the recent flutter_tools changes for enabling ARM64 support (a618ca2, fd3c34c)

@jmagman @cbracken

@jason-simmons jason-simmons added tool Affects the "flutter" command-line tool. See also t: labels. a: build Building flutter applications with the tool labels Mar 25, 2022
@jmagman
Copy link
Member

jmagman commented Mar 25, 2022

@cbracken looks like macOS needs to be audited for local engine single-architecture issues.

if (!useMacOSConfig) {
String arch;
if (localEngineName.endsWith('_arm')) {
arch = 'armv7';
} else if (localEngineName.contains('_arm64')) {
arch = 'arm64';
} else if (localEngineName.contains('_sim')) {
arch = 'x86_64';
} else {
arch = 'arm64';
}
xcodeBuildSettings.add('ARCHS=$arch');
}

@jmagman
Copy link
Member

jmagman commented Mar 26, 2022

-dDarwinArchs shouldn't hard-coded, it should come from ARCHS

"-dDarwinArchs=x86_64 arm64"

- "-dDarwinArchs=x86_64 arm64" 
+ "-dDarwinArchs=${ARCHS}"

like this:

'-dIosArchs=${environment['ARCHS'] ?? ''}',

@jmagman
Copy link
Member

jmagman commented Mar 26, 2022

Jason's logs also show:

[        ] [   +2 ms] Target compile_macos_framework failed: ProcessException: Failed to find "path/to/engine/src/out/host_profile/./gen_snapshot_x64" in the search path.

out/host_profile/gen_snapshot_x64 does not exist, but out/host_profile/gen_snapshot does. Either need to generate as gen_snapshot_x64 in this case, or update the tool to handle the missing _x64 in a local engine.

@jmagman jmagman added the platform-mac Building on or for macOS specifically label Mar 26, 2022
@jmagman jmagman added this to Awaiting triage in Tools - engine support review via automation Mar 26, 2022
@jmagman jmagman moved this from Awaiting triage to Engineer reviewed in Tools - engine support review Mar 26, 2022
@jmagman
Copy link
Member

jmagman commented Mar 26, 2022

"-dDarwinArchs=x86_64 arm64" 

is also incorrect since it shouldn't build both in debug mode.

@jmagman
Copy link
Member

jmagman commented Mar 29, 2022

#100811 and #100917 have merged. The last piece is to fix the gen_snapshot_x64 vs gen_snapshot.
So if you hit this issue on x64, the workaround for now is to symlink out/host_<variant>/gen_snapshot to out/host_<variant>/gen_snapshot_x64.

@cbracken
Copy link
Member

I'll patch that bit in the engine build rather than in the tool, as we do for iOS.

@cbracken cbracken self-assigned this Mar 29, 2022
cbracken added a commit to cbracken/flutter_engine that referenced this issue Mar 29, 2022
Moves //flutter/build/archives:create_macos_gen_snapshots target to
//flutter/lib/snapshot:create_macos_gen_snapshots and make it part of
the :generate_bin_snapshots target in that BUILD.gn file. This makes it
part of the default build.

When performing a Flutter build using the --local-engine option, the
flutter tool looks for the architecture-specific gen_snapshot name, as
it does with iOS builds. As such, we should be building the
architecture-specific gen_snapshot binary as part of the default build
for the given architecture.

Issue: flutter/flutter#100804
@cbracken
Copy link
Member

cbracken commented Mar 29, 2022

Patch is out at flutter/engine#32326.

That said, it's important to note that the correct local engine to point to for macOS builds is a local engine built with --mac flag; e.g. mac_release_unopt_arm64 etc. Host builds will likely work for x64 targets, but not currently for arm64, where an x64 gen_snapshot is built instead, since in host builds the target is the host.

FWIW it should work fine if you're building on and targeting x64, but I could imagine us tightening things up one day, so we should probably encourage people to use a Mac target build.

@jmagman
Copy link
Member

jmagman commented Mar 29, 2022

That said, it's important to note that the correct local engine to point to for macOS builds is a local engine built with --mac flag; e.g. mac_release_unopt_arm64 etc. Host builds will likely work for x64 targets, but not currently for arm64, where an x64 gen_snapshot is built instead, since in host builds the target is the host.

@cbracken can you update https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-macos-or-linux to make that clear?

@cbracken
Copy link
Member

Will do. To be clear, flutter/engine#32326 will get things working with a host build (as well as target builds) right now, but long-term I could imagine things diverging enough that it's no longer the case.

@cbracken cbracken added this to To do in macOS Desktop Stable via automation Mar 30, 2022
@cbracken cbracken moved this from To do to Done in macOS Desktop Stable Mar 30, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: build Building flutter applications with the tool platform-mac Building on or for macOS specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Status: Done
Tools - engine support review
  
Engineer reviewed
Development

No branches or pull requests

3 participants