Skip to content

Commit

Permalink
[dotnet] Make 'Full' the default link mode for NativeAOT. (#18734)
Browse files Browse the repository at this point in the history
Make 'Full' the default link mode for all platforms for NativeAOT because:

* It will achieve the best app size.
* NativeAOT is not a drop-in replacement that's guaranteed to work - there are
  already known features NativeAOT don't support (and may never support), so
  this may be an opportunity for app developers (and component vendors) to
  make their products trimmer safe.
* NativeAOT will be in preview in .NET 8, so we can change our mind later if
  it turns out to cause too many problems.
* In some cases NativeAOT might require trimming, because we may
  optimize/rewrite assemblies to be NativeAOT-compatible to support existing
  libraries.

This requires #18666 to be merged first, so that ests aren't linked away.
  • Loading branch information
rolfbjarne authored Aug 22, 2023
1 parent 7a797a2 commit c024223
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1641,8 +1641,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TrimMode)' == ''">
<!-- Linking is always on for all assemblies when using NativeAOT - this is because we need to modify all assemblies in the linker for them to be compatible with NativeAOT -->
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true' And '$(_PlatformName)' == 'macOS'">Full</_DefaultLinkMode>
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true' And '$(_PlatformName)' != 'macOS'">SdkOnly</_DefaultLinkMode>
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true'">Full</_DefaultLinkMode>

<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'macOS'">None</_DefaultLinkMode> <!-- Linking is off by default for macOS apps -->
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly</_DefaultLinkMode> <!-- Default linking is on for release builds for Mac Catalyst apps -->
Expand Down

6 comments on commit c024223

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.