feat(flutter): add a linux_arm64 toolchain - #5
Draft
pawelchcki wants to merge 1 commit into
Draft
Conversation
Flutter publishes no linux-arm64 SDK tarball, so `linux` is registered as x86_64-only and there is no way to build on arm64 Linux -- increasingly common on CI (AWS CodeBuild arm images, Ampere runners) and on developer machines. Flutter does publish the architecture-specific pieces per engine revision: dart-sdk-linux-arm64.zip and linux-arm64/artifacts.zip (flutter_tester, gen_snapshot, impellerc). Only bin/cache holds native code -- the framework sources, the flutter_tools kernel snapshot and the templates in the x64 archive are architecture-independent. So linux_arm64 downloads the x64 release archive, deletes the native pieces of bin/cache along with the stamps that mark them current, and lets the existing fetch-time precache refetch them for the host: the launcher's update_dart_sdk.sh selects the Dart SDK by `uname -m`, and flutter_tools resolves engine artifacts through its own host-platform detection. This is the same bootstrap path a plain `git clone` of the SDK takes on arm64. Consequences worth reviewing: - The linux_arm64 repository can only be *fetched* on an arm64 Linux host, since completing it runs the launcher. Bazel only fetches the host platform's SDK repository, so this is not a practical restriction, but it is enforced with an explicit error rather than a confusing failure later. - _verify_rearchitected fails at fetch time if the replacements did not appear, so a future release that stops refetching them as a side effect of precache surfaces here instead of as an exec-format error inside a build action. - _host_matches_platform is now architecture-aware, which would have silently disabled the `linux` artifact group on arm64 hosts. Artifact groups are named after operating systems, so they now route through a separate _host_is_os helper. The x64, macOS and Windows paths are unchanged: _archive_platform and _platform_arch are identity mappings for every platform except linux_arm64. Tested on x86_64 (no regression: a full web build, test suite and analyze run of a real app all pass). The arm64 path has been verified against the published artifact URLs but not yet run end to end on arm64 hardware -- hence the draft.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PLATFORMSregisterslinuxas x86_64-only, so there is no way to build on arm64 Linux. That is increasingly common on CI (AWS CodeBuild arm images, Ampere/Graviton runners) and on developer machines.The blocker is real but narrower than it looks: Flutter publishes no linux-arm64 SDK tarball, so there is no archive to point a new platform at.
What Flutter does publish
The architecture-specific pieces exist, per engine revision:
And only
bin/cacheholds native code — the framework sources, theflutter_toolskernel snapshot (a JIT snapshot, so portable) and the templates in the x64 archive are architecture-independent.Approach
linux_arm64downloads the x64 release archive, deletes the native pieces ofbin/cachealong with the stamps that mark them current, and lets the existing fetch-time precache refetch them for the host:update_dart_sdk.shselects the Dart SDK byuname -mflutter_toolsresolves engine artifacts through its own host-platform detectionThis is the same bootstrap path a plain
git cloneof the SDK takes on arm64, which is how people run Flutter on arm64 Linux today.Points worth reviewing
Fetch is host-restricted. Completing the
linux_arm64repository runs the launcher, so it can only be fetched on an arm64 Linux host. Bazel only fetches the host platform's SDK repository, so this is not a practical restriction — but it is enforced with an explicit error rather than a confusing failure later.Failure is loud, not silent.
_verify_rearchitectedchecks thatdart-sdk/bin/dartandlinux-arm64/flutter_testerexist after the precache. If a future release stops refetching them as a side effect ofprecache, it surfaces at fetch time with an actionable message instead of an exec-format error inside a build action.One latent trap fixed along the way. Making
_host_matches_platformarchitecture-aware would have silently disabled thelinuxartifact group on arm64 hosts, since_PRECACHE_GROUP_HOSTSvalues are OS names, not platform names. Those now route through a separate_host_is_oshelper.Existing platforms are untouched.
_archive_platformand_platform_archare identity mappings for everything exceptlinux_arm64, and_PRECACHE_SENTINELSonly gained an{arch}placeholder that substitutes tox64everywhere else.Testing
Verified on x86_64 that this is a no-op for the existing path: a full
flutter build web --release, an 8-shard test suite andflutter analyze --fatal-infosfor a real app all pass through the patched ruleset.The arm64 path is verified against the published artifact URLs (both return 200 for the pinned engine revision, and I confirmed
linux-arm64/artifacts.zipcontainsflutter_tester,gen_snapshotandimpellerc) but has not yet been run end to end on arm64 hardware — that is why this is a draft. I am wiring it into arm64 CI now and will report back with a real run before marking it ready.Would also like your view on whether
_ARCHIVE_ALIASESis the shape you want for this, or whether you would rather see an explicit per-platform archive/artifact descriptor.