Skip to content

Commit

Permalink
[net10.0] [dotnet] Disable aggressive attribute trimming when using N…
Browse files Browse the repository at this point in the history
…ativeAOT. Fixes #22065.

Aggressive attribute trimming removes attributes used by the trimmer. This is
fine as long as we don't run _two_ trimmers - because then the first pass
would remove attributes needed by the second pass, which is exactly what
happens when we're building using NativeAOT: we first run ILLink, then
NativeAOT's trimmer.

If aggressive attribute trimming is enabled in this scenario, ILLink will
remove attributes required by NativeAOT to work correctly, so disable
aggressive attribute trimming.

Fixes #22065.
  • Loading branch information
rolfbjarne committed Feb 11, 2025
1 parent 99ed424 commit 6c5e3f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@
<_AdditionalTaskAssemblyDirectory>$(_XamarinSdkRootDirectoryOnMac)tools/dotnet-linker/</_AdditionalTaskAssemblyDirectory>
<_AdditionalTaskAssembly>$(_AdditionalTaskAssemblyDirectory)dotnet-linker.dll</_AdditionalTaskAssembly>

<MobileAggressiveAttributeTrimming Condition="'$(MobileAggressiveAttributeTrimming)' == ''">true</MobileAggressiveAttributeTrimming>
<MobileAggressiveAttributeTrimming Condition="'$(MobileAggressiveAttributeTrimming)' == '' And '$(_UseNativeAot)' != 'true'">true</MobileAggressiveAttributeTrimming>
<_TrimAttributesLinkDescriptionPath>$(_XamarinSdkRootDirectory)tools/TrimAttributes.LinkDescription.xml</_TrimAttributesLinkDescriptionPath>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --link-attributes $(_TrimAttributesLinkDescriptionPath)</_ExtraTrimmerArgs>
</PropertyGroup>
Expand Down

0 comments on commit 6c5e3f5

Please sign in to comment.