Skip to content

Fix Crossgen2 failure on trimmed intrinsic types#123956

Merged
jkoritzinsky merged 5 commits intomainfrom
copilot/fix-crossgen-trim-mac-catalyst
Feb 8, 2026
Merged

Fix Crossgen2 failure on trimmed intrinsic types#123956
jkoritzinsky merged 5 commits intomainfrom
copilot/fix-crossgen-trim-mac-catalyst

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

The fix modifies the InstructionSetGenerator to generate code that gracefully handles missing (trimmed) intrinsic types. Instead of throwing a TypeLoadException when a type is not found, the code now:

  1. Calls GetType(..., false) which returns null for missing types
  2. Checks for null before yielding types to the enumerable
  3. Skips trimmed types entirely, allowing crossgen to complete successfully

This is the correct behavior - if a hardware intrinsic type has been trimmed away, it shouldn't be added to the compilation roots, and the build should succeed without that type.

Fixes #123953

Copilot AI changed the title [WIP] Fix Crossgen fails when compiling a trimmed Mac Catalyst project Fix Crossgen2 failure on trimmed intrinsic types Feb 3, 2026
Copilot AI requested a review from jkoritzinsky February 3, 2026 19:09
Copilot AI requested a review from jkotas February 3, 2026 19:52
@jkoritzinsky jkoritzinsky marked this pull request as ready for review February 3, 2026 21:10
Copilot AI review requested due to automatic review settings February 3, 2026 21:10
Copy link
Contributor

Copilot AI left a comment

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 fixes a Crossgen2 failure that occurs when compiling trimmed Mac Catalyst projects where hardware intrinsic types like System.Runtime.Intrinsics.Arm.Crc32 have been trimmed away. The fix modifies the instruction set lookup code to gracefully handle missing types instead of throwing TypeLoadExceptions.

Changes:

  • Modified InstructionSetGenerator.cs to generate null-safe type lookup code
  • Regenerated CorInfoInstructionSet.cs with the updated template
  • Changed all GetType(..., true) calls to GetType(..., false) to return null instead of throwing
  • Added null checks before yielding types to the enumerable

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs Updated code generator template to emit null-safe type lookups with proper null checks for both parent types and nested types
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs Auto-generated file containing null-safe type lookup implementations for all instruction sets across ARM64, X64, and X86 architectures

@jkotas jkotas added area-crossgen2-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Feb 8, 2026
@jkoritzinsky jkoritzinsky merged commit dee6079 into main Feb 8, 2026
102 of 104 checks passed
@github-project-automation github-project-automation bot moved this to Done in AppModel Feb 8, 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.

Crossgen fails when compiling a trimmed Mac Catalyst project

3 participants