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

When linker removes all references to an assembly the assembly ref is not removed #1296

Closed
ericstj opened this issue Jun 25, 2020 · 3 comments · Fixed by #1683
Closed

When linker removes all references to an assembly the assembly ref is not removed #1296

ericstj opened this issue Jun 25, 2020 · 3 comments · Fixed by #1683

Comments

@ericstj
Copy link
Member

ericstj commented Jun 25, 2020

I noticed this when looking at the trimmed assemblies in the .NETCore shared framework.

The assembly System.Diagnostics.TraceSource had a reference to System.Diagnostics.Process in one place which was unreachable and trimmed by the linker, however the assembly ref to System.Diagnostics.Process remains.

Some tools will see this and still try to load Process, the linker should remove this if possible.

@marek-safar
Copy link
Contributor

Could you attach the assembly? The illinker removes assembly references in such cases automatically so it's likely there is still some reference to System.Diagnostics.Process somewhere (e.g. in attribute)

@ericstj
Copy link
Member Author

ericstj commented Jun 25, 2020

Here you go
System.Diagnostics.TraceSource.zip

This came from the 5.0.0-preview.6.20305.6 win-x64 shared framework.

Here's the disassembly that shows no references to S.D.Process: https://gist.github.com/ericstj/a73b7511a968d5adb45186e93ef5a166

I can also reproduce by building the System.Diagnostics.TraceSource library in dotnet/runtime, which runs the linker as a post-build step.

@ericstj
Copy link
Member Author

ericstj commented Jun 30, 2020

@marek-safar did you get a chance to look at this?

@marek-safar marek-safar added this to the .NET 6.0 milestone Nov 13, 2020
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 10, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 10, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 10, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 10, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 13, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
marek-safar added a commit to marek-safar/linker that referenced this issue Dec 16, 2020
The previous logic only removed assembly reference for linked assembly
if the reference didn't exist in the closure of input assemblies. This
was wrong because it kept unused references in one assembly if the
another assembly used same reference.

Fixes dotnet#1296
Fixes dotnet#1576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants