Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make arm64 a first-class build host (auto-detect host arch)#11250

Open
dennisameling wants to merge 4 commits into
microsoft:mainmicrosoft/microsoft-ui-xaml:mainfrom
dennisameling:arm64-first-class-build-hostdennisameling/microsoft-ui-xaml:arm64-first-class-build-hostCopy head branch name to clipboard
Open

Make arm64 a first-class build host (auto-detect host arch)#11250
dennisameling wants to merge 4 commits into
microsoft:mainmicrosoft/microsoft-ui-xaml:mainfrom
dennisameling:arm64-first-class-build-hostdennisameling/microsoft-ui-xaml:arm64-first-class-build-hostCopy head branch name to clipboard

Conversation

@dennisameling

Copy link
Copy Markdown

Fixes

Fixes #11249

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Description

The build scripts hardcoded amd64 for the host toolchain, so on a native arm64 machine everything ran x64-emulated. This auto-detects the native host architecture and selects the matching native toolchain, falling back to amd64 for any host that is neither arm64 nor amd64 (x86, or a future arch such as RISC-V). Independent of the target architecture being built.

While arm64 devices can run x64 tools like cl.exe and MSBuild.exe under emulation, Visual Studio 2022 and later offers native arm64 versions of these build tools as well, which significantly speeds up the build process.

Current Behavior

The .\Build.cmd script always invokes amd64/x64 host tools, even on arm64 devices

New Behavior

The .\Build.cmd script auto-detects the host architecture and uses native arm64 build tools on arm64 devices, such as the Surface Pro X.

Customer Impact

Just build-related changes for users who want to contribute to this repository.

Regression Potential

  • Low risk — isolated change, limited scope
  • Medium risk — touches shared components or public APIs
  • High risk — architectural or breaking API change

How Has This Been Tested?

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • Existing tests pass locally

Also, here's a successful CI build on both an x64 and arm64 host: https://github.com/dennisameling/microsoft-ui-xaml/actions/runs/29587060879

Screenshots (if appropriate)

dennisameling and others added 4 commits July 17, 2026 14:20
The build scripts hardcoded amd64 for the *host* toolchain, so on a native
arm64 machine everything ran x64-emulated. Detect the native host architecture
and select the matching native toolchain, falling back to amd64 for any host
that is neither arm64 nor amd64 (x86, or a future arch such as RISC-V). This is
independent of the *target* architecture being built.

Host-toolchain selection (MSBuild, VsDevCmd host, VC compilers, Windows SDK
tools, PGO merge, .NET SDK):

- scripts/init/SetHostArch.cmd: new shared helper that sets _HostArch to
  amd64|arm64. Prefers the machine-level PROCESSOR_ARCHITECTURE from the
  registry (authoritative even from an emulated shell), then
  PROCESSOR_ARCHITEW6432, then PROCESSOR_ARCHITECTURE.
- init.cmd: use _HostArch for the MSBuild Bin paths and all three
  DevCmd -host_arch calls (was amd64).
- scripts/init/Initialize-InstallMSBuild.ps1, build/DownloadDotNetCoreSdk.ps1:
  detect host arch via RuntimeInformation.OSArchitecture. The in-repo .NET SDK
  is now installed native (arm64) on an arm64 host.
- scripts/init/SetMSBuildVars.cmd, src/XamlCompiler/runtests.cmd: use the shared
  helper.

PreferredToolArchitecture is host-aware in eng/sdkconfig.props,
controls/environment.props and controls/dev/dll/Microsoft.UI.Xaml.Common.props
(was hardcoded x64). This one property drives both the VC host compilers
(cl.exe/link.exe -> bin\Host<arch>) and the Windows SDK tools
(midlrt/mc/rc -> WindowsSdkToolLocation). arm64 on an arm64 host, else x64.

perf/pgo/Microsoft.WinUI.PGO.props: select pgomgr.exe (PGO profile merge) by
host arch. pgomgr /merge is target-agnostic (the repo already used the x64
pgomgr to merge ARM64 target data), so use the native arm64 pgomgr on an arm64
host; non-arm64 hosts keep the previous behavior exactly.

CI: .github/workflows/pr-build.yml gains an os matrix axis crossing
windows-2022 (x64) and windows-11-arm, so every flavor builds on both hosts for
toolchain parity. Artifact names are namespaced by host.

Validated on a Windows 11 arm64 machine: native arm64 MSBuild/cl/link/midlrt
build the dxaml core product and package the arm64 native runtime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The windows-11-arm GitHub runner image ships most VS components but lacks
VC.Runtimes.x86.x64.Spectre (and the version-pinned 14.44 Spectre variants),
so all six flavors fail with MSB8040 - even arm64 targets, because the codegen
tools (gencompheadersandidl, genmrtheadersandidl, manifest) compile as x86/x64.

Add a windows-11-arm-only step that applies the repo's .vsconfig via the VS
Installer before building, matching the toolchain the build expects.
windows-2022 already includes these components.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On an arm64 host, MSBuild (and the AnyCPU XamlCompiler.exe it launches) runs
arm64, so the XamlCompiler loads GenXbf.dll from the arm64 folder regardless of
the product target arch. BuildGenXbfForMSBuild only ever built x64 + the host
SDK-tools arch (x86 on arm64), so x86/x64-target builds on an arm64 host failed
with 'Cannot resolve GenXbf.dll under ...\GenXbf\arm64' (WMC0621). arm64-target
builds happened to work because they compile GenXbf as arm64 anyway.

Add an arm64 GenXbf reference gated on an arm64 host, mirroring the existing
always-x64 reference. Verified locally: an x64-target build on an arm64 host now
produces BuildOutput\bin\GenXbf\arm64\genxbf.dll.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Building the arm64 GenXbf.dll (added in the previous commit) links against the
arm64 Windows SDK (e.g. kernel32.lib from Microsoft.Windows.SDK.cpp.arm64).
PostInit only restored packages.arm64.config for arm64/arm64ec product targets,
so x86/x64-target builds on an arm64 host failed the GenXbf link with
LNK1181 'cannot open input file kernel32.lib'. Restore packages.arm64.config
whenever the build host is arm64, regardless of the product target.

Verified locally: an x86-target build on an arm64 host now builds the arm64
GenXbf.dll cleanly (0 errors) with the arm64 SDK present.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dennisameling
dennisameling requested a review from a team as a code owner July 17, 2026 15:37
@dennisameling dennisameling changed the title Make arm64 a first-class build host (auto-detect host arch)Arm64 first class build host Make arm64 a first-class build host (auto-detect host arch) Jul 17, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the needs-triage Issue needs to be triaged by the area owners label Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Issue needs to be triaged by the area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: make Windows arm64 a first-class build host

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.