Allow the icu native code to be linked out when invariant globalization is enabled...
authorZoltan Varga <vargaz@gmail.com>
Tue, 16 Feb 2021 00:25:56 +0000 (19:25 -0500)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 00:25:56 +0000 (19:25 -0500)
* Disable the dynamic loading of icu functions on WASM.

* Preserve GetICUVersion using a DynamicDependency attribute so its only preserved for the tests which need it.

* Add GetICUVersion to .LibraryBuild.xml so its retained during the class libs build.

* Set InvariantGlobalization based on WasmInvariantGlobalization.

* Fix the framework build.

* Avoid linking in the libicu libraries on wasm in invariant mode.

* Move ICU tests dependency to libraries build descriptor file

* Hook up the shared file in the build

* Fix conditionals.

* Remove WasmInvariantGlobalization msbuild variable.

Co-authored-by: Marek Safar <marek.safar@gmail.com>
src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml
src/libraries/System.Private.CoreLib/src/ILLink/ILLinkTrim_LibraryBuild.xml [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/mono/CMakeLists.txt
src/mono/wasm/build/WasmApp.targets

index ad014dc..3fe9dc5 100644 (file)
@@ -1,9 +1,5 @@
 <linker>
   <assembly fullname="System.Private.CoreLib">
-    <type fullname="Interop/Globalization">
-      <!-- Internal API used by tests only. -->
-      <method name="GetICUVersion" />
-    </type>
     <type fullname="System.Threading.ThreadPoolBoundHandle">
       <!-- Workaround to keep .interfaceimpl even though this type
              is not instantiated on unix:
diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLinkTrim_LibraryBuild.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLinkTrim_LibraryBuild.xml
new file mode 100644 (file)
index 0000000..53a41af
--- /dev/null
@@ -0,0 +1,8 @@
+<linker>
+  <assembly fullname="System.Private.CoreLib">
+    <type fullname="Interop/Globalization">
+      <!-- Internal API used by tests only. -->
+      <method name="GetICUVersion" />
+    </type>
+  </assembly>
+</linker>
index 8408056..01918ee 100644 (file)
@@ -41,6 +41,9 @@
     <ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.NoX86Intrinsics.xml" Condition="'$(SupportsX86Intrinsics)' != 'true'" />
     <ILLinkLinkAttributesXmls Include="$(ILLinkSharedDirectory)ILLink.LinkAttributes.Shared.xml" />
   </ItemGroup>
+  <PropertyGroup>
+    <ILLinkTrimXmlLibraryBuild>$(ILLinkSharedDirectory)ILLinkTrim_LibraryBuild.xml</ILLinkTrimXmlLibraryBuild>
+  </PropertyGroup>
   <ItemGroup>
     <Compile Include="$(MSBuildThisFileDirectory)Internal\AssemblyAttributes.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Internal\Console.cs" />
index e0bc915..b502956 100644 (file)
@@ -216,6 +216,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 ?
index 6fd32a0..bc743a9 100644 (file)
@@ -23,7 +23,7 @@
       - $(WasmProfilers)     - Profilers to use
       - $(AOTMode)           - Defaults to `LLVMOnly`
       - $(AOTProfilePath)    - profile data file to be used for profile-guided optimization
-      - $(WasmInvariantGlobalization)
+      - $(InvariantGlobalization)       - Whenever to disable ICU. Defaults to false.
 
       - $(WasmResolveAssembliesBeforeBuild) - Resolve the assembly dependencies. Defaults to false
       - $(WasmAssemblySearchPaths)          - used for resolving assembly dependencies
     <Error Condition="'$(WasmMainJSPath)' == ''" Text="%24(WasmMainJSPath) property needs to be set" />
 
     <PropertyGroup>
-      <WasmIcuDataFileName Condition="'$(WasmInvariantGlobalization)' != 'true'">icudt.dat</WasmIcuDataFileName>
+      <WasmIcuDataFileName Condition="'$(InvariantGlobalization)' != 'true'">icudt.dat</WasmIcuDataFileName>
 
       <_HasDotnetWasm Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.wasm'">true</_HasDotnetWasm>
       <_HasDotnetJs Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js'">true</_HasDotnetJs>
       <WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native\dotnet.wasm" Condition="'$(_HasDotnetWasm)' != 'true'" />
       <WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native\dotnet.js" Condition="'$(_HasDotnetJs)' != 'true'" />
 
-      <WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native\$(WasmIcuDataFileName)" Condition="'$(WasmInvariantGlobalization)' != 'true'" />
+      <WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native\$(WasmIcuDataFileName)" Condition="'$(InvariantGlobalization)' != 'true'" />
       <WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidDir)native\dotnet.timezones.blat" />
     </ItemGroup>
 
       AppDir="$(WasmAppDir)"
       MainJS="$(WasmMainJSPath)"
       Assemblies="@(_WasmAssemblies)"
-      InvariantGlobalization="$(WasmInvariantGlobalization)"
+      InvariantGlobalization="$(InvariantGlobalization)"
       SatelliteAssemblies="@(WasmSatelliteAssemblies)"
       FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
       IcuDataFileName="$(WasmIcuDataFileName)"
      <_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="'$(InvariantGlobalization)' != 'true'" />
+     <_WasmRuntimePackNativeLibs Include="libicui18n.a" Condition="'$(InvariantGlobalization)' != 'true'" />
      <_WasmObjects Include="@(_WasmRuntimePackNativeLibs->'$(MicrosoftNetCoreAppRuntimePackRidDir)\native\%(FileName)%(Extension)')" />
 
      <_WasmObjects Include="$(_WasmIntermediateOutputPath)driver.o"/>