Skip to content
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

Don't remove MethodImpl if overridden method is not in a link assembly #2771

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

jtschuster
Copy link
Member

@jtschuster jtschuster commented Apr 28, 2022

Before removing overrides, we should check if the overridden method is
in an ignore scope.

In the linker we consider types and methods in a skip assembly as "removed", so when the linker would check if an overridden method is removed, it would see that it is considered removed, even though it should be considered kept. The workaround is to use the IgnoreScope helper to determine if the interface method is in a link assembly and removed, and only remove the MethodImpl if both are true.

Now, whether ShouldRemove should return true or false for things in a skip assembly, I'm not sure. It depends on whether it does / should mean "Actively removed from the assembly" or "not in the final output".

This PR fixes the issues found in dotnet/runtime#68612.

Before removing overrides, we should check if the overridden method is
in an ignore scope.
@agocke
Copy link
Member

agocke commented Apr 28, 2022

Definitely think we need a test here. @sbomer any idea on what might be happening in the runtime repo that isn't the same in our testing system?

@sbomer
Copy link
Member

sbomer commented Apr 28, 2022

We should be able to repro it in the test infra, sounds like @jtschuster was able to get a repro.

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@sbomer
Copy link
Member

sbomer commented Apr 29, 2022

One nit: when you check it in, I'd update the commit title to not mention INumberBase, but to describe the fix

@jtschuster jtschuster changed the title Quick fix for INumberBase overrides being removed Don't remove MethodImpl if overridden method is not in a link assembly Apr 29, 2022
@jtschuster jtschuster requested a review from agocke April 29, 2022 16:23
@jtschuster jtschuster merged commit 4461068 into dotnet:main Apr 29, 2022
@jtschuster jtschuster deleted the staticInterfaceBug2 branch April 29, 2022 19:28
@agocke
Copy link
Member

agocke commented May 1, 2022

Ah, so the thing I was missing here was

[SetupLinkerAction ("skip", "skiplibrary")]

which turns the S.P.C reference to "skip"

@tannergooding
Copy link
Member

About how long does it normally take this to flow to dotnet/runtime? No particular rush atm, just wanting to make sure it stays on my own radar.

@tannergooding
Copy link
Member

Looks like dotnet/runtime#68650 has it and I just need to wait on that to merge.

@vitek-karas
Copy link
Member

Typically less then a day... if everything is green - which it hasn't been (as we improve the analyzer we find either issues in the analyzer or in the setup in runtime repo)

jtschuster added a commit to jtschuster/linker that referenced this pull request May 6, 2022
jtschuster added a commit that referenced this pull request May 6, 2022
* Revert "Trim static interfaces (#2741)"

This reverts commit a073a68.

* Revert "Don't remove MethodImpl if overridden method is not in a link assembly (#2771)"

This reverts commit 4461068.

* Revert "Fix NullReferenceException when sweeping unused static interface (#2783)"

This reverts commit 00e9a15.
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
dotnet/linker#2771)

Before removing overrides, we should check if the overridden method is
in an ignore scope.

Commit migrated from dotnet/linker@4461068
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Revert "Trim static interfaces (dotnet/linker#2741)"

This reverts commit dotnet/linker@a073a68.

* Revert "Don't remove MethodImpl if overridden method is not in a link assembly (dotnet/linker#2771)"

This reverts commit dotnet/linker@4461068.

* Revert "Fix NullReferenceException when sweeping unused static interface (dotnet/linker#2783)"

This reverts commit dotnet/linker@00e9a15.

Commit migrated from dotnet/linker@eb6144b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants