[dotnet-linker] Set AssociatedSourceType on UnmanagedCallersOnly trampolines#25915
[dotnet-linker] Set AssociatedSourceType on UnmanagedCallersOnly trampolines#25915rolfbjarne wants to merge 1 commit into
Conversation
…polines Set the AssociatedSourceType property on UnmanagedCallersOnly attributes generated by the managed registrar step. This tells the trimmer/NativeAOT that the trampoline entry point is only needed if the associated type (the NSObject subclass declaring the exported method) is kept in the app. This reduces app size in NativeAOT scenarios by avoiding unnecessary native exports for trimmed types. Fixes #25631 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
It would be nice to wait until we get #25910 working so that we can get size diffs for this PR (thus |
There was a problem hiding this comment.
Pull request overview
This PR updates the managed registrar’s generated UnmanagedCallersOnly trampolines to set AssociatedSourceType, so NativeAOT/trimming can elide entry points when the corresponding NSObject subclass is trimmed, reducing app size.
Changes:
- Pass the exported method’s declaring type into
CreateUnmanagedCallersAttribute. - Emit an
AssociatedSourceTypenamed argument on generatedUnmanagedCallersOnlyAttributeinstances.
| CustomAttribute CreateUnmanagedCallersAttribute (string entryPoint, TypeReference? associatedSourceType = null) | ||
| { | ||
| var unmanagedCallersAttribute = new CustomAttribute (abr.UnmanagedCallersOnlyAttribute_Constructor); | ||
| unmanagedCallersAttribute.Fields.Add (new CustomAttributeNamedArgument ("EntryPoint", new CustomAttributeArgument (abr.System_String, entryPoint))); | ||
| if (associatedSourceType is not null) | ||
| unmanagedCallersAttribute.Fields.Add (new CustomAttributeNamedArgument ("AssociatedSourceType", new CustomAttributeArgument (abr.System_Type, associatedSourceType))); | ||
| return unmanagedCallersAttribute; | ||
| } |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #a4797cf] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #a4797cf] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ [PR Build #a4797cf] Build passed (Build packages) ✅Pipeline on Agent |
🔥 [CI Build #a4797cf] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 49 tests failed, 159 tests passed. Failures❌ linker tests (iOS)4 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)4 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (macOS)13 tests failed, 8 tests passed.Failed tests
Html Report (VSDrops) Download ❌ linker tests (tvOS)4 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (iOS)4 tests failed, 14 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)5 tests failed, 13 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (macOS)10 tests failed, 8 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)4 tests failed, 14 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Set the AssociatedSourceType property on UnmanagedCallersOnly attributes
generated by the managed registrar step. This tells the trimmer/NativeAOT
that the trampoline entry point is only needed if the associated type
(the NSObject subclass declaring the exported method) is kept in the app.
This reduces app size in NativeAOT scenarios by avoiding unnecessary
native exports for trimmed types.
Fixes #25631