Skip to content

Fix managed ilasm ARM64 target with PE64 - #137454

Merged
jkoritzinsky merged 4 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/ilasm-pe64-arm64
Nov 18, 2026
Merged

jkoritzinsky merged 4 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/ilasm-pe64-arm64

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Treat PE64 as an AMD64 default only when ARM64 was not explicitly requested. Previously, PE64 selected AMD64 before the ARM64 option was considered, regardless of argument order.

This restores compatibility with the original -DLL -PE64 -ARM64 invocations without changing the MixedMode fixture projects. Explicit X64 and PE64-only behavior remain unchanged.

Add a 15-case command-line theory checking both COFF Machine and optional-header magic for the default target, X64, ARM64, and PE64, including legacy/modern spellings and both option orders.

Validation

  • .\build.cmd clr+libs -rc release — passed (clean prerequisite build).
  • .\dotnet.cmd test src\tools\ilasm\tests\ilasm.Tests\ilasm.Tests.csproj --filter FullyQualifiedName~TargetOptions_EmitRequestedArchitecture before the fix — reproduced exactly four failures (ARM64 + PE64 with legacy/modern spellings in both orders); 11 controls passed.
  • .\dotnet.cmd test src\tools\ilasm\tests\ilasm.Tests\ilasm.Tests.csproj after the fix — passed: 578 passed, 3 existing skips, 0 failures.
  • .\build.cmd tools+tools.ilasm — passed. Two unrelated NU1903 warnings report the existing Microsoft.DotNet.ILCompiler 10.0.12 dependency in mscordaccore_universal.
  • Assembled the unchanged DataPointers.il and ExecutableData.il fixtures with the built production ILAsm and inspected their PE headers: all 20 fixture/option combinations passed. Both legacy -PE64 -ARM64 and modern --pe64 --arm64, in either order, emit Machine 0xAA64 and PE32+ (0x20B). ARM64 alone, PE64 alone, X64, X64 + PE64, and default I386/PE32 controls also passed. The ARM64 executable-data input includes the existing Arm64.il definition, as its project does.

Windows ARM64 execution was not performed: the available host is Windows x64. No test cases were disabled or fixture flags changed.

Resolves #137449

Note

This pull request was generated by GitHub Copilot.

Honor the ARM64 target when PE64 is also specified, retaining AMD64 as the PE64-only default. Cover legacy and modern architecture switches and both option orders with emitted-header checks.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib
See info in area-owners.md if you want to be subscribed.

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.

🟢 Approval recommended

No active review issues are recorded for the ARM64/PE64 target-selection change.

No open issues 🎉

What changed in this PR

Fixes managed ILAsm target selection so an explicit ARM64 option takes precedence over the PE64 default to AMD64, restoring compatibility with existing MixedMode fixture invocations.

Changes:

  • Prevents PE64 from overriding ARM64 while preserving explicit X64 and PE64-only behavior.
  • Adds 15 command-line test cases checking COFF machine and optional-header magic across legacy and modern option spellings and both option orders.
File Description
src/​tools/​ilasm/​tests/​ilasm.Tests/​CommandLineTests.cs Adds architecture-selection regression coverage using emitted PE headers.
src/​tools/​ilasm/​src/​ilasm/​Program.cs Applies the PE64 AMD64 default only when ARM64 is not explicitly requested.

Review effort: Balanced

Comment thread src/tools/ilasm/src/ilasm/Program.cs Resolved
Replace the modern --pe64, --x64, and --arm64 switches with a single --arch <x86|x64|arm64> option. Legacy /PE64, /X64, and /ARM64 switches now normalize to one --arch value that matches native ilasm: the last /X64 or /ARM64 wins, and /PE64 alone targets x64.

Co-authored-by: Copilot App <[email protected]>
Emit the synthesized architecture option at the end of the normalized arguments instead of tracking its original position. Keep the end-of-options separator and trailing operands after the architecture option.

Co-authored-by: Copilot App <[email protected]>
@jkoritzinsky
jkoritzinsky requested a review from jkotas November 17, 2026 22:04
@jkoritzinsky
jkoritzinsky requested a review from jkotas November 17, 2026 22:23
Replace the single-use local setter functions with direct assignments.

Co-authored-by: Copilot App <[email protected]>

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.

🟡 Changes recommended

Architecture normalization adds a conflicting x64 target to an explicit ARM64 request and emits duplicate targets when modern and legacy selectors are mixed.

1 open issue

Review effort: Balanced

@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) November 17, 2026 23:00
@jkoritzinsky
jkoritzinsky merged commit 8efd167 into dotnet:main Nov 18, 2026
60 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 18, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Managed ilasm emits AMD64 instead of ARM64 when -PE64 and -ARM64 are combined

3 participants