Skip to content

ci: cross-compile osx-x64 CLI archive on Apple Silicon runner#18190

Open
radical wants to merge 1 commit into
microsoft:mainfrom
radical:radical/cross-compile-cli-osx-x64-on-arm64
Open

ci: cross-compile osx-x64 CLI archive on Apple Silicon runner#18190
radical wants to merge 1 commit into
microsoft:mainfrom
radical:radical/cross-compile-cli-osx-x64-on-arm64

Conversation

@radical

@radical radical commented Jun 13, 2026

Copy link
Copy Markdown
Member

Description

The Build native CLI archive (macOS x64) job is the long pole of the CLI build matrix on PRs — ~18m vs ~8m for the equivalent osx-arm64 job.

Root cause: it ran on the macos-15-intel runner. The dominant cost is Native AOT codegen; the BuildCli.binlog from run 27448293173 shows IlcCompile ~327s, CoreCompile ~193s, LinkNative ~84s. The Intel runner is ~2.5x slower per core than Apple Silicon, so every step pays that tax.

The fix: build osx-x64 on the arm64 macos-latest runner, cross-compiling the x64 archive. Native AOT officially supports arm64 → osx-x64 cross-compilation (.NET 8+); no project changes are needed — the SDK resolves the osx-x64 NativeAOT runtime package and clang targets x86_64-apple-macos automatically.

Why this is safe: the reusable build workflow (build-cli-native-archives.yml) only packages and structurally verifies the archive (verify-cli-tool-nupkg.ps1 / verify-cli-npm-package.ps1 check the binary's presence in the nupkg/npm package, never run it). The x64 binary is never executed, so running x64 on arm64 hardware is never attempted. This mirrors the AzDO release pipeline, which already builds osx-x64 on an arm64 mac agent (eng/pipelines/templates/build_sign_native.yml), gating only its execute-verify step by agent arch.

Validation: cross-compile was reproduced locally on Apple Silicon — dotnet publish -r osx-x64 -p:PublishAot=true produced a real Mach-O 64-bit executable x86_64 (confirmed with file / lipo -archs). This PR's own macos-latest run is the end-to-end proof on GitHub-hosted hardware.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No

The "Build native CLI archive (macOS x64)" job ran on the macos-15-intel
runner, where Native AOT codegen (IlcCompile) dominates wall time. The
Intel runner is ~2.5x slower per core than Apple Silicon, making this job
the long pole of the CLI build matrix: ~18m vs ~8m for the osx-arm64 job
on macos-latest.

Build osx-x64 on the arm64 macos-latest runner instead, cross-compiling
the x64 archive. Native AOT officially supports arm64 -> osx-x64
cross-compilation (.NET 8+), and the reusable build workflow only packages
and structurally verifies the archive (verify-cli-tool-nupkg.ps1 /
verify-cli-npm-package.ps1) -- it never executes the x64 binary, so
x64-on-arm64 execution is never attempted. This mirrors the AzDO release
pipeline, which already builds osx-x64 on an arm64 mac agent
(eng/pipelines/templates/build_sign_native.yml).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 13, 2026 01:13
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18190

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18190"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR speeds up the macOS x64 CLI build job in GitHub Actions by cross-compiling on an Apple Silicon (macos-latest) runner instead of the slower Intel (macos-15-intel) runner, leveraging .NET Native AOT's official arm64→x64 cross-compilation support.

Changes:

  • Switches the build_cli_archive_macos_x64 job's runner from macos-15-intel to macos-latest (Apple Silicon) for cross-compilation
  • Adds an informative comment explaining the rationale, safety guarantees, and precedent from the AzDO release pipeline

@radical radical marked this pull request as ready for review June 13, 2026 01:24
@radical radical added the area-engineering-systems infrastructure helix infra engineering repo stuff label Jun 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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

Labels

area-engineering-systems infrastructure helix infra engineering repo stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants