-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotate FSharp.Core for trimmability #15980
Comments
Some work by @teo-tsirpanis on trimming here: https://github.com/teo-tsirpanis/fsharp/tree/fscore-trimming |
@charlesroddie : That verify trimming now works correctly for %A, unions, records etc, but we have not yet done the work to enable F# apps to work when AOT reflection is disabled. It is the next sizable job I will be working on unless priorities change. |
@charlesroddie , I think we are in a pretty decent place now for trimmabilty. We have %A support for all F# types. We do need to do a lot of work to enable F# AOT when reflection is disabled in the runtime. We have these tests here: https://github.com/dotnet/fsharp/tree/main/tests/AheadOfTime/Trimming We will manage reflection disabled AOT with this PR: #16663 If there are any Apis that need Annotation we will handle them as issues. Before I close this, let me know if there are any specific APIs you have in mind for additional annotation. Thanks Kevin |
Great. Is there a released version of F# or the dotnet sdk with these annotations in? We have dotnet sdk 8.0.101 in the pipeline but can try 8.0.201. |
I can confirm that when building from VS 17.9.2, there are no trim warnings coming from FSharp.Core. |
Compile an F# app with NativeAOT
Set
<TrimmerSingleWarn>false</TrimmerSingleWarn>
to see detailed logs.Many warnings result. These are mostly from FSharp.Core but some are from a "Compiler" namespace and presumably leak from there into FSharp.Core.
F# should be annotated for trimming so that users who do not use problematic constructs will not get warnings. Problematic code should be annotated with
DynamicallyAccessedMemberTypes
etc.. The aim of the trimming annotations is to give users full confidence that, if there are no warnings, then AOT compilation will work.The code warned about should not be actually called if users are careful, and if they set --reflectionfree they will be given help in avoiding problematic code (like
sprintf
used explicitly), and the compiler will also not generate problematic code (likesprintf
generated from DUs).However --reflectionfree doesn't catch all uses of reflection (although it could and should be extended to do that), so there are currently false negatives, and there are also a lot of false positives as seen below. So this is complementary to the standard dotnet trimming annotation approach.
The text was updated successfully, but these errors were encountered: