[wasm] Add beginnings of support for building with ICU. (#38977)
authorZoltan Varga <vargaz@gmail.com>
Thu, 9 Jul 2020 23:06:22 +0000 (19:06 -0400)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 23:06:22 +0000 (01:06 +0200)
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
eng/Subsets.props
eng/Version.Details.xml
eng/Versions.props
src/mono/configure.ac
src/mono/mono.proj
src/mono/wasm/Makefile
src/mono/wasm/icu-init.proj [new file with mode: 0644]
src/mono/wasm/wasm.targets

index b27d1e5..1ee5239 100644 (file)
     <ProjectToBuild Include="$(MonoProjectRoot)llvm\llvm-init.proj" Category="mono" />
   </ItemGroup>
 
+  <ItemGroup Condition="'$(TargetOS)' == 'Browser'">
+    <ProjectToBuild Include="$(MonoProjectRoot)wasm\icu-init.proj" Category="mono" />
+  </ItemGroup>
+
   <ItemGroup Condition="$(_subset.Contains('+mono.runtime+'))">
     <ProjectToBuild Include="$(MonoProjectRoot)mono.proj" Category="mono" />
   </ItemGroup>
index 03d6fa5..97502a6 100644 (file)
       <Uri>https://github.com/dotnet/runtime-assets</Uri>
       <Sha>629993236116221fba87fe1de6d7893dd02c3722</Sha>
     </Dependency>
+    <Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="5.0.0-preview.8.20359.5">
+      <Uri>https://github.com/dotnet/icu</Uri>
+      <Sha />
+    </Dependency>
     <Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="9.0.1-alpha.1.20356.1">
       <Uri>https://github.com/dotnet/llvm-project</Uri>
       <Sha>266c9f5b5c1e94333e01ca77fa74d76563969842</Sha>
index 50c9c29..246794d 100644 (file)
     <MicrosoftPrivateIntellisenseVersion>3.0.0-preview-20200602.3</MicrosoftPrivateIntellisenseVersion>
     <!-- ILLink -->
     <MicrosoftNETILLinkTasksVersion>5.0.0-preview.3.20359.3</MicrosoftNETILLinkTasksVersion>
+    <!-- ICU -->
+    <MicrosoftNETCoreRuntimeICUTransportVersion>5.0.0-preview.8.20359.5</MicrosoftNETCoreRuntimeICUTransportVersion>
     <!-- Mono LLVM -->
     <runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>9.0.1-alpha.1.20356.1</runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion>
     <runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>9.0.1-alpha.1.20356.1</runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMToolsVersion>
index befd0f6..bab7614 100644 (file)
@@ -146,7 +146,7 @@ case "$host" in
                CFLAGS="$CFLAGS -D_REENTRANT -D_GNU_SOURCE -s WASM=1"
                CPPFLAGS="$CPPFLAGS -D_REENTRANT -DUSE_MMAP -s WASM=1"
                libgc_threads=pthreads
-               platform_wasm=yes
+               host_wasm=yes
                # FIXME:
                RID="osx-x64"
                COREARCH="wasm32"
@@ -584,7 +584,7 @@ AM_CONDITIONAL(HOST_SIGPOSIX, test x$use_sigposix = xyes)
 AM_CONDITIONAL(HOST_ANDROID, test x$platform_android = xyes)
 AM_CONDITIONAL(HOST_TIZEN, test x$platform_tizen = xyes)
 AM_CONDITIONAL(HOST_IOS, test x$platform_ios = xyes)
-AM_CONDITIONAL(HOST_WASM, test x$platform_wasm = xyes)
+AM_CONDITIONAL(HOST_WASM, test x$host_wasm = xyes)
 AM_CONDITIONAL(HOST_AIX, test x$host_aix = xyes)
 
 if test -z "$HOST_DARWIN_TRUE"; then :
@@ -6867,6 +6867,9 @@ if test x$with_core = xonly; then
                elif test x$host_sunos = xyes; then
                        ICU_CFLAGS="-DPALEXPORT="" -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option"
                        have_sys_icu=yes
+               elif test x$host_wasm = xyes; then
+                       ICU_CFLAGS="-DPALEXPORT="" -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option"
+                       have_sys_icu=yes
                else
                        GLOBALIZATION_SHIM_DEFINES="-DNO_GLOBALIZATION_SHIM"
                fi
index be67580..4fef851 100644 (file)
       <_MonoConfigureParams Include="--with-bitcode=yes"/>
       <_MonoConfigureParams Include="--enable-minimal=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,full_messages,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,logging,remoting,shared_perfcounters,sgen_debug_helpers,soft_debug,interpreter,assert_messages,cleanup,mdb,gac,threads,$(_MonoEnableMinimal)"/>
       <_MonoCFLAGS Include="-fexceptions" />
-      <_MonoCXXFLAGS Include="-fexceptions -s DISABLE_EXCEPTION_CATCHING=0" />
+      <_MonoCFLAGS Include="-I$(NuGetPackageRoot)/microsoft.netcore.runtime.icu.transport/$(MicrosoftNETCoreRuntimeICUTransportVersion)/runtimes/browser-wasm/native/include" />
+      <_MonoCXXFLAGS Include="-fexceptions" />
+      <_MonoCXXFLAGS Include="-I$(NuGetPackageRoot)/microsoft.netcore.runtime.icu.transport/$(MicrosoftNETCoreRuntimeICUTransportVersion)/runtimes/browser-wasm/native/include" />
+      <_MonoCXXFLAGS Include="-s DISABLE_EXCEPTION_CATCHING=0" />
       <_MonoAC_VARS Include="ac_cv_func_shm_open_working_with_mmap=no" />
 
       <!-- AOT cross-compiler configuration -->
index cf1a893..6fd3203 100644 (file)
@@ -15,6 +15,7 @@ PINVOKE_TABLE?=$(TOP)/artifacts/obj/wasm/pinvoke-table.h
 MONO_BIN_DIR?=$(BINDIR)/mono/Browser.wasm.$(CONFIG)
 NATIVE_DIR?=$(OBJDIR)/native/net5.0-Browser-$(CONFIG)-wasm
 BUILDS_BIN_DIR?=$(BINDIR)/native/net5.0-Browser-$(CONFIG)-wasm
+ICU_LIBDIR?=
 
 all: build-native timezone-data
 
@@ -51,7 +52,9 @@ MONO_LIBS = \
        $(MONO_BIN_DIR)/libmono-ilgen.a \
        $(MONO_BIN_DIR)/libmono-icall-table.a \
        ${NATIVE_DIR}/System.Native/libSystem.Native.a \
-       ${NATIVE_DIR}/System.IO.Compression.Native/libSystem.IO.Compression.Native.a
+       ${NATIVE_DIR}/System.IO.Compression.Native/libSystem.IO.Compression.Native.a \
+       $(ICU_LIBDIR)/libicuuc.a \
+       $(ICU_LIBDIR)/libicui18n.a
 
 EMCC_FLAGS=--profiling-funcs -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s ALIASING_FUNCTION_POINTERS=0 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']" -s "EXPORTED_FUNCTIONS=['_putchar']" --source-map-base http://example.com  -emit-llvm -s FORCE_FILESYSTEM=1 -s USE_ZLIB=1
 EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DENABLE_NETCORE=1 -DDEBUG=1
@@ -112,7 +115,7 @@ timezone-data:
        cp runtime/dotnet.timezones.blat $(BUILDS_BIN_DIR)
 
 runtime:
-       EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh --subset mono --arch wasm --os Browser -c $(CONFIG)
+       EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh --subset mono --arch wasm --os Browser -c $(CONFIG) /p:ContinueOnError=false  /p:StopOnFirstFailure=true
 
 build-all:
        EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh --subset mono+libs --arch wasm --os Browser -c $(CONFIG)
diff --git a/src/mono/wasm/icu-init.proj b/src/mono/wasm/icu-init.proj
new file mode 100644 (file)
index 0000000..4368893
--- /dev/null
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.Build.NoTargets">
+
+  <!-- This project installs the wasm ICU nupkg -->
+
+  <PropertyGroup>
+    <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.NETCore.Runtime.ICU.Transport" PrivateAssets="all" Version="$(MicrosoftNETCoreRuntimeICUTransportVersion)" GeneratePathProperty="true" />
+  </ItemGroup>
+
+</Project>
index f92ffb7..b3aa4c1 100644 (file)
@@ -10,6 +10,7 @@
   <ItemGroup>
     <WasmPInvokeModules Include="libSystem.Native"/>
     <WasmPInvokeModules Include="libSystem.IO.Compression.Native"/>
+    <WasmPInvokeModules Include="libSystem.Globalization.Native"/>
     <WasmPInvokeAssemblies Include="$(MonoArtifactsPath)\System.Private.CoreLib.dll"/>
     <WasmPInvokeAssemblies Include="$(ArtifactsBinDir)\System.Runtime\$(NetCoreAppCurrent)-$(Configuration)\System.Runtime.dll"/>
     <WasmPInvokeAssemblies Include="$(ArtifactsBinDir)\System.Console\$(NetCoreAppCurrent)-Browser-$(Configuration)\System.Console.dll"/>
@@ -41,7 +42,7 @@
 
   <Target Name="BuildWasmRuntimes"
           DependsOnTargets="BuildPInvokeTable">
-    <Exec Command="make -C $(MonoProjectRoot)wasm all SHELL=/bin/bash BINDIR=$(ArtifactsBinDir) MONO_BIN_DIR=$(MonoArtifactsPath) OBJDIR=$(ArtifactsObjDir) BUILDS_BIN_DIR=$(NativeBinDir) NATIVE_DIR=$(ArtifactsObjDir)/native/$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) CONFIG=$(Configuration) PINVOKE_TABLE=$(WasmPInvokeTablePath)" IgnoreStandardErrorWarningFormat="true"/>
+    <Exec Command="make -C $(MonoProjectRoot)wasm all SHELL=/bin/bash BINDIR=$(ArtifactsBinDir) MONO_BIN_DIR=$(MonoArtifactsPath) OBJDIR=$(ArtifactsObjDir) BUILDS_BIN_DIR=$(NativeBinDir) NATIVE_DIR=$(ArtifactsObjDir)/native/$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) CONFIG=$(Configuration) PINVOKE_TABLE=$(WasmPInvokeTablePath) ICU_LIBDIR=$(NuGetPackageRoot)/microsoft.netcore.runtime.icu.transport/$(MicrosoftNETCoreRuntimeICUTransportVersion)/runtimes/browser-wasm/native/lib" IgnoreStandardErrorWarningFormat="true"/>
   </Target>
 
 </Project>