Skip to content

fix(flutter): fetch the arm64 macOS archive on Apple Silicon hosts - #9

Merged
SpencerC merged 2 commits into
SpencerC:mainfrom
TeddyHarnat:fix/macos-arm64-archive
Aug 27, 2026
Merged

fix(flutter): fetch the arm64 macOS archive on Apple Silicon hosts#9
SpencerC merged 2 commits into
SpencerC:mainfrom
TeddyHarnat:fix/macos-arm64-archive

Conversation

@TeddyHarnat

Copy link
Copy Markdown
Contributor

Problem

The macOS SDK repository always downloads the x64 release archive
(flutter_macos_<version>-stable.zip). Its Dart binaries are x86_64, so on an
Apple Silicon host without Rosetta 2 every fetch fails during the warm-up steps
with:

flutter/bin/cache/dart-sdk/bin/dart: Bad CPU type in executable

making the toolchain unusable on such machines (Rosetta 2 is not installed by
default, and installing it requires admin rights).

Fix

Select the archive variant by host architecture in _flutter_repo_impl: on
aarch64/arm64 macOS the repository fetches
flutter_macos_arm64_<version>-stable.zip. The URL's directory component stays
macos; only the file name carries the variant, matching how Flutter publishes
its releases.

Integrity is resolved against the variant actually fetched:

  • scripts/update_flutter_versions.sh now extracts both macOS hashes from the
    release metadata, and the regenerated versions.bzl records a
    macos_arm64 SRI for every version that publishes one. (The refresh also
    picked up the stable releases published since the last run, 3.44.6–3.47.1.)
  • The flutter.toolchain(integrity = {...}) escape hatch accepts a
    "macos_arm64" key, carried into the repository rule by a new
    integrity_arm64 attribute — backward compatible with existing callers.

Docs (docs/extensions.md via //docs:update) and CHANGELOG updated; the
lockfile changes are the resolved extension's new attribute and bzl digest.

Verification

On an arm64 Mac without Rosetta 2 (the previously broken scenario):

  • bazel test //... — 14/14 pass
  • examples/hello_world: bazel test --override_module=rules_flutter=<tree> //...
    builds and the widget test passes; the fetched dart-sdk binaries are
    Mach-O 64-bit executable arm64
  • The generated 3.38.4 macos_arm64 SRI matches a hash computed independently
    from a separately downloaded copy of the archive
  • buildifier check clean

🤖 Generated with Claude Code

The macOS SDK repository always downloaded the x64 release archive
(flutter_macos_<version>-stable.zip). Its Dart binaries are x86_64, so on
an Apple Silicon host without Rosetta 2 every fetch-time warm-up fails
with 'Bad CPU type in executable' and the toolchain is unusable.

Select the archive variant by host architecture: on aarch64/arm64 macOS
the repository fetches flutter_macos_arm64_<version>-stable.zip (the
directory component stays 'macos'; only the file name carries the
variant). Integrity is resolved against the variant actually fetched:
the generated version table now records a 'macos_arm64' SRI for every
version that publishes one, the flutter.toolchain integrity escape hatch
accepts a 'macos_arm64' key, and flutter_repositories grew a matching
integrity_arm64 attribute.

update_flutter_versions.sh extracts both macOS hashes from the release
metadata; regenerating the table also picked up the stable releases
published since the last refresh (3.44.6 through 3.47.1).

Verified on an arm64 Mac without Rosetta 2: examples/hello_world builds
and its widget test passes against the working tree, with the fetched
dart-sdk binaries confirmed Mach-O arm64; //... passes (14 tests).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TeddyHarnat
TeddyHarnat requested a review from SpencerC as a code owner August 26, 2026 17:23
@SpencerC
SpencerC merged commit 8f60ab4 into SpencerC:main Aug 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants