-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix Crossgen2 failure on trimmed intrinsic types #123956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
There was a problem hiding this 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.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 |
Fix Crossgen failure when compiling trimmed Mac Catalyst project
The issue occurs when crossgen tries to load intrinsic types that have been trimmed away during the compilation process. Specifically,
System.Runtime.Intrinsics.Arm.Crc32is being trimmed but crossgen still tries to load it withthrowIfNotFound=true, causing a TypeLoadException.Plan:
GetType(..., true)toGetType(..., false)so it returns null instead of throwingSummary:
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.
Original prompt
This section details on the original issue you should resolve
<issue_title>Crossgen fails when compiling a trimmed Mac Catalyst project</issue_title>
<issue_description>### Description
Crossgen fails to compile a trimmed Mac Catalyst project with:
Reproduction Steps
Use .NET 11 preview 1, install the mac catalyst workload, create a mac catalyst project, compile.
This script does it:
Expected behavior
Successful build.
Actual behavior