dotnet / dotnet/fsharp

AOT compilation warnings cannot be pinpointed in code

Open
#18,959 1 comment 0 reactions 0 assignees View on GitHub
Area-AOT Feature Improvement
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

Please provide a succinct description of the issue:

Attempting to use AOT with F# is problematic when trying to identify where your code may be calling offending functions. The C# compiler seems to do better with this by providing the exact call site, F# compiler does not.

It seems F# isn't fully AOT compatible yet and will take some time to get there. But a resolution to this item could ease the pain in the meantime.

Provide the steps required to reproduce the problem:

1. Create simple F# project with `printfn "%i 1`
2. Publish with AOT
3. Observe AOT trim warnings

**Expected behavior**

As with the C# compiler, the call site is pin-pointed to your code. In this example it is pin-pointed to Program.Main():

`AOT analysis warning IL3050: Program.$(String[]): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.`

**Actual behavior**

Call site is obscured with the F# compiler:

`AOT analysis warning IL3050: Microsoft.FSharp.Reflection.Impl.getUnionCaseTyp(Type,Int32,BindingFlags): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime.`

**Known workarounds**

None

**Related information**

I've had some limited success using tricks learned [here](https://github.com/dotnet/linker/issues/3212). But it isn't easy or timely.

* Operating system=Windows&Linux
* .NET Runtime = .NET Core 10 rc1
* Editing Tools = VSCode

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.