-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix missing assemblyref for typeref only kept for debug info in illink #87575
Conversation
When linking `save` assemblis with `-b true` (linking debug info), we preserve all debug info (and don't sweep the debug info like we do for `link` assemblies). With this change, we now take into account type references that are only referenced by the debug info, preserving any assembly refs needed by them. This adds test infra to walk the type references in the output assembly, and check that they reference assembly refs that also exist in the output. Includes some test infra changes that were ultimately not necessary for the repro, but were useful, to allow passing multiple additional compiler args when compiling testcase dependencies.
This should be adequately covered by NoLinkedOutputAttribute
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr, @marek-safar Issue DetailsFixes #86462 using the approach suggested in #86462 (comment). Initially I was looking into removing the unused typeref, but since we don't sweep debug info for save assemblies, I think it makes sense to keep it, even though this means the presence of the typeref in the final output depends on whether we are linking the PDB. The fix also needed 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 I don't think the output should depend on the presence of PDBs. 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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I got stuck on making the unit test for this, so I am glad you tackled it in the end.
Yeah, reproducing this in a unit test was challenging. Thanks a lot for the detailed issue report! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - thanks.
I find it weird that we intentionally leave a type ref/assembly ref in but remove the target from the app - but I guess that's what save
is about. I got too used to true trimming recently with AOT and such.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Outdated
Show resolved
Hide resolved
It is a bit weird, but it's at least consistent with what we do for the other kept typerefs in save assemblies. It's also a bit weird that if we aren't linking debug symbols, we will actually remove both the typeref and the assemblyref in this example - but I think it makes sense for the reason I gave above. |
I perfectly fine with the behavior regarding stripping symbols - I think it makes sense. |
Fixes #86462 using the approach suggested in #86462 (comment). Initially I was looking into removing the unused typeref, but since we don't sweep debug info for save assemblies, I think it makes sense to keep it, even though this means the presence of the typeref in the final output depends on whether we are linking the PDB.
The fix also needed 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 I don't think the output should 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.