-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
ILLink produces invalid IL metadata with -b switch and Save assembly mode #86462
Comments
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsAs 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:
Repro:
Observations:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
I realized that I forgot to include the .pdb in the repro package. That's essential for the error to occur. Here's a fixed one: |
This fixes the output for me: filipnavara@7cca2fa Unit tests will be easier to write once #86474 lands. |
This is similar to this old issue btw: dotnet/linker#399 |
@vitek-karas This should be rather trivial to fix. I suppose that I can take a stab at it if you are busy... |
I'm definitely busy with other commitments... maybe @sbomer can take a look. |
Would love it if you were able to contribute a fix. :) Otherwise I can take a look next week. |
#87575) Fixes #86462 by walking debug info to discover typerefs in the assembly that are only preserved due to debug info. In this case the assembly has the 'save' action, so the reference to the typeref in the debug info is not swept. This means that the presence of the typeref in the final output depends on whether we are linking the PDB. Walking the typeref will preserve the assemblyref that it refers to, fixing the issue. The fix also needs to walk up the parent import scopes, discovered by reproducing the issue in our test infra. The behavior needs to depend on whether we are linking debug symbols, otherwise we will keep the assemblyref (but not the typeref that uses it) when PDBs are present, and the output should not depend on the presence of PDBs. `AssemblyOnlyUsedByUsingSaveAction` tests this case - see comments in there for more detail. This includes some unrelated test infra changes (supporting multiple additional compiler arguments) which were useful for iterating on this, even though they aren't necessary in the final version of the testcases.
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:
global using
produces unnecessary TypeRef in output file roslyn#68250). Xamarin uses this to create an alias fornfloat
.-b
switch strips the unused AssemblyRef but keeps the unused TypeRef in theSave
assembly mode. Xamarin uses ILLink, among other things, to produce the Managed Static Registrar. In this configuration the originalCopy
mode of the input assembly is changed toSave
in the process.Repro:
Save
since it cannot be done on command linedotnet <path to illink.dll> @linker.rsp
out\extra-typeref.dll
with themdv
tool (https://github.com/dotnet/metadata-tools) and observe that there'sNFloat
type reference that points to non-existent assembly referenceObservations:
-b
switch fromlinker.rsp
makes the problem go awaycc @rolfbjarne @ivanpovazan
The text was updated successfully, but these errors were encountered: