From 4a23e8e2a0984568b774fe5ae689003926a4fd3d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 27 Jan 2025 19:04:29 +0100 Subject: [PATCH] rebase --- eng/testing/tests.browser.targets | 2 ++ eng/testing/tests.wasi.targets | 2 ++ eng/testing/tests.wasm.targets | 4 +++- src/mono/browser/browser.proj | 6 +++--- src/mono/browser/build/BrowserWasmApp.targets | 2 +- src/mono/browser/build/WasmApp.InTree.targets | 6 +++--- ...rosoft.NET.Sdk.WebAssembly.Browser.targets | 8 ++++---- src/mono/sample/Directory.Build.targets | 2 +- src/mono/wasm/build/WasmApp.Common.targets | 12 ++++++------ .../wasm/build/WasmApp.LocalBuild.targets | 6 +++--- src/tasks/AotCompilerTask/MonoAOTCompiler.cs | 12 ++++++++++-- .../EmitBundleTask/EmitBundleBase.cs | 12 ++++++++++-- src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs | 13 +++++++++++-- src/tasks/WasmAppBuilder/EmccCompile.cs | 12 ++++++++++-- src/tasks/WasmAppBuilder/ForceMSBuildGC.cs | 19 +++++++++++++++++++ src/tests/build.proj | 2 +- .../build/Microsoft.NET.ILLink.targets | 4 ++-- 17 files changed, 91 insertions(+), 33 deletions(-) create mode 100644 src/tasks/WasmAppBuilder/ForceMSBuildGC.cs diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index e7029f44e21915..d591b8a608bebe 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -207,6 +207,8 @@ + + diff --git a/eng/testing/tests.wasi.targets b/eng/testing/tests.wasi.targets index 39642c413d0613..066c4391ad4503 100644 --- a/eng/testing/tests.wasi.targets +++ b/eng/testing/tests.wasi.targets @@ -129,6 +129,8 @@ TargetPath="%(WasmFilesToIncludeFromPublishDir.Identity)" Condition="'%(WasmFilesToIncludeFromPublishDir.Identity)' != ''" /> + + diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index eee739184828fa..65ab8ed35de7f8 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -91,7 +91,9 @@ + AssemblyFile="$(WasmBuildTasksAssemblyPath)" TaskFactory="TaskHostFactory" /> + + diff --git a/src/mono/browser/browser.proj b/src/mono/browser/browser.proj index 5ab8d0407a7751..95f56cea27e8cc 100644 --- a/src/mono/browser/browser.proj +++ b/src/mono/browser/browser.proj @@ -1,6 +1,6 @@ - + @@ -49,7 +49,7 @@ - + $(WasmObjDir)\pinvoke-table.h @@ -81,7 +81,7 @@ - + <_WasmTimezonesPath>$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) diff --git a/src/mono/browser/build/BrowserWasmApp.targets b/src/mono/browser/build/BrowserWasmApp.targets index 2e611016df020a..ac43cf31e1d11f 100644 --- a/src/mono/browser/build/BrowserWasmApp.targets +++ b/src/mono/browser/build/BrowserWasmApp.targets @@ -7,7 +7,7 @@ - + diff --git a/src/mono/browser/build/WasmApp.InTree.targets b/src/mono/browser/build/WasmApp.InTree.targets index 885a3fba37ea8b..8babff1f7489f2 100644 --- a/src/mono/browser/build/WasmApp.InTree.targets +++ b/src/mono/browser/build/WasmApp.InTree.targets @@ -1,8 +1,8 @@ - - - + + + diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index 1596acac199074..8fa97e16cb21b7 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -54,10 +54,10 @@ Copyright (c) .NET Foundation. All rights reserved. true - - - - + + + + true diff --git a/src/mono/sample/Directory.Build.targets b/src/mono/sample/Directory.Build.targets index ad0054cc1be7f1..5f7e4e32316bb7 100644 --- a/src/mono/sample/Directory.Build.targets +++ b/src/mono/sample/Directory.Build.targets @@ -1,5 +1,5 @@ - + RunTests.sh diff --git a/src/mono/wasm/build/WasmApp.Common.targets b/src/mono/wasm/build/WasmApp.Common.targets index be718671187a1c..d37350ecf80ad8 100644 --- a/src/mono/wasm/build/WasmApp.Common.targets +++ b/src/mono/wasm/build/WasmApp.Common.targets @@ -105,12 +105,12 @@ - @(EmccExportedFunction) - Extra function for emcc flag EXPORTED_FUNCTIONS --> - - - - - - + + + + + + diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.targets b/src/mono/wasm/build/WasmApp.LocalBuild.targets index 19f025670984ba..bedbba30750c07 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.targets +++ b/src/mono/wasm/build/WasmApp.LocalBuild.targets @@ -22,9 +22,9 @@ - - - + + + true diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index c4a37b083d982e..7ae3255fac5bee 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -542,8 +542,16 @@ private bool ExecuteInternal() { int allowedParallelism = DisableParallelAot ? 1 : Math.Min(_assembliesToCompile.Count, Environment.ProcessorCount); IBuildEngine9? be9 = BuildEngine as IBuildEngine9; - if (be9 is not null) - allowedParallelism = be9.RequestCores(allowedParallelism); + try + { + if (be9 is not null) + allowedParallelism = be9.RequestCores(allowedParallelism); + } + catch(NotImplementedException) + { + // RequestCores is not implemented in TaskHostFactory + be9 = null; + } /* From: https://github.com/dotnet/runtime/issues/46146#issuecomment-754021690 diff --git a/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs b/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs index af96acb2444922..40aac49edb70bf 100644 --- a/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs +++ b/src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs @@ -155,8 +155,16 @@ public override bool Execute() // Generate source file(s) containing each resource's byte data and size int allowedParallelism = Math.Max(Math.Min(bundledResources.Count, Environment.ProcessorCount), 1); IBuildEngine9? be9 = BuildEngine as IBuildEngine9; - if (be9 is not null) - allowedParallelism = be9.RequestCores(allowedParallelism); + try + { + if (be9 is not null) + allowedParallelism = be9.RequestCores(allowedParallelism); + } + catch(NotImplementedException) + { + // RequestCores is not implemented in TaskHostFactory + be9 = null; + } try { diff --git a/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs b/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs index 34cc69f7752839..a71e2b69321f7d 100644 --- a/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs +++ b/src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs @@ -76,8 +76,17 @@ public override bool Execute() int allowedParallelism = DisableParallelStripping ? 1 : Math.Min(Assemblies.Length, Environment.ProcessorCount); IBuildEngine9? be9 = BuildEngine as IBuildEngine9; - if (be9 is not null) - allowedParallelism = be9.RequestCores(allowedParallelism); + try + { + if (be9 is not null) + allowedParallelism = be9.RequestCores(allowedParallelism); + } + catch(NotImplementedException) + { + // RequestCores is not implemented in TaskHostFactory + be9 = null; + } + try { ParallelLoopResult result = Parallel.ForEach(Assemblies, diff --git a/src/tasks/WasmAppBuilder/EmccCompile.cs b/src/tasks/WasmAppBuilder/EmccCompile.cs index f549f96c316bce..52a06ed6f306e9 100644 --- a/src/tasks/WasmAppBuilder/EmccCompile.cs +++ b/src/tasks/WasmAppBuilder/EmccCompile.cs @@ -132,8 +132,16 @@ private bool ExecuteActual() int allowedParallelism = DisableParallelCompile ? 1 : Math.Min(SourceFiles.Length, Environment.ProcessorCount); IBuildEngine9? be9 = BuildEngine as IBuildEngine9; - if (be9 is not null) - allowedParallelism = be9.RequestCores(allowedParallelism); + try + { + if (be9 is not null) + allowedParallelism = be9.RequestCores(allowedParallelism); + } + catch(NotImplementedException) + { + // RequestCores is not implemented in TaskHostFactory + be9 = null; + } /* From: https://github.com/dotnet/runtime/issues/46146#issuecomment-754021690 diff --git a/src/tasks/WasmAppBuilder/ForceMSBuildGC.cs b/src/tasks/WasmAppBuilder/ForceMSBuildGC.cs new file mode 100644 index 00000000000000..8ddf5d46bfefd5 --- /dev/null +++ b/src/tasks/WasmAppBuilder/ForceMSBuildGC.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.WebAssembly.Build.Tasks +{ + public class ForceMSBuildGC : Task + { + public override bool Execute() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + return true; + } + } +} diff --git a/src/tests/build.proj b/src/tests/build.proj index 289fd39e04b073..46c98e88dc51c3 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -291,7 +291,7 @@ - + diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 8c5e472f879cdf..eceaebf36f48a0 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -127,7 +127,7 @@ Copyright (c) .NET Foundation. All rights reserved. if the output semaphore file is out of date with respect to the inputs. ============================================================ --> - + - +