[ObjCRuntime] Allow native dynamic registrar removal. Fixes #16668#26219
Conversation
Initialize the native trampoline table from generated startup code only when dynamic registration support is enabled, so the native linker can dead-strip it otherwise. Verify the linked trampoline symbol follows DynamicRegistrationSupported. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 436154f1-6cca-4e7e-bd3e-199087275dcf
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
✅ Applied expected app size files from gist. |
There was a problem hiding this comment.
Pull request overview
Updates the native runtime initialization path so the dynamic registrar’s trampoline table is only referenced/initialized when dynamic registration support is enabled, allowing the native linker to dead-strip the dynamic-registrar native code when it’s disabled (fixing #16668).
Changes:
- Emit a call to
xamarin_initialize_dynamic_registrar ()from generated startup code only whenDynamicRegistrationSupportedis enabled (and not for NativeAOT). - Move
options.Trampolines = &trampolines;out ofxamarin_initialize ()into the newxamarin_initialize_dynamic_registrar ()entry point. - Add a unit test that validates
_xamarin_invoke_trampolineis present/absent based onDynamicRegistrationSupported, and update size baselines accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/common/Target.cs | Generated startup code now conditionally calls xamarin_initialize_dynamic_registrar () and sets xamarin_supports_dynamic_registration only for non-NativeAOT. |
| runtime/xamarin/runtime.h | Declares xamarin_initialize_dynamic_registrar () for generated code to call. |
| runtime/runtime.m | Introduces xamarin_initialize_dynamic_registrar () and removes unconditional trampoline-table wiring from xamarin_initialize (). |
| tests/dotnet/UnitTests/DynamicRegistrationSupportedTest.cs | Adds symbol-level verification (nm) that _xamarin_invoke_trampoline matches the feature switch. |
| tests/dotnet/UnitTests/expected/*-size.txt | Updates size baselines reflecting dead-stripping improvements across platforms/configurations. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The UserSpecifiedValue test verifies that the dynamic registrar's native
trampoline symbol ('_xamarin_invoke_trampoline') is linked into the main
executable when '$(DynamicRegistrationSupported)' is true and dead-stripped
when it's false.
On a simulator build, '$(_LibXamarinLinkMode)' defaults to 'dylib', so
libxamarin is a dynamic library that always contains the trampoline symbol,
and the main executable never does - so the 'nm -j <mainExecutable>' check
could never observe the presence of the symbol, failing the true case.
Force '$(_LibXamarinLinkMode)=static' so libxamarin is linked into the main
executable and the native linker's dead-stripping becomes observable there.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dynamic-registrar-native-code
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…dynamic-registrar-native-code
This comment has been minimized.
This comment has been minimized.
✅ 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 |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #e37d4cb] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 203 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Initialize the native trampoline table from generated startup code only when dynamic registration support is enabled, so the native linker can dead-strip it otherwise.
Verify the linked trampoline symbol follows DynamicRegistrationSupported.
Fixes #16668
🤖 Pull request created by Copilot