8000 [Windows] ☂️ Add support for Arm64 as a target · Issue #62597 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Windows] ☂️ Add support for Arm64 as a target #62597

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

Open
7 of 17 tasks
stuartmorgan-g opened this issue Jul 30, 2020 · 23 comments
Open
7 of 17 tasks

[Windows] ☂️ Add support for Arm64 as a target #62597

stuartmorgan-g opened this issue Jul 30, 2020 · 23 comments
Labels
a: desktop Running on desktop c: new feature Nothing broken; request for a new capability engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project platform-target-arm Targeting an ARM-based platform platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team triaged-windows Triaged by the Windows platform team

Comments

@stuartmorgan-g
Copy link
Contributor
stuartmorgan-g commented Jul 30, 2020

#53120 tracks supporting Windows arm64 as a development environment; this is for being able to build Flutter Windows applications that run on arm64.

This would require:

@stuartmorgan-g stuartmorgan-g added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine repository. See also e: labels. platform-windows Building on or for Windows specifically a: desktop Running on desktop P3 Issues that are less important to the Flutter project labels Jul 30, 2020
stuartmorgan-g added a commit to stuartmorgan-g/engine that referenced this issue Jul 30, 2020
- Rolls buildroot to pick up
  flutter/buildroot#389
- Adds support to the gn wrapper for setting the traget CPU on Windows

Attempting to generate Windows arm64 GN files will currently fail, due
to lack of arm64 support for an OpenGL test support target, but this
sets the foundation, and makes experimentation easier.

Part of flutter/flutter#62597
stuartmorgan-g added a commit to flutter/engine that referenced this issue Aug 4, 2020
- Rolls buildroot to pick up
  flutter/buildroot#389
- Adds support to the gn wrapper for setting the traget CPU on Windows

Attempting to generate Windows arm64 GN files will currently fail, due
to lack of arm64 support for an OpenGL test support target, but this
sets the foundation, and makes experimentation easier.

Part of flutter/flutter#62597
@TahaTesser TahaTesser added the platform-target-arm Targeting an ARM-based platform label Oct 6, 2021
@azchohfi
Copy link

@stuartmorgan it seems like dart-lang/sdk#47824 was merged, so this is mostly technically unblocked? I do have a Surface Pro X, which is Arm64, so I want to help.

@stuartmorgan-g
Copy link
Contributor Author

Interesting, I didn't realize that was on the Dart team's radar.

I played around with this quite a while ago and got a PoC of the Dart part compiling, but then ran into the issue that it would require cross-building support, or for the entire compilation of the Flutter engine to be on aarm64 (bullet point #2). Does cross-compilation work at the Dart level (i.e., can Dart AOT compilation be done for arm64, but from an x64 machine)?

If not you could experiment with getting flutter/engine building on arm64, but getting from there to flutter tool support would require CI arm64 machines; I don't know if there's a good option for that available.

(/cc @cbracken )

@azchohfi
Copy link

Doesn't seem like cross compilation is a thing yet (dart-lang/sdk#28617). I can try to start things on my Surface Pro X, but that seems challenging. I'll see how far I can get.
There are Azure machines that support Arm64, so maybe that is one solution, but not sure how the Flutter team would be able to leverage those.

@cbracken
Copy link
Member
cbracken commented May 26, 2022

Aside from the compilation of the C++ bits, there's also gen_snapshot and the Dart compilation. Today we can generate a gen_snapshot binary that runs on x64 host and targets arm64, but it is not currently possible (without a significant amount of work from the Dart team) to build a gen_snapshot binary that runs on arm64 and targets x64 because there is no simx64 support in the Dart SDK.

On macOS, this isn't a huge problem since we can run x64 code on arm64 macs via Rosetta. It looks like this may be possible on Windows 11 and later. It also looks like there was a preview release for Windows 10 based on this Windows blog post but it's unclear if a final version will be available.

@stuartmorgan-g
Copy link
Contributor Author

Today we can generate a gen_snapshot binary that runs on x64 host and targets arm64

Nice! Given the current distribution of machines, that's the most important thing for us to have to get something working end-to-end.

@azchohfi azchohfi changed the title Add support for Windows ARM64 as a target Add support for Windows Arm64 as a target May 26, 2022
@azchohfi
Copy link

@cbracken I believe we should look at these issues as separate issues.
This specific issue is tracking building Flutter apps that target Windows 10 and 11 on Arm64. Maybe we can create a cross compiling issue to track making a host Arm64 target x64 binaries.
Also, Windows 10 Arm64 will not support x64 emulation. That feature is exclusive to Windows 11 on Arm64, so we can't fully rely on the emulation to have coverage of Arm64. Energy consumption is also always in mind when any kind of emulation is used, so natively supporting Arm64 would provide a better battery life.

The way I see it, we have two options to unblock Arm64 Flutter apps on Windows 10/11:

  1. Work to enable cross compilation on x64 hardware. If the compilation is on an Intel x64 machine, that would require cross compiling to Arm64 (which doesn't have a specific issue tracked by Flutter, but does have one from the Dart SDK, Allow AOT executables to be cross-compiled dart-lang/sdk#28617, which would be a very first step in getting this to reality).
  2. Work to enable all the tooling to work on an Arm64 host machine. If the compilation is happening on an Arm64 machine, then it would require work to enable all the flutter tools to works on Arm64 hosts, but there wouldn't be any cross-compilation effort required here.

Since cross compilation seems like a harder subject to tackle, and since Arm64 hardware on the cloud is starting to be a reality (e.g. Azure already has a public preview of Arm64 VMs), working with option number 2 seems like a better approach. This would unblock developers to build their Flutter apps for Windows 10 Arm64 + Windows 11 Arm64, as well as enabling them to use Arm64 hosts to build their apps locally, with the same great developer tools that work today on Intel x64, with minimal focus on cross compilation.

Does that seem reasonable?

If so, would you be willing to help me drill this down a bit into actionable things to do? I would love to see this become a reality, specially since Microsoft announced Project Volterra.

@stuartmorgan-g
Copy link
Contributor Author

Also, Windows 10 Arm64 will not support x64 emulation. That feature is exclusive to Windows 11 on Arm64, so we can't fully rely on the emulation to have coverage of Arm64. Energy consumption is also always in mind when any kind of emulation is used, so natively supporting Arm64 would provide a better battery life.

gen_snapshot is only used during the build, so the emulation here (and associated restrictions) would only apply to developers at app creation time.

The first goal though would be to get the engine cross-compiling (x64->arm64), or compiling natively on arm64, or both. (And if only the later, a CI solution for creating engine artifacts). Without that we can't do anything at the tool level.

@cbracken
Copy link
Member
cbracken commented May 26, 2022

Correct. The minimum set of steps required to be able to develop Flutter apps that target Windows arm64 devices from an x64 host machine is something like (I'm sure I'm missing a pile of items):

  • Enable building x64 host binaries:
    • x64 build of gen_snapshot_arm64 (host arch: x64, target arch: arm64)
  • Enable building arm64 target binaries for Windows:
    • flutter_engine.dll
    • flutter_windows.dll
    • libtessellator.dll (required?)
  • Update flutter/recipes to build and upload new artifacts for use by the flutter tool. We should probably rename gen_snapshot to gen_snapshot_x64 as part of this, but we'll need to preserve the old binary until the change rolls to the framework and the tool can be updated to use the binary with the new name.
  • Update the gen_snapshot artifact resolution code in the tool to resolve the appropriate gen_snapshot_$ARCH depending on target architecture.
  • Update the tool to support specifying a target architecture for Windows app builds.
  • Update the Windows app/plugin templates in the tool to support arm64.

The following would be necessary to upgrade Windows ARM64 from a "best-effort" platform to a "google-tested" platform:

  • Update build framework CI with any updates necessary to build/execute these tests, benchmarks on arm64 devices.
  • Create any CIPD packages required for arm64 Windows CI tests.
  • Add arm64 Windows hardware to our infra pool.
  • Add arm64 Windows images to our infra.
  • Enable running integration tests, benchmarks on arm64 pool.
  • Document the development and deployment workflow on the website.

@citrus77
Copy link
citrus77 commented Jun 15, 2022

I'm late to this party and I don't know much about compiling for different architectures, but I have Visual Studio 2022 for ARM64, and Flutter installed on my Surface Pro X, and was able to build for x64. While most devs are probably building on a x64 host, maybe you can provide support faster by targeting an ARM64 host? Especially since Microsoft is set to release that fancy new ARM64 dev box soon.

@azchohfi
Copy link

Yes, targeting an ARM64 host is probably an easier path forward. Visual Studio 2022 17.3 Preview 2+ runs as an ARM64 process on WIndows 11, and the toolchain should follow, so this is the least resistance path.
The Desktop development with C++ is exactly the type of app that is already supported, so Flutter fits perfectly here.
https://devblogs.microsoft.com/visualstudio/arm64-visual-studio/

@pbo-linaro
Copy link
Contributor

Hello, I've been able to compile a native flutter app for arm64 (native build, no cross compilation). This is documented on Linaro's Windows on Arm wiki.

However, I needed to hack through flutter build scripts (see details here). The goal is to upstream all that, starting first with dart-sdk.

Just wanted to say there does not seem to be any blocking issue for native build. Cross compilation will be next target.

@citrus77
Copy link

Great news!

@mohitmundhragithub
Copy link

From which version will we have the support ready?

@cbracken cbracken added team-windows Owned by the Windows platform team and removed team-desktop labels Jun 6, 2024
@flutter-triage-bot
Copy link

The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop c: new feature Nothing broken; request for a new capability engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project platform-target-arm Targeting an ARM-based platform platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team triaged-windows Triaged by the Windows platform team
Projects
None yet
Development

No branches or pull requests

10 participants
0