Skip to content

Commit

Permalink
Allow the icu native code to be linked out when invariant globalizati…
Browse files Browse the repository at this point in the history
…on is enabled. (#48120)

* 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>
  • Loading branch information
vargaz and marek-safar committed Feb 16, 2021
1 parent 56d0eb9 commit 2e36f1b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
1 change: 1 addition & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand Down
12 changes: 6 additions & 6 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,7 +156,7 @@
<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>
Expand All @@ -167,15 +167,15 @@
<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>

<WasmAppBuilder
AppDir="$(WasmAppDir)"
MainJS="$(WasmMainJSPath)"
Assemblies="@(_WasmAssemblies)"
InvariantGlobalization="$(WasmInvariantGlobalization)"
InvariantGlobalization="$(InvariantGlobalization)"
SatelliteAssemblies="@(WasmSatelliteAssemblies)"
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
IcuDataFileName="$(WasmIcuDataFileName)"
Expand Down Expand Up @@ -250,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"/>
<_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"/>
Expand Down

0 comments on commit 2e36f1b

Please sign in to comment.