Skip to content

[Windows Arm64] Allow cross compilation using --target-platform option #129808

Description

@loic-sharma

Background

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

Once #129807 lands, flutter build windows will always use the host architecture as the target architecture. In other words, Flutter on an Arm64 machine is unable to create AMD64 executables.

Work

Add a --target-platform option to flutter build windows to allow changing the target architecture.

Using the --target-platform option should produce an error on the "beta" and "stable" release channels.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-windowsBuilding on or for Windows specifically
    P3Issues that are less important to the Flutter project
    on Jun 30, 2023
  2. added
    team-windowsOwned by the Windows platform team
    and removed on Jun 6, 2024
  3. 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.

  4. krll-kov commented on Sep 30, 2024

    @krll-kov
    Contributor

    Are there any news/timeline on this? A lot of Windows arm laptops were released this summer, mac devs can use windows arm with parallels but it's still impossible to build x64 flutter app from an arm windows environment

  5. krll-kov commented on Nov 18, 2024

    @krll-kov
    Contributor

    If anybody wonders, you can actually build a x64 flutter app on ARM mac with Parallels by installing the ARM Windows 11.

    When you open your project, go to windows/flutter/CMakeLists.txt file and change this

    # Set fallback configurations for older versions of the flutter tool.
    if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
      set(FLUTTER_TARGET_PLATFORM "windows-x64")
    endif()
    

    to this (basically comment the check to force x64 builds)

    # Set fallback configurations for older versions of the flutter tool.
    # if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
      set(FLUTTER_TARGET_PLATFORM "windows-x64")
    # endif()
    

    After this change apps build normally as you've built them on a default x64 machine and can be launched on any x64 pc without problems. Tested with latest m4 mac.

    (But do not forget that flutter apps require you to copy msvcp140.dll, vcruntime140.dll and vcruntime140_1.dll files into your build folder, YOU MUST NOT copy them from the ARM' Windows/System32 folder since those are ARM64X dlls with hybrid PE headers and are not meant to be used on old x64 pcs so you have to copy them from your x64 windows machine!)

    image image
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-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