Skip to content

Commit

Permalink
[wasm] Add beginnings of support for building with ICU. (#38977)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
  • Loading branch information
vargaz and akoeplinger committed Jul 9, 2020
1 parent 16840f3 commit 8c1792d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 6 deletions.
4 changes: 4 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
<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>
Expand Down
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
<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>
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
<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>
Expand Down
7 changes: 5 additions & 2 deletions src/mono/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,10 @@
<_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 -->
Expand Down
7 changes: 5 additions & 2 deletions src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions src/mono/wasm/icu-init.proj
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 2 additions & 1 deletion src/mono/wasm/wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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>

0 comments on commit 8c1792d

Please sign in to comment.