Skip to content

Commit 5dbdd82

Browse files
authored
[dotnet] Adjust the default trimming mode to not trim when using CoreCLR. (#24206)
1 parent 41f7a7c commit 5dbdd82

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

dotnet/targets/Xamarin.Shared.Sdk.Trimming.props

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,33 @@
4848
</PropertyGroup>
4949
<PropertyGroup Condition="'$(TrimMode)' == ''">
5050
<!-- 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 -->
51-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' == 'true'">Full</_DefaultLinkMode>
52-
53-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'macOS'">None</_DefaultLinkMode> <!-- Linking is off by default for macOS apps -->
54-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly</_DefaultLinkMode> <!-- Default linking is on for release builds for Mac Catalyst apps -->
55-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release' And $(RuntimeIdentifier.Contains('arm64'))">SdkOnly</_DefaultLinkMode> <!-- Default linking is on for non-release builds for Mac Catalyst apps when building for arm64 -->
56-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release' And !$(RuntimeIdentifier.Contains('arm64'))">None</_DefaultLinkMode> <!-- Default linking is off for non-release builds for Mac Catalyst apps when not building for arm64 -->
57-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' == 'true' And $(RuntimeIdentifier.Contains('arm64')) And '$(MtouchInterpreter)' == ''">SdkOnly</_DefaultLinkMode> <!-- Linking is on by default in the simulator when building for arm64, as long as the interpreter is not enabled -->
58-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' == 'true' And (!$(RuntimeIdentifier.Contains('arm64')) Or '$(MtouchInterpreter)' != '')">None</_DefaultLinkMode> <!-- Linking is off by default in the simulator when not building for arm64 -->
59-
<_DefaultLinkMode Condition="'$(_UseNativeAot)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst' And '$(_SdkIsSimulator)' != 'true'">SdkOnly</_DefaultLinkMode> <!-- Linking is SdkOnly for iOS/tvOS apps on device -->
51+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_UseNativeAot)' == 'true'">Full</_DefaultLinkMode>
52+
53+
<!-- Linking is off by default when using CoreCLR -->
54+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(UseMonoRuntime)' != 'true'">None</_DefaultLinkMode>
55+
56+
<!-- Default linking is on for release builds for Mac Catalyst apps -->
57+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' == 'Release'">SdkOnly</_DefaultLinkMode>
58+
<!-- Default linking is on for non-release builds for Mac Catalyst apps when building for arm64 -->
59+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release' And $(RuntimeIdentifier.Contains('arm64'))">SdkOnly</_DefaultLinkMode>
60+
<!-- Default linking is off for non-release builds for Mac Catalyst apps when not building for arm64 -->
61+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst' And '$(Configuration)' != 'Release' And !$(RuntimeIdentifier.Contains('arm64'))">None</_DefaultLinkMode>
62+
<!-- Otherwise, default linking is off for Mac Catalyst (this is just a safety net, because all possible scenarios should be handled already) -->
63+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">None</_DefaultLinkMode>
64+
65+
<!-- Linking is on by default in the simulator when building for arm64, as long as the interpreter is not enabled -->
66+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_SdkIsSimulator)' == 'true' And $(RuntimeIdentifier.Contains('arm64')) And '$(MtouchInterpreter)' == ''">SdkOnly</_DefaultLinkMode>
67+
<!-- Linking is off by default in the simulator when not building for arm64 -->
68+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_SdkIsSimulator)' == 'true' And (!$(RuntimeIdentifier.Contains('arm64')) Or '$(MtouchInterpreter)' != '')">None</_DefaultLinkMode>
69+
<!-- Otherwise, default linking is SdkOnly for iOS/tvOS apps -->
70+
<_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == ''">SdkOnly</_DefaultLinkMode>
71+
6072
</PropertyGroup>
6173
<PropertyGroup>
6274
<_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">$(LinkMode)</_LinkMode>
6375
<_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">$(MtouchLink)</_LinkMode>
6476
<_LinkMode Condition="'$(_LinkMode)' == ''">$(_DefaultLinkMode)</_LinkMode>
65-
<_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' == 'macOS'">None</_LinkMode> <!-- Linking is off by default for macOS apps -->
66-
<_LinkMode Condition="'$(_LinkMode)' == '' And '$(_PlatformName)' != 'macOS'">SdkOnly</_LinkMode> <!-- Default linking is SdkOnly for iOS/tvOS apps -->
77+
<_LinkMode Condition="'$(_LinkMode)' == ''">SdkOnly</_LinkMode> <!-- We shouldn't ever hit this, but if we do, default to SdkOnly if no other scenario fits -->
6778

6879
<!-- TrimMode specifies what the linker will do with framework assemblies -->
6980
<TrimMode Condition="'$(_LinkMode)' == 'TrimMode'">$(TrimMode)</TrimMode>

0 commit comments

Comments
 (0)