-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Closed
Copy link
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Description
As part of testing dotnet/macios#18268 we hit an odd case where invalid IL is produced as the output of ILLink, resulting in later crash when post-processing the data with ILStrip. There's actually several issues at play here:
- Roslyn produces an unused TypeRef for global using aliases (
global usingproduces unnecessary TypeRef in output file roslyn#68250). Xamarin uses this to create an alias fornfloat. - ILLink with
-bswitch strips the unused AssemblyRef but keeps the unused TypeRef in theSaveassembly mode. Xamarin uses ILLink, among other things, to produce the Managed Static Registrar. In this configuration the originalCopymode of the input assembly is changed toSavein the process. - ILStrip crashes on the invalid input (Xamarin uses pretty old version, bump is handled in [msbuild] Bump ILStrip and add a maestro dependency to keep it updated. macios#18291).
Repro:
- Download extra-typeref-linker.zip
- Update the illinktask.dll path in linker.rsp to an absolute path to the included task .dll; the custom task only changes the assembly action to
Savesince it cannot be done on command line - Run
dotnet <path to illink.dll> @linker.rsp - Check
out\extra-typeref.dllwith themdvtool (https://github.com/dotnet/metadata-tools) and observe that there'sNFloattype reference that points to non-existent assembly reference
Observations:
- Tested with .NET 7.0.302 and .NET 8.0 Preview 5 linkers. The issue exists in both. On .NET 8 the original test case produces different linker input and doesn't hit the problem, but the underlying bug still exists.
- Removing the
-bswitch fromlinker.rspmakes the problem go away
ivanpovazan and rolfbjarne
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers