Skip to content

TrimmerRootAssembly deoptimizes size of native AOT apps #10672

@MichalStrehovsky

Description

@MichalStrehovsky

Android framework version

Other

Affected platform version

.NET 11

Description

<!-- Root *everything* for ILC, as it's already trimmed -->
<TrimmerRootAssembly Include="@(_AndroidILLinkAssemblies->'%(Filename)')" Exclude="System.Private.CoreLib" TrimMode="All" />

This forces the compiler to consider everything that survived IL trimming as target of reflection. This is a big deoptimization. ILC has an internal/undocumented mode that does something similar (add /p:IlcTrimMetadata=false to dotnet publish and you'll get similar results to how an ILLinked IL-based app looks like under reflection). Adding this undocumented switch to a dotnet new webapiaot app doubles the size of the native AOT output, for example).

See also conversation around https://discord.com/channels/732297728826277939/732297837953679412/1444909702512119899 on discord.

We should work on ensuring this is not needed. Xamarin macios originally started with a similar TrimmerRootAssembly thing but it was removed before shipping.

The first step in getting rid of this should be to review all the UnconditionalSuppressMessage attributes in this repo.

I can help with this work.

Cc @sbomer FYI

Steps to Reproduce

Build a native AOT android app.

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions