You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was filed with AI (Copilot) assistance.
When an assembly is rooted with -a (AllMembers) and has link action, ILLink preserves type forwarder assemblies that are referenced through type references. This is unnecessary because the linker rewrites the type references to point directly to the implementation assembly, so the forwarder is not needed at runtime to load the assembly. Without -a, these forwarder assemblies are correctly removed.
Root Cause
MarkStep.MarkEntireAssembly unconditionally calls TypeReferenceMarker.MarkTypeReferences, which walks all type references in the assembly and calls MarkForwardedScope for each one. This marks the ExportedType entries in forwarder assemblies, which causes those assemblies to be preserved.
This is correct for copy/save action assemblies — they can't be rewritten, so forwarders they reference must be kept. But for root assemblies with link action, the type references will be rewritten by AssemblyReferencesCorrector in the sweep step to point directly to the implementation assemblies, making the forwarders unnecessary.
Note
This issue was filed with AI (Copilot) assistance.
When an assembly is rooted with
-a(AllMembers) and haslinkaction, ILLink preserves type forwarder assemblies that are referenced through type references. This is unnecessary because the linker rewrites the type references to point directly to the implementation assembly, so the forwarder is not needed at runtime to load the assembly. Without-a, these forwarder assemblies are correctly removed.Root Cause
MarkStep.MarkEntireAssemblyunconditionally callsTypeReferenceMarker.MarkTypeReferences, which walks all type references in the assembly and callsMarkForwardedScopefor each one. This marks theExportedTypeentries in forwarder assemblies, which causes those assemblies to be preserved.This is correct for copy/save action assemblies — they can't be rewritten, so forwarders they reference must be kept. But for root assemblies with link action, the type references will be rewritten by
AssemblyReferencesCorrectorin the sweep step to point directly to the implementation assemblies, making the forwarders unnecessary.Encountered in dotnet/android@924649e