From f927b985725c2f6ba2bb38908d0d1440bf980b15 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 9 Aug 2021 21:39:55 -0500 Subject: [PATCH 1/2] [MonoAOTCompiler] accept more than one AotProfilePath Fixes part of: https://github.com/dotnet/runtime/issues/56989 The Android workload needs to be able to pass in multiple AOT profiles to the `` MSBuild task. We plan on shipping a default profile in the Android workload, as well as the MAUI workload. .NET MAUI would have two profiles when using profiled AOT. Adding `profile-only`, and then multiple `profile` arguments is currently working in legacy Xamarin.Android: https://github.com/xamarin/xamarin-android/blob/77895e2a03ed91fdf3729cde54501f91e7d1a36f/src/Xamarin.Android.Build.Tasks/Tasks/GetAotArguments.cs#L256-L260 Either a single property or item group can be passed in for `AotProfilePath` now. I avoided changing the name, as it looks like it might be used by wasm. --- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index ab27947c15a7a2..8801b4dcf2ceb7 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -111,7 +111,7 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task /// /// File to use for profile-guided optimization, *only* the methods described in the file will be AOT compiled. /// - public string? AotProfilePath { get; set; } + public string[]? AotProfilePath { get; set; } /// /// List of profilers to use. @@ -219,10 +219,16 @@ public override bool Execute() return false; } - if (!string.IsNullOrEmpty(AotProfilePath) && !File.Exists(AotProfilePath)) + if (AotProfilePath != null) { - Log.LogError($"'{AotProfilePath}' doesn't exist.", nameof(AotProfilePath)); - return false; + foreach (var path in AotProfilePath) + { + if (!File.Exists(path)) + { + Log.LogError($"'{path}' doesn't exist."); + return false; + } + } } if (UseLLVM) @@ -491,9 +497,13 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths) aotAssembly.SetMetadata("AotDataFile", aotDataFile); } - if (!string.IsNullOrEmpty(AotProfilePath)) + if (AotProfilePath?.Length > 0) { - aotArgs.Add($"profile={AotProfilePath},profile-only"); + aotArgs.Add("profile-only"); + foreach (var path in AotProfilePath) + { + aotArgs.Add($"profile={path}"); + } } // we need to quote the entire --aot arguments here to make sure it is parsed From 697eb0909025f0eaf65ee1caa88777b9d3598424 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 10 Aug 2021 08:28:08 -0500 Subject: [PATCH 2/2] Update src/tasks/AotCompilerTask/MonoAOTCompiler.cs Co-authored-by: Ankit Jain --- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 8801b4dcf2ceb7..f19da50dae47f0 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -225,7 +225,7 @@ public override bool Execute() { if (!File.Exists(path)) { - Log.LogError($"'{path}' doesn't exist."); + Log.LogError($"AotProfilePath '{path}' doesn't exist."); return false; } }