You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NativeAOT: Consider enabling trim/AOT/single-file warnings by default #18571
Since NativeAOT is much more restrictive in terms of trimming and AOT compatibility of compiled applications (and used frameworks) compared to Mono, we should enable trimming, AOT and single-file warnings by default. Especially for the fact that NativeAOT does not have a safety - fallback mechanism like Mono's interpreter.
Additionally, since we will release NativeAOT on iOS as an experimental feature, enabling these warnings (and treating them as errors) would let us detect issues with our frameworks and compiled applications, which will enable us to address them early and improve the AOT experience for our customers.
changed the title [-]NativeAOT: Consider enabling trim and aot warnings by default[/-][+]NativeAOT: Consider enabling trim and AOT warnings by default[/+]on Jul 21, 2023
changed the title [-]NativeAOT: Consider enabling trim and AOT warnings by default[/-][+]NativeAOT: Consider enabling trim/AOT/single file warnings by default[/+]on Jul 21, 2023
changed the title [-]NativeAOT: Consider enabling trim/AOT/single file warnings by default[/-][+]NativeAOT: Consider enabling trim/AOT/single-file warnings by default[/+]on Jul 21, 2023
To get the full analysis log, we would have to pass -p:SuppressTrimAnalysisWarnings=false -p:TrimmerSingleWarn=false
Another thing worth considering is enabling these properties only for the ILC pass, and not for ILLink, to avoid getting duplicate warnings from the two trimming tools, or even incorrect warnings due to ILLink-ILC compatibility and difference in trimming capabilities.
Would it be possible to at least address the ones in new ios?
MAUI is probably a lost cause for .NET 8 and there will be warnings to tell people they're not getting a great experience. It would be nice if we could address at least those that are in an empty app but I don't know if it's possible.
To get the full analysis log, we would have to pass -p:SuppressTrimAnalysisWarnings=false -p:TrimmerSingleWarn=false
We should disable warning suppression in the SDK. TrimmerSingleWarn is useful to turn off for us, but brings no value to customers (customer knowing a MAUI assembly is not trim safe is better than spamming them with a dozen warnings they can do nothing about because they don't have MAUI source code they can edit).
+1 on leaving TrimmerSingleWarn=true, it's a much better experience.
+10 for trying to make the default template for ios warning free, but it might be too difficult
In general I think it would make sense to suppress all trim analysis warnings from the linker, not only due to duplicates but also due to possible differences (the tools will run with different input and settings). For correctness those from the NativeAOT should be sufficient (and more precise).
Activity
[-]Enable trim/aot warnings by default[/-][+]NativeAOT: Consider enabling trim and aot warnings by default[/+][-]NativeAOT: Consider enabling trim and aot warnings by default[/-][+]NativeAOT: Consider enabling trim and AOT warnings by default[/+][-]NativeAOT: Consider enabling trim and AOT warnings by default[/-][+]NativeAOT: Consider enabling trim/AOT/single file warnings by default[/+][-]NativeAOT: Consider enabling trim/AOT/single file warnings by default[/-][+]NativeAOT: Consider enabling trim/AOT/single-file warnings by default[/+]MichalStrehovsky commentedon Jul 25, 2023
If we don't do anything to break this, adding
<PublishAot>true</PublishAot>to the project should already enable these analyzers (we should validate).To validate, one should be able to create a new MAUI project in VS and add:
To the .cs somewhere. You should see IL3050 and IL2055 warnings when you build (and green squiggles in VS).
ivanpovazan commentedon Jul 25, 2023
If I did not miss anything, there are two places/properties which affect what can be currently seen in the build output:
https://github.com/xamarin/xamarin-macios/blob/d1d3dcdf68928303f8a00719a26dc1844b8567d9/dotnet/targets/Xamarin.Shared.Sdk.props#L23
Building a MAUI template application with how the analysers are currently configured (from above) the build log does not include precise information:
To get the full analysis log, we would have to pass
-p:SuppressTrimAnalysisWarnings=false -p:TrimmerSingleWarn=falseAnother thing worth considering is enabling these properties only for the ILC pass, and not for ILLink, to avoid getting duplicate warnings from the two trimming tools, or even incorrect warnings due to ILLink-ILC compatibility and difference in trimming capabilities.
/cc: @vitek-karas
ivanpovazan commentedon Jul 25, 2023
Here are the list of warnings for two different apps built with Xamarin+NativeAOT with analyzers enabled:
dotnet new iosapp: https://gist.github.com/ivanpovazan/930ccc4dd4199c449f0987a210e89a8fdotnet new mauiapp: https://gist.github.com/ivanpovazan/640891a7fe619fac3f4be982a928bdfcApps were built with the current state of: https://github.com/xamarin/xamarin-macios/tree/release/8.0.1xx-preview7
MichalStrehovsky commentedon Jul 25, 2023
Would it be possible to at least address the ones in
new ios?MAUI is probably a lost cause for .NET 8 and there will be warnings to tell people they're not getting a great experience. It would be nice if we could address at least those that are in an empty app but I don't know if it's possible.
We should disable warning suppression in the SDK. TrimmerSingleWarn is useful to turn off for us, but brings no value to customers (customer knowing a MAUI assembly is not trim safe is better than spamming them with a dozen warnings they can do nothing about because they don't have MAUI source code they can edit).
vitek-karas commentedon Jul 25, 2023
+1 on leaving
TrimmerSingleWarn=true, it's a much better experience.+10 for trying to make the default template for ios warning free, but it might be too difficult
In general I think it would make sense to suppress all trim analysis warnings from the linker, not only due to duplicates but also due to possible differences (the tools will run with different input and settings). For correctness those from the NativeAOT should be sufficient (and more precise).
rolfbjarne commentedon Aug 3, 2023
We have these two issues already:
rolfbjarne commentedon Aug 3, 2023
I've added an issue to fix the warnings, with a list of all the warnings: #18629
Once they're fixed, and the warnings enabled by default, we should also add tests to ensure we don't regress.
NativeAOT: Do not suppress trim warnings by default with NativeAOT (#…
ivanpovazan commentedon Aug 18, 2023
Fixed with 90cc165