From 0919a5f3cbc776d3aacf30620a7dd46eccbae144 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 9 Feb 2021 22:54:43 -0500 Subject: [PATCH 01/10] Disable the dynamic loading of icu functions on WASM. --- src/mono/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index cf828d4af0ecfa..bdfa0628c5cd08 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -218,6 +218,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") # FIXME: Rest of the flags from configure.ac elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") set(HOST_BROWSER 1) + add_definitions(-DNO_GLOBALIZATION_SHIM) add_definitions(-D_THREAD_SAFE) set(DISABLE_EXECUTABLES 1) # FIXME: Is there a cmake option for this ? From 740d54fea15eff2f006e441e4272f104a7efb632 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 10 Feb 2021 14:19:37 -0500 Subject: [PATCH 02/10] Preserve GetICUVersion using a DynamicDependency attribute so its only preserved for the tests which need it. --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 1 + .../src/ILLink/ILLink.Descriptors.Shared.xml | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index f56404ff270243..1bde7eeadd0121 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -207,6 +207,7 @@ private static bool GetIsInvariantGlobalization() public static bool IsIcuGlobalization => ICUVersion > new Version(0,0,0,0); public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization; + [DynamicDependency("GetICUVersion", "Interop/Globalization", "System.Private.CoreLib")] private static Version GetICUVersion() { int version = 0; diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml index ad014dcaf50929..3fe9dc5f861b3f 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml @@ -1,9 +1,5 @@ - - - - + + From ff2f2da3ea3c30a84ecb3c34b5f8690a9062eda7 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 10 Feb 2021 19:33:09 -0500 Subject: [PATCH 04/10] Set InvariantGlobalization based on WasmInvariantGlobalization. --- src/mono/wasm/build/WasmApp.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 6fd32a0a01c981..9f6166fe8c1039 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -23,7 +23,7 @@ - $(WasmProfilers) - Profilers to use - $(AOTMode) - Defaults to `LLVMOnly` - $(AOTProfilePath) - profile data file to be used for profile-guided optimization - - $(WasmInvariantGlobalization) + - $(WasmInvariantGlobalization) - Whenever to disable ICU. Defaults to false. - $(WasmResolveAssembliesBeforeBuild) - Resolve the assembly dependencies. Defaults to false - $(WasmAssemblySearchPaths) - used for resolving assembly dependencies @@ -64,6 +64,7 @@ true $(RunAOTCompilation) $(MicrosoftNetCoreAppRuntimePackRidDir)native\cross\$(PackageRID)\mono-aot-cross + true From f142940b030fbfc42198d2a14f6802c1996dff81 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 10 Feb 2021 20:13:19 -0500 Subject: [PATCH 05/10] Fix the framework build. --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 5c9b35bb29ba03..0cea0bc41395af 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -208,7 +208,9 @@ private static bool GetIsInvariantGlobalization() public static bool IsIcuGlobalization => ICUVersion > new Version(0,0,0,0); public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization; +#if NETCOREAPP [DynamicDependency("GetICUVersion", "Interop/Globalization", "System.Private.CoreLib")] +#endif private static Version GetICUVersion() { int version = 0; From e8ce84a9c5798008ff83f7ab10b19fdb7bb5d7a3 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 10 Feb 2021 22:17:25 -0500 Subject: [PATCH 06/10] Avoid linking in the libicu libraries on wasm in invariant mode. --- src/mono/wasm/build/WasmApp.targets | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 9f6166fe8c1039..96b36918c24d4f 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -62,9 +62,10 @@ true $(WasmBuildNative) true + false $(RunAOTCompilation) $(MicrosoftNetCoreAppRuntimePackRidDir)native\cross\$(PackageRID)\mono-aot-cross - true + true @@ -251,8 +252,8 @@ <_WasmRuntimePackNativeLibs Include="libSystem.Native.a"/> <_WasmRuntimePackNativeLibs Include="libSystem.IO.Compression.Native.a"/> <_WasmRuntimePackNativeLibs Include="libmono-profiler-aot.a"/> - <_WasmRuntimePackNativeLibs Include="libicuuc.a"/> - <_WasmRuntimePackNativeLibs Include="libicui18n.a"/> + <_WasmRuntimePackNativeLibs Include="libicuuc.a" Condition="'$(WasmInvariantGlobalization)' == 'false'" /> + <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(WasmInvariantGlobalization)' == 'false'" /> <_WasmObjects Include="@(_WasmRuntimePackNativeLibs->'$(MicrosoftNetCoreAppRuntimePackRidDir)\native\%(FileName)%(Extension)')" /> <_WasmObjects Include="$(_WasmIntermediateOutputPath)driver.o"/> From 8b2b5356ae7a351e2761dafda4d676086b215f95 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 11 Feb 2021 15:34:10 +0100 Subject: [PATCH 07/10] Move ICU tests dependency to libraries build descriptor file --- .../tests/TestUtilities/System/PlatformDetection.cs | 4 ---- .../src/ILLink/ILLink.Suppressions.LibraryBuild.xml | 4 ---- .../src/ILLink/ILLink_LibraryBuild.xml | 8 ++++++++ 3 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 0cea0bc41395af..f56404ff270243 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Security; using System.Security.Authentication; @@ -208,9 +207,6 @@ private static bool GetIsInvariantGlobalization() public static bool IsIcuGlobalization => ICUVersion > new Version(0,0,0,0); public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization; -#if NETCOREAPP - [DynamicDependency("GetICUVersion", "Interop/Globalization", "System.Private.CoreLib")] -#endif private static Version GetICUVersion() { int version = 0; diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Suppressions.LibraryBuild.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Suppressions.LibraryBuild.xml index ca70f225978fe9..695f2477d9b08b 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Suppressions.LibraryBuild.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Suppressions.LibraryBuild.xml @@ -8,9 +8,5 @@ M:System.Resources.ManifestBasedResourceGroveler.CreateResourceSet(System.IO.Stream,System.Reflection.Assembly) This warning is left in the product so developers get an ILLink warning when trimming an app with System.Resources.ResourceManager.AllowCustomResourceTypes=true. - - - - diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml new file mode 100644 index 00000000000000..53a41aff8c935a --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml @@ -0,0 +1,8 @@ + + + + + + + + From 28d8a48960c68be6df0bc8fe56ea12b0e9d2c8e9 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 11 Feb 2021 18:32:01 +0100 Subject: [PATCH 08/10] Hook up the shared file in the build --- .../{ILLink_LibraryBuild.xml => ILLinkTrim_LibraryBuild.xml} | 0 .../src/System.Private.CoreLib.Shared.projitems | 3 +++ 2 files changed, 3 insertions(+) rename src/libraries/System.Private.CoreLib/src/ILLink/{ILLink_LibraryBuild.xml => ILLinkTrim_LibraryBuild.xml} (100%) diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLinkTrim_LibraryBuild.xml similarity index 100% rename from src/libraries/System.Private.CoreLib/src/ILLink/ILLink_LibraryBuild.xml rename to src/libraries/System.Private.CoreLib/src/ILLink/ILLinkTrim_LibraryBuild.xml diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 8408056788ff54..01918eedac5644 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -41,6 +41,9 @@ + + $(ILLinkSharedDirectory)ILLinkTrim_LibraryBuild.xml + From c0e949b48927bb89e361595a9cfc925ba89b7f65 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 11 Feb 2021 17:04:27 -0500 Subject: [PATCH 09/10] Fix conditionals. --- src/mono/wasm/build/WasmApp.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 96b36918c24d4f..1202076e6adcd8 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -252,8 +252,8 @@ <_WasmRuntimePackNativeLibs Include="libSystem.Native.a"/> <_WasmRuntimePackNativeLibs Include="libSystem.IO.Compression.Native.a"/> <_WasmRuntimePackNativeLibs Include="libmono-profiler-aot.a"/> - <_WasmRuntimePackNativeLibs Include="libicuuc.a" Condition="'$(WasmInvariantGlobalization)' == 'false'" /> - <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(WasmInvariantGlobalization)' == 'false'" /> + <_WasmRuntimePackNativeLibs Include="libicuuc.a" Condition="'$(WasmInvariantGlobalization)' != 'true'" /> + <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(WasmInvariantGlobalization)' != 'true'" /> <_WasmObjects Include="@(_WasmRuntimePackNativeLibs->'$(MicrosoftNetCoreAppRuntimePackRidDir)\native\%(FileName)%(Extension)')" /> <_WasmObjects Include="$(_WasmIntermediateOutputPath)driver.o"/> From 8e471a29d6ae8997b8970b1c4216e1a43ca8cbd9 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 15 Feb 2021 14:41:24 -0500 Subject: [PATCH 10/10] Remove WasmInvariantGlobalization msbuild variable. --- src/mono/wasm/build/WasmApp.targets | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 1202076e6adcd8..bc743a92253a03 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -23,7 +23,7 @@ - $(WasmProfilers) - Profilers to use - $(AOTMode) - Defaults to `LLVMOnly` - $(AOTProfilePath) - profile data file to be used for profile-guided optimization - - $(WasmInvariantGlobalization) - Whenever to disable ICU. Defaults to false. + - $(InvariantGlobalization) - Whenever to disable ICU. Defaults to false. - $(WasmResolveAssembliesBeforeBuild) - Resolve the assembly dependencies. Defaults to false - $(WasmAssemblySearchPaths) - used for resolving assembly dependencies @@ -62,10 +62,8 @@ true $(WasmBuildNative) true - false $(RunAOTCompilation) $(MicrosoftNetCoreAppRuntimePackRidDir)native\cross\$(PackageRID)\mono-aot-cross - true @@ -158,7 +156,7 @@ - icudt.dat + icudt.dat <_HasDotnetWasm Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.wasm'">true <_HasDotnetJs Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'">true @@ -169,7 +167,7 @@ - + @@ -177,7 +175,7 @@ AppDir="$(WasmAppDir)" MainJS="$(WasmMainJSPath)" Assemblies="@(_WasmAssemblies)" - InvariantGlobalization="$(WasmInvariantGlobalization)" + InvariantGlobalization="$(InvariantGlobalization)" SatelliteAssemblies="@(WasmSatelliteAssemblies)" FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)" IcuDataFileName="$(WasmIcuDataFileName)" @@ -252,8 +250,8 @@ <_WasmRuntimePackNativeLibs Include="libSystem.Native.a"/> <_WasmRuntimePackNativeLibs Include="libSystem.IO.Compression.Native.a"/> <_WasmRuntimePackNativeLibs Include="libmono-profiler-aot.a"/> - <_WasmRuntimePackNativeLibs Include="libicuuc.a" Condition="'$(WasmInvariantGlobalization)' != 'true'" /> - <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(WasmInvariantGlobalization)' != 'true'" /> + <_WasmRuntimePackNativeLibs Include="libicuuc.a" Condition="'$(InvariantGlobalization)' != 'true'" /> + <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(InvariantGlobalization)' != 'true'" /> <_WasmObjects Include="@(_WasmRuntimePackNativeLibs->'$(MicrosoftNetCoreAppRuntimePackRidDir)\native\%(FileName)%(Extension)')" /> <_WasmObjects Include="$(_WasmIntermediateOutputPath)driver.o"/>