Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0.1xx-preview7] Enable dedup only when targeting ARM64 mobile platforms #20951

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Enable dedup only when targeting arm64 platforms
  • Loading branch information
ivanpovazan committed Jul 29, 2024
commit 66e5e7c5e205f8df95250cd498d29843982deedf
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@
In such setup, during runtime, AOT images are loaded but marked as unusuable as they are compiled with `full` compiler switch and the code fallsback to interpreter.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not accurate anymore, but lets clean up after we snap.

Dedup AOT image is specially handled by the AOT runtime and it is not allowed to have it marked as unusuable.
-->
<_IsDedupEnabled Condition="'$(_IsDedupEnabled)' == '' And '$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true' And '$(RuntimeIdentifier)' != 'maccatalyst-x64'">true</_IsDedupEnabled>
<_IsDedupEnabled Condition="'$(_IsDedupEnabled)' == '' And '$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true' And '$(TargetArchitectures)' == 'ARM64'">true</_IsDedupEnabled>
<_DedupAssembly Condition="'$(_IsDedupEnabled)' == 'true'">$(IntermediateOutputPath)aot-instances.dll</_DedupAssembly>

<!-- default to 'static' for Mac Catalyst to work around https://github.com/xamarin/xamarin-macios/issues/14686 -->
Expand Down
71 changes: 53 additions & 18 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2019,19 +2019,58 @@ bool FindAOTedAssemblyFile (string path, string dllName)
}

[Test]
[TestCase (ApplePlatform.iOS, "ios-arm64;", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "ios-arm64;", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "ios-arm64;", "-all")]
[TestCase (ApplePlatform.iOS, "ios-arm64;", "")]
[TestCase (ApplePlatform.iOS, "ios-arm64", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "ios-arm64", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "ios-arm64", "")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64", "")]
public void DedupEnabledTest (ApplePlatform platform, string runtimeIdentifiers, string mtouchInterpreter)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["MtouchInterpreter"] = $"\"{mtouchInterpreter}\"";

DotNet.AssertBuild (project_path, properties);

var objDir = GetObjDir (project_path, platform, runtimeIdentifiers);
Assert.True (FindAOTedAssemblyFile (objDir, "aot-instances.dll"), $"Dedup optimization should be enabled for AOT compilation on: {platform} with RID: {runtimeIdentifiers}");
}

[Test]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", "")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", "")]
public void DedupDisabledTest (ApplePlatform platform, string runtimeIdentifiers, string mtouchInterpreter)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["MtouchInterpreter"] = $"\"{mtouchInterpreter}\"";

DotNet.AssertBuild (project_path, properties);

var objDir = GetObjDir (project_path, platform, runtimeIdentifiers);
Assert.False (FindAOTedAssemblyFile (objDir, "aot-instances.dll"), $"Dedup optimization should not be enabled for AOT compilation on: {platform} with RID: {runtimeIdentifiers}");
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "-all")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64", "")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64;", "-all,System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64;", "all,-System.Private.CoreLib")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64;", "-all")]
[TestCase (ApplePlatform.TVOS, "tvos-arm64;", "")]
public void DedupEnabledTest (ApplePlatform platform, string runtimeIdentifiers, string mtouchInterpreter)
public void DedupUniversalAppTest (ApplePlatform platform, string runtimeIdentifiers, string mtouchInterpreter)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Expand All @@ -2045,15 +2084,11 @@ public void DedupEnabledTest (ApplePlatform platform, string runtimeIdentifiers,
DotNet.AssertBuild (project_path, properties);

var objDir = GetObjDir (project_path, platform, runtimeIdentifiers);
if (platform == ApplePlatform.MacCatalyst) {
var objDirMacCatalystArm64 = Path.Combine (objDir, "maccatalyst-arm64");
Assert.True (FindAOTedAssemblyFile (objDirMacCatalystArm64, "aot-instances.dll"), $"Dedup optimization should be enabled for AOT compilation on: {platform} with RID: maccatalyst-arm64");
var objDirMacCatalystArm64 = Path.Combine (objDir, "maccatalyst-arm64");
Assert.True (FindAOTedAssemblyFile (objDirMacCatalystArm64, "aot-instances.dll"), $"Dedup optimization should be enabled for AOT compilation on: {platform} with RID: maccatalyst-arm64");

var objDirMacCatalystx64 = Path.Combine (objDir, "maccatalyst-x64");
Assert.False (FindAOTedAssemblyFile (objDirMacCatalystx64, "aot-instances.dll"), $"Dedup optimization should not be enabled for AOT compilation on: {platform} with RID: maccatalyst-x64");
} else {
Assert.True (FindAOTedAssemblyFile (objDir, "aot-instances.dll"), $"Dedup optimization should be enabled for AOT compilation on: {platform} with RID: {runtimeIdentifiers}");
}
var objDirMacCatalystx64 = Path.Combine (objDir, "maccatalyst-x64");
Assert.False (FindAOTedAssemblyFile (objDirMacCatalystx64, "aot-instances.dll"), $"Dedup optimization should not be enabled for AOT compilation on: {platform} with RID: maccatalyst-x64");

var appExecutable = GetNativeExecutable (platform, appPath);

Expand Down