Skip to content

Commit

Permalink
Correctly set trimmer args for NativeAOT builds
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrozsival committed Jul 2, 2024
1 parent 3618785 commit 4502d35
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@
<!-- Suppress trimmer warnings unless we're trimming all assemblies -->
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimMode)' == 'full'">false</SuppressTrimAnalysisWarnings>
<SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == ''">true</SuppressTrimAnalysisWarnings>
<!--
In the case of NativeAOT builds, the trim warnings will be produced either by the ILLink roslyn analyzer in Debug builds
or by the ILC when publishing. We want to suppress the ILLink warnings in all build configurations to avoid duplicates.
-->
<SuppressTrimAnalysisWarnings Condition="'$(PublishAot)' == 'true'">true</SuppressTrimAnalysisWarnings>

<!-- Pass the custom options to our custom steps -->
<_CustomLinkerOptionsFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)custom-linker-options.txt'))</_CustomLinkerOptionsFile>
Expand Down Expand Up @@ -652,6 +657,9 @@
<!-- If we're using NativeAOT, tell ILLink to not remove dependency attributes (DynamicDependencyAttribute), because NativeAOT's trimmer also needs to see them. -->
<_ExtraTrimmerArgs Condition="'$(_UseNativeAot)' == 'true'">$(_ExtraTrimmerArgs) --keep-dep-attributes</_ExtraTrimmerArgs>

<!-- Ensure ILLink respects the value of SuppressTrimAnalysisWarnings -->
<_ExtraTrimmerArgs Condition="'$(SuppressTrimAnalysisWarnings)' == 'true'">$(_ExtraTrimmerArgs) --notrimwarn</_ExtraTrimmerArgs>

<!-- We always want the linker to process debug symbols, even when building in Release mode, because the AOT compiler uses the managed debug symbols to output DWARF debugging symbols -->
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols>

Expand Down

0 comments on commit 4502d35

Please sign in to comment.