diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets
index c4d067319f998f..35cb31310f0814 100644
--- a/src/mono/wasm/build/WasmApp.Native.targets
+++ b/src/mono/wasm/build/WasmApp.Native.targets
@@ -323,6 +323,7 @@
<_WasmSourceFileToCompile Remove="@(_WasmSourceFileToCompile)" />
<_WasmSourceFileToCompile Include="@(_WasmRuntimePackSrcFile)" Dependencies="%(_WasmRuntimePackSrcFile.Dependencies);$(_EmccDefaultFlagsRsp);$(_EmccCompileRsp)" />
+
<_BitCodeFile Dependencies="%(_BitCodeFile.Dependencies);$(_EmccDefaultFlagsRsp);$(_EmccCompileBitcodeRsp)" />
+ <_WasmSourceFileToCompileSequentially Include="@(WasmAssemblyToAOTSequentially -> '%(Identity).bc')" />
@@ -350,6 +352,7 @@
Arguments=""@$(_EmccDefaultFlagsRsp)" "@$(_EmccCompileBitcodeRsp)""
EnvironmentVariables="@(EmscriptenEnvVars)"
DisableParallelCompile="$(DisableParallelEmccCompile)"
+ SourceFileNamesToCompileSequentially="@(_WasmSourceFileToCompileSequentially)"
OutputMessageImportance="$(_EmccCompileOutputMessageImportance)">
diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets
index d9a5f1f06ed70f..c20ce76c05f152 100644
--- a/src/mono/wasm/build/WasmApp.targets
+++ b/src/mono/wasm/build/WasmApp.targets
@@ -69,6 +69,7 @@
- $(WasmSIMD) - Enable support for the WASM SIMD feature.
Public items:
+ - @(WasmAssemblyToAOTSequentially) - Filenames of assemblies to always compile (to .o) sequentially
- @(WasmExtraFilesToDeploy) - Files to copy to $(WasmAppDir).
(relative path can be set via %(TargetPath) metadata)
- @(WasmFilesToIncludeInFileSystem) - Files to include in the vfs
diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs
index cec8460e6251fc..dde5e91ae2ec7e 100644
--- a/src/tasks/WasmAppBuilder/EmccCompile.cs
+++ b/src/tasks/WasmAppBuilder/EmccCompile.cs
@@ -35,6 +35,7 @@ public class EmccCompile : Microsoft.Build.Utilities.Task
public string Arguments { get; set; } = string.Empty;
public string? WorkingDirectory { get; set; }
public string OutputMessageImportance{ get; set; } = "Low";
+ public string[] SourceFileNamesToCompileSequentially { get; set; } = Array.Empty();
[Output]
public ITaskItem[]? OutputFiles { get; private set; }
@@ -80,6 +81,7 @@ private bool ExecuteActual()
_totalFiles = SourceFiles.Length;
IDictionary envVarsDict = GetEnvironmentVariablesDict();
ConcurrentBag outputItems = new();
+ ConcurrentBag<(string srcFile, string objFile)> filesToCompileSequentially = new();
try
{
List<(string, string)> filesToCompile = new();
@@ -96,15 +98,21 @@ private bool ExecuteActual()
{
Log.LogMessage(MessageImportance.Low, $"Skipping {srcFile} because {reason}.");
outputItems.Add(CreateOutputItemFor(srcFile, objFile));
+ continue;
}
- else
+
+ if (SourceFileNamesToCompileSequentially.Contains(Path.GetFileName(srcFile)))
{
- Log.LogMessage(MessageImportance.Low, $"Compiling {srcFile} because {reason}.");
- filesToCompile.Add((srcFile, objFile));
+ Log.LogMessage(MessageImportance.Low, $"Compiling {srcFile} because {reason}. It will be compiled at the end, sequentially.");
+ filesToCompileSequentially.Add((srcFile, objFile));
+ continue;
}
+
+ Log.LogMessage(MessageImportance.Low, $"Compiling {srcFile} because {reason}.");
+ filesToCompile.Add((srcFile, objFile));
}
- _numCompiled = SourceFiles.Length - filesToCompile.Count;
+ _numCompiled = SourceFiles.Length - (filesToCompile.Count + filesToCompileSequentially.Count);
if (_numCompiled == _totalFiles)
{
// nothing to do!
@@ -165,7 +173,18 @@ all assigned to that one partition.
});
if (!result.IsCompleted && !Log.HasLoggedErrors)
- Log.LogError("Unknown failure occurred while compiling. Check logs to get more details.");
+ {
+ Log.LogError("Unknown failure occured while compiling. Check logs to get more details.");
+ }
+ else if (!Log.HasLoggedErrors && !filesToCompileSequentially.IsEmpty)
+ {
+ Log.LogMessage(MessageImportance.High, "Compiling sequentially ...");
+ foreach ((string srcFile, string objFile) in filesToCompileSequentially)
+ {
+ if (!ProcessSourceFile(srcFile, objFile))
+ break;
+ }
+ }
if (!Log.HasLoggedErrors)
{