Skip to content

Change default TrimMode to link #15905

@sbomer

Description

@sbomer

The default TrimMode for ILLink is copyused, which will keep an entire assembly if it is statically used. The primary advantage of copyused over link is that it keeps more code, making it more likely that the linked application will work. But this has a few downsides:

  • We keep code which is unused by the application, bloating app size
    • This can produce spurious warnings from unused code
  • We don't rewrite IL in copyused assemblies, so we don't eliminate unused branches
    • This results in spurious warnings from unused features
    • This may also compound the size problem - we might keep dependencies (possibly other assemblies) of branches that would otherwise have been eliminated

We should consider changing the default mode to link - this mode has proven to work well enough for Xamarin and Blazor. The downside is that we have shipped the last two releases (albeit in "preview") with copyused as the default, and changing it could break some apps, particularly in cases where non-framework code reflects over the framework.

@vitek-karas @eerhardt @agocke

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions