Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

[WIP] Remove keep-facades option - #1781

Closed
marek-safar wants to merge 1 commit into
dotnet:mainfrom
marek-safar:nofacades
Closed

marek-safar wants to merge 1 commit into
dotnet:mainfrom
marek-safar:nofacades

Conversation

@marek-safar

Copy link
Copy Markdown
Contributor

It was introduced when .net core added framework initial trimming for
libraries build. This is a third way to achieve same thing but less
logical than using -p or -a option and it's no longer used by libraries
build.

Fixes #1740

It was introduced when .net core added framework initial trimming for
libraries build. This is a third way to achieve same thing but less
logical than using -p or -a option and it's no longer used by libraries
build.

Fixes dotnet#1740
var di = new DependencyInfo (DependencyKind.TypePreserve, type);

switch (members) {
case TypePreserveMembers.All:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the difference between TypePreserveMembers.All and TypePreserve.All? They look like they do the same thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

they are enum values stored into a different annotation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can see that they're different enums. What I mean is, we have this case above:

case TypePreserve.All:
	MarkFields (type, true, di);
	MarkMethods (type, di, type);
	return;

Why do we need TypePreserveMembers.All if it is only duplicating this logic? Could we do Annotations.SetPreserve (type, TypePreserve.All) below, instead of Annotations.SetMembersPreserve (type, TypePreserveMembers.All)? That seems to be the only place we use it.

[SetupLinkerAction ("copy", "copied")]

// --keep-facades sends the sweep step down a different code path that caused problems for this corner case
[SetupLinkerArgument ("--keep-facades", "true")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this testcase can be deleted (it's now the same as AssemblyOnlyUsedByUsingWithCsc).

if (assembly.MainModule.HasExportedTypes) {
// TODO: This needs more work accross all steps
foreach (var exportedType in assembly.MainModule.ExportedTypes) {
_context.Annotations.Mark (exportedType, new DependencyInfo (DependencyKind.ExportedType, exportedType));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a significant behavior change:

  • We didn't used to keep type forwards in copy assemblies - this could result in some extra facade dlls being kept that weren't needed previously. It's probably uncommon, since facades are usually going to be copyused as part of the framework, but it's unclear how copyused is supposed to behave now. Should a marked copyused assembly also have exported types kept? (This would be a bigger issue since copyused are more likely to pull in facades).
  • I think this will prevent SweepStep from sweeping assembly refs from copy assemblies, so it will never update scopes for Copy assemblies. Same question - how should this work for copyused assemblies?

If we go this direction and mark all copy type forwarders, I think we can simplify a few cases in SweepStep:

  • get rid of the copy case from UpdateAssembliesReferencingRemovedAssembly
  • get rid of the SweepTypeForwarders handling for copy assemblies

Comment thread src/linker/Linker.Steps/MarkStep.cs Resolved
Comment on lines 148 to 149
// FIXME: AddBypassNGen is just wrong, it should not be action as we need to
// turn it to Action.Save here to e.g. correctly update debug symbols

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we also delete the comment now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that still wrong. The whole AddBypassNGen thing is weird :-) and has no tests.

@marek-safar
marek-safar marked this pull request as draft January 26, 2021 19:38
@marek-safar marek-safar changed the title Remove keep-facades option [WIP] Remove keep-facades option Jan 26, 2021
Base automatically changed from master to main February 4, 2021 22:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type forwarder handling needs cleanup

3 participants