Skip to content

Commit c613692

Browse files
[release/8.0.1xx-xcode15.1] Enable dedup optimization in FullAOT mode only (#20701)
## Description This PR enables the dedup optimization in FullAOT mode only. The optimization can only run in FullAOT mode with complete application context. Without it, the AOT compiler may fail to collect all generic instances, and the runtime can't find them as they are searched in the dedup assembly. ## Changes This PR updates the SDK targets to enable dedup optimization in FullAOT mode only. This change doesn't depend on any runtime changes. ## Verification This PR also introduces partial AOT tests. They inspect the bundle for `aot-instances.dll`, which shouldn't be generated in a partial AOT compilation setup. Additionally, basic functionality is tested by asserting at app startup. ## Additional notes This change should be backported to .NET 8 as well. Fixes dotnet/runtime#99248 Backport of #20687 --------- Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com>
1 parent 8bab6a8 commit c613692

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,9 @@
10511051

10521052
<_AOTInputDirectory>$(_IntermediateNativeLibraryDir)aot-input/</_AOTInputDirectory>
10531053
<_AOTOutputDirectory>$(_IntermediateNativeLibraryDir)aot-output/</_AOTOutputDirectory>
1054-
<_IsDedupEnabled Condition="'$(_IsDedupEnabled)' == ''">true</_IsDedupEnabled>
1055-
<_DedupAssembly Condition="'$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true' And '$(_IsDedupEnabled)' == 'true'">$(IntermediateOutputPath)aot-instances.dll</_DedupAssembly>
1054+
<!-- Enable dedup optimization only in FullAOT mode -->
1055+
<_IsDedupEnabled Condition="'$(_IsDedupEnabled)' == '' And '$(_RunAotCompiler)' == 'true' And '$(MtouchInterpreter)' == '' And '$(IsMacEnabled)' == 'true'">true</_IsDedupEnabled>
1056+
<_DedupAssembly Condition="'$(_IsDedupEnabled)' == 'true'">$(IntermediateOutputPath)aot-instances.dll</_DedupAssembly>
10561057

10571058
<!-- default to 'static' for Mac Catalyst to work around https://github.com/xamarin/xamarin-macios/issues/14686 -->
10581059
<_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static</_LibMonoLinkMode>
@@ -1174,7 +1175,7 @@
11741175
</Target>
11751176

11761177
<Target Name="_CreateAOTDedupAssembly"
1177-
Condition="'$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true'"
1178+
Condition="'$(_IsDedupEnabled)' == 'true'"
11781179
DependsOnTargets="_ComputeManagedAssemblyToLink"
11791180
BeforeTargets="PrepareForILLink"
11801181
Inputs="$(MSBuildThisFileFullPath)"

0 commit comments

Comments
 (0)