rust-lang / rust-lang/rust

ARM64EC static libraries fail when linked into ARM64X DLLs

Open
#145,154 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage C-bug O-arm64ec-pc-windows-msvc O-x86_64
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

Rust-generated ARM64EC static libraries cause crashes (0xc0000096 - privileged instruction) when statically linked into ARM64X DLLs and loaded by x64 processes on ARM64 Windows. The same scenario works correctly with MSVC-compiled ARM64EC static libraries.

Environment

  • Rust version: rustc 1.88.0 (6b00bc388 2025-06-23)
  • Platform: Windows 11 ARM64 (10.0.26100)
  • Target: arm64ec-pc-windows-msvc
  • Toolchain: Visual Studio 2022 17.11+ with ARM64/ARM64EC build tools

Steps to Reproduce

  1. Create a minimal Rust library with C FFI exports
  2. Build it as static library for both aarch64-pc-windows-msvc and arm64ec-pc-windows-msvc
  3. Link both static libraries into an ARM64X DLL using /machine:arm64x
  4. Load the DLL from an x64 process on ARM64 Windows
  5. Process crashes with 0xc0000096

Attached arm64x-rust-test.zip for minimal reproducible example

Expected Behavior

The ARM64X DLL should load successfully in x64 processes, with the ARM64EC code handling the x64 emulation layer properly, just as it does with MSVC-compiled ARM64EC static libraries.

Actual Behavior

x64 processes crash immediately upon loading the ARM64X DLL with error 0xc0000096 (privileged instruction).

Additional Context

  • Works: Standalone ARM64EC DLL (not ARM64X) loads fine in x64 processes
  • Works: ARM64X DLL without Rust (pure C++) loads fine in x64 processes
  • Works: Same ARM64X DLL with Rust loads fine in ARM64 processes
  • Fails: Only fails when x64 process loads ARM64X DLL containing Rust ARM64EC static lib

This suggests the issue is specific to the static library format and how the ARM64X linker processes Rust-generated ARM64EC objects.

Workarounds

  1. Build separate architecture-specific DLLs instead of ARM64X
  2. Use dynamic linking (Rust as separate DLL)
  3. Avoid Rust in ARM64X components

This issue affects any Windows on ARM application trying to use Rust in system components that must support both ARM64 and x64 processes (like Text Services Framework, shell extensions, COM servers, etc.).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached arm64x-rust-test.zip minimal reproduction and reproduce the crash using rustc 1.88.0, the arm64ec-pc-windows-msvc target, and Visual Studio ARM64/ARM64EC build tools. Compare the Rust-generated ARM64EC static library with the working MSVC version during ARM64X linking; done means the DLL loads successfully in an x64 process without 0xc0000096.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.