Skip to content

Ensure that FSharp.Core is trimmable. #12819

@teo-tsirpanis

Description

@teo-tsirpanis

Is your feature request related to a problem? Please describe.

When I trim a simple F# project, the size of FSharp.Core is unchanged. When I manually enable trimming it and after removing the optimization and signature data, its size shrunk by five, from 1.09 MB to 197 KB.

Describe the solution you'd like

Providing these size savings out of the box and in a safe way would be great. The following things need to happen:

  • Ensure that the optimization and signature data are removed by the trimmer. This can happen very easily by embedding an ILLink.Substitutions.xml file to the library. If these files are indeed only used at compile time, I can submit a PR.
  • The library's usage of reflection has to be audited, and the appropriate attributes must be applied to avoid any unpleasant surprises. If the trimmer does not recignize these attributes by name, we would have to multi-target FSharp.Core to .NET 5+.
    • After that, adding [<assembly: AssemblyMetadata("IsTrimmable", "True")>] will ensure that FSharp.Core will get trimmed.

I am not sure whether the first bullet point requires the second.

Describe alternatives you've considered

N/A

Additional context

This issue is not about making F# in general friendly to trimming or AOT, but about the minimum required work to make just FSharp.Core trimmable.

Metadata

Metadata

Assignees

Labels

Area-LibraryIssues for FSharp.Core not covered elsewhereFeature RequestImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions