Fix Crossgen2 failure on trimmed intrinsic types#123956
Merged
jkoritzinsky merged 5 commits intomainfrom Feb 8, 2026
Merged
Conversation
Co-authored-by: jkoritzinsky <[email protected]>
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
jkotas
reviewed
Feb 3, 2026
Co-authored-by: jkotas <[email protected]>
jkoritzinsky
approved these changes
Feb 3, 2026
Contributor
There was a problem hiding this comment.
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.csto generate null-safe type lookup code - Regenerated
CorInfoInstructionSet.cswith the updated template - Changed all
GetType(..., true)calls toGetType(..., 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
approved these changes
Feb 3, 2026
This was referenced Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fix modifies the
InstructionSetGeneratorto generate code that gracefully handles missing (trimmed) intrinsic types. Instead of throwing aTypeLoadExceptionwhen a type is not found, the code now:GetType(..., false)which returnsnullfor missing typesnullbefore yielding types to the enumerableThis 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