Skip to content

[Windows Arm64] Update tool to target Arm64 on Arm64 hosts #129807

Description

@loic-sharma

Background

See: https://flutter.dev/go/windows-arm64

Once #129805 lands, Arm64 hosts will be able to build x64 executables. These executables run using x64 emulation.

Solution

  1. Add Windows Arm64 to the HostPlatform and TargetPlatform enums
  2. Update the Flutter Windows plugin templates to show how to use the target architecture to bundle pre-built libraries
  3. If on Arm64 host and the "beta" or "stable" release channels, produce a warning that an x64 executable will be built.
  4. If on Arm64 host and the "master" release channel,
    1. Use Abi.current() to determine the target architecture
    2. Download Windows Arm64 artifacts
  5. Update Windows Arm64 devicelab tests: build, run, benchmark

Activity

  1. added
    platform-windowsBuilding on or for Windows specifically
    P3Issues that are less important to the Flutter project
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Jun 30, 2023
  2. changed the title [-][Windows Arm64] Update tool to target Arm64 on Arm64 machines[/-] [+][Windows Arm64] Update tool to target Arm64 on Arm64 hosts[/+] on Jun 30, 2023
  3. dcharkes commented on Sep 18, 2023

    @dcharkes
    Contributor

    @loic-sharma Please give me a ping when you want to land this, so that we can ensure the native assets support added in #134203 works for Windows arm64 as well. (Or if you land it earlier than that PR, I'll give you a ping on how to test the native assets on Arm64 Windows.)

  4. loic-sharma commented on Sep 19, 2023

    @loic-sharma
    MemberAuthor

    @pbo-linaro is the contributor working on adding Windows Arm64 support.

    @dcharkes It looks like the native assets support added by #134203 works already on Windows Arm64 machines thanks to x64 emulation. FYI we're still working on running tests on Windows Arm64 machines, your new tests won't run on Arm64 machines yet.

    @pbo-linaro, Daco is working on adding "native assets", which is a new way to support native code in pub packages. From my understanding, this will be an alternative to Flutter's existing support for native plugins. The package author creates a build.dart file that uses the user's installed compilers to compile the native assets. For more information, see:

    In #134203, Daco enabled the Flutter Windows build to use native assets using the x64 MSVC toolchain. To enable targeting Arm64, we will need to update the logic added by #134203 to use the correct MSVC toolchain depending on the host/target.

    (Daco feel free to correct any details I may have gotten wrong!)

  5. p-b-o commented on Oct 25, 2023

    @p-b-o
    Contributor

    Hi, I'm currently working on windows-arm64 support and managed to get native (x64, arm64) and cross compilation (x64 -> arm64 and arm64 -> x64) of flutter apps to work on my local branch.

    One issue I'm investigating now is support for native_assets, where it fails because cl compiler can't be identified for arm64 architecture. After digging into this, I reached this native_toolchain_c/lib/src/native_toolchain/msvc.dart, and found that support need to be done here.

    I don't think flutter project will accept a windows-arm64 enablement without native assets, so it would be nice if we could fix this together @dcharkes. Once native repository has correct support, I should be able to do the rest on flutter side.

    @loic-sharma: Do you see native assets as something mandatory for first enablement?
    @dcharkes: Do you think anything more beyond toolchain detection has to be done to support new windows-arm64 platform?

    Thanks,
    Pierrick

  6. dcharkes commented on Oct 25, 2023

    @dcharkes
    Contributor

    Hi, I'm currently working on windows-arm64 support and managed to get native (x64, arm64) and cross compilation (x64 -> arm64 and arm64 -> x64) of flutter apps to work on my local branch.

    🎉

    One issue I'm investigating now is support for native_assets, where it fails because cl compiler can't be identified for arm64 architecture. After digging into this, I reached this native_toolchain_c/lib/src/native_toolchain/msvc.dart, and found that support need to be done here.

    Yep, that sounds correct!

    I don't think flutter project will accept a windows-arm64 enablement without native assets, so it would be nice if we could fix this together @dcharkes. Once native repository has correct support, I should be able to do the rest on flutter side.

    Yes, please feel free to create PRs to the dart-lang/native repo to do toolchain detection. ❤️
    I don't have access to an arm64 win machine myself. Neither do the GitHub actions have support for Windows arm64 as far as I know.
    You should be able to have your local copy of the dart-lang/native packages and use a path dependency in the pubspec.yaml of flutter_tools to test your changes directly from flutter tools.

    @dcharkes: Do you think anything more beyond toolchain detection has to be done to support new windows-arm64 platform?

    I'm not aware of anything. The Abi.windowsArm64 is already in dart:ffi, and @rmacnak-google has been fixing corner cases recently. (There are some remaining corner cases: dart-lang/sdk#53829. If you run into a crash when doing an FFI call please give us a ping. But these are relatively uncommon cases: e.g. structs by value with specific struct sizes. This shouldn't stop you with implementing support for native assets for Windows arm64, as most tests just pass integer values.)

  7. p-b-o commented on Oct 25, 2023

    @p-b-o
    Contributor

    Thanks for your reactive answer!

    The advice about using a path in pubspec.yaml is what I was missing to try this locally, that should help.
    I'll propose a PR to add support in native then.

  8. added
    team-windowsOwned by the Windows platform team
    and removed on Jun 6, 2024
  9. flutter-triage-bot commented on Jun 6, 2024

    @flutter-triage-bot

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

  10. stuartmorgan-g commented on Apr 1, 2026

    @stuartmorgan-g
    Contributor

    Was this supposed to be closed when #141930 landed? If not, what's the current status/next steps?

  11. talynone commented on Sep 28, 2026

    @talynone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopplatform-host-armBuilding on an ARM-based platformplatform-target-armTargeting an ARM-based platformplatform-windowsBuilding on or for Windows specificallyteam-windowsOwned by the Windows platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-windowsTriaged by the Windows platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions