Skip to content

Run XamlCompiler.exe as ARM64-native on Windows on ARM - #11247

Open
dennisameling wants to merge 1 commit into
microsoft:mainfrom
dennisameling:fix/xamlcompiler-arm64-native-manifest
Open

Run XamlCompiler.exe as ARM64-native on Windows on ARM#11247
dennisameling wants to merge 1 commit into
microsoft:mainfrom
dennisameling:fix/xamlcompiler-arm64-native-manifest

Conversation

@dennisameling

Copy link
Copy Markdown

Fixes #11237

Problem

XamlCompiler.exe is an AnyCPU / IL-only .NET Framework executable. On Windows on ARM, AnyCPU IL-only images launch under x64 emulation by default. Since the XAML compiler dominates WinUI build time, this emulation tax makes ARM64 builds much slower than they need to be. Issue #11237 measured the compiler at ~76% of build time, and forcing it ARM64-native via a per-machine registry hack gave a ~3.4× compiler speedup.

Fix

Declare the native architectures the compiler supports via an application manifest, and reference it from the project:

  • New src/XamlCompiler/Exe/XamlCompiler.manifest with:
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2024/WindowsSettings">
      <supportedArchitectures>amd64 arm64</supportedArchitectures>
    </asmv3:windowsSettings>
  • Microsoft.UI.Xaml.Markup.Compiler.Executable.csproj: <ApplicationManifest>XamlCompiler.manifest</ApplicationManifest>

On Windows 11, version 24H2 and later, the loader then launches the compiler ARM64-native instead of x64-emulated — no per-machine Image File Execution Options PreferredMachine registry workaround needed. This was the approach suggested by @driver1998 in the issue.

See the supportedArchitectures documentation.

Verification

Measured on the actual shipped XamlCompiler.exe (from the microsoft.windowsappsdk.winui package — PE32 / ILONLY / AnyCPU) on Windows 11 ARM64 (build 26200). Architecture read at image-load time via GetProcessInformation(ProcessMachineTypeInfo) from an ARM64-native parent process (representing the ARM64 build host):

Binary Launch architecture
XamlCompiler.exe as shipped (no supportedArchitectures) x64 EMULATED
Same binary with this manifest injected ARM64 NATIVE

Notes:

XamlCompiler.exe is an AnyCPU / IL-only .NET Framework executable, so on
Windows on ARM it launches under x64 emulation by default. Because the XAML
compiler dominates WinUI build time, this emulation tax makes ARM64 builds
substantially slower than they need to be (see microsoft#11237).

Add an application manifest that declares supportedArchitectures
"amd64 arm64" and reference it from the project via <ApplicationManifest>.
On Windows 11, version 24H2 and later, this lets the loader launch the
compiler ARM64-native instead of x64-emulated, without the per-machine
Image File Execution Options PreferredMachine registry workaround.

Verified on the shipped XamlCompiler.exe binary on Windows 11 ARM64
(measured at image load via GetProcessInformation from an ARM64-native
parent): as shipped it launches x64-emulated; with this manifest it
launches ARM64-native.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@driver1998

Copy link
Copy Markdown

MSBuild has a builtin flag named PreferNativeArm64 that does just this:

dotnet/msbuild#10060

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.

XamlCompiler.exe is a .NET Framework AnyCPU binary and runs under x64 emulation on Windows on ARM, dominating WinUI build time

2 participants