Cannot AOT compile trimmed FSharp.Core

Open
#116,811 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, fsharp, ios

Research direction

Start with the kerams/fsharp-ios-aot reproduction and the two F# type usages in App.axaml.cs. Compare the Release build with TrimMode copyused enabled against the workaround in Theme.iOS.csproj, then inspect the reported AOT failures for FSharp.Core. Done means the Release iOS AOT build succeeds with copyused trimming enabled without disabling trimming for FSharp.Core.

Written by the indexing model from the issue text.

Description

area-Tools-ILLink
Apple platform

iOS

Framework version

net10.0-*

Affected platform version

VS 17.14.5, 10.0.100-preview.5.25277.114, 18.4.10622-net10-p5

Description

Similar to https://github.com/dotnet/macios/issues/14813

AOT builds fail when copyused trimming is enabled for FSharp.Core.

1>... Microsoft.iOS.Sdk.net10.0_18.4\18.4.10622-net10-p5\targets\Xamarin.Shared.Sdk.targets(1284,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 1.
1>... Microsoft.iOS.Sdk.net10.0_18.4\18.4.10622-net10-p5\targets\Xamarin.Shared.Sdk.targets(1284,3): error : Failed to AOT compile FSharp.Core.dll, the AOT compiler exited with code 1.
Steps to Reproduce

https://github.com/kerams/fsharp-ios-aot

There are 2 lines that use F# types in App.axaml.cs.

Try to compile in Release, see errors. Then remove TrimMode copyused and uncomment IsTrimmable in Theme.iOS.csproj. Complile successfully.

Did you find any workaround?

Disable trimming for FSharp.Core completely with

<ManagedAssemblyToLink Condition="'%(Filename)' == 'FSharp.Core'">
  <IsTrimmable>false</IsTrimmable>
</ManagedAssemblyToLink>
Build logs

No response

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.