Add beginnings of WebAssembly build support for mono. (#33551)
authorZoltan Varga <vargaz@gmail.com>
Fri, 10 Apr 2020 10:17:58 +0000 (06:17 -0400)
committerGitHub <noreply@github.com>
Fri, 10 Apr 2020 10:17:58 +0000 (12:17 +0200)
* Set emcc as the compiler for libraries build

* Add default subsets for webassembly build

* Fix various problems in the build

* Use WebAssembly Docker image

* Use Mono runtime for webassembly builds

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
19 files changed:
eng/Subsets.props
eng/native/build-commons.sh
eng/native/configureplatform.cmake
eng/native/configuretools.cmake
eng/native/gen-buildsys.sh
eng/pipelines/common/platform-matrix.yml
eng/pipelines/libraries/base-job.yml
eng/pipelines/libraries/build-job.yml
eng/pipelines/mono/templates/build-job.yml
eng/pipelines/runtime.yml
src/libraries/Native/Unix/CMakeLists.txt
src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt
src/libraries/Native/Unix/System.Native/CMakeLists.txt
src/libraries/Native/Unix/System.Native/pal_runtimeinformation.c
src/libraries/Native/Unix/configure.cmake
src/libraries/Native/build-native.sh
src/mono/Directory.Build.props
src/mono/mono.proj
src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj

index 135e0e5..edaaefc 100644 (file)
@@ -39,6 +39,7 @@
   <PropertyGroup>
     <DefaultSubsets>clr+mono+libs+installer</DefaultSubsets>
     <DefaultSubsets Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'tvOS'">mono+libs+installer</DefaultSubsets>
+    <DefaultSubsetCategories Condition="'$(TargetOS)' == 'WebAssembly'">mono+libs</DefaultSubsetCategories>
   </PropertyGroup>
 
   <PropertyGroup>
@@ -66,7 +67,7 @@
   </PropertyGroup>
 
   <PropertyGroup>
-    <RuntimeFlavor Condition="'$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android'">Mono</RuntimeFlavor>
+    <RuntimeFlavor Condition="'$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'WebAssembly'">Mono</RuntimeFlavor>
     <RuntimeFlavor Condition="'$(RuntimeFlavor)' == '' and $(_subset.Contains('+mono.runtime+')) and !$(_subset.Contains('+clr.runtime+'))">Mono</RuntimeFlavor>
     <RuntimeFlavor Condition="'$(RuntimeFlavor)' == ''">CoreCLR</RuntimeFlavor>
   </PropertyGroup>
index 9c93eb9..425ed7d 100755 (executable)
@@ -151,8 +151,13 @@ build_native()
 
         popd
     else
-        echo "Executing cmake --build \"$intermediatesDir\" --target install -j $__NumProc"
-        cmake --build "$intermediatesDir" --target install -j "$__NumProc"
+        cmake_command=cmake
+        if [[ "$build_arch" == "wasm" ]]; then
+            cmake_command="emcmake $cmake_command"
+        fi
+
+        echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -j $__NumProc"
+        $cmake_command --build "$intermediatesDir" --target install -j "$__NumProc"
     fi
 
     local exit_code="$?"
index b366c6e..e28bad6 100644 (file)
@@ -166,7 +166,8 @@ if(CLR_CMAKE_HOST_OS STREQUAL Windows)
 endif(CLR_CMAKE_HOST_OS STREQUAL Windows)
 
 if(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
-    set(CLR_CMAKE_HOST_ARCH_WASM 1)
+    #set(CLR_CMAKE_HOST_UNIX 1) # TODO: this should be reenabled but it activates a bunch of additional compiler flags in configurecompiler.cmake
+    set(CLR_CMAKE_HOST_UNIX_WASM 1)
 endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
 
 #--------------------------------------------
@@ -196,6 +197,9 @@ elseif(CLR_CMAKE_HOST_UNIX_AMD64)
 elseif(CLR_CMAKE_HOST_UNIX_X86)
     set(CLR_CMAKE_HOST_ARCH_I386 1)
     set(CLR_CMAKE_HOST_ARCH "x86")
+elseif(CLR_CMAKE_HOST_UNIX_WASM)
+    set(CLR_CMAKE_HOST_ARCH_WASM 1)
+    set(CLR_CMAKE_HOST_ARCH "wasm")
 elseif(WIN32)
     # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
     if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
@@ -237,6 +241,8 @@ if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
     set(CLR_CMAKE_TARGET_ARCH_ARM 1)
     set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
     set(ARM_SOFTFP 1)
+  elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
+    set(CLR_CMAKE_TARGET_ARCH_WASM 1)
   else()
     clr_unknown_arch()
 endif()
@@ -306,6 +312,12 @@ if(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
     set(CLR_CMAKE_TARGET_SUNOS 1)
 endif(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
 
+if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
+    set(CLR_CMAKE_TARGET_UNIX 1)
+    set(CLR_CMAKE_TARGET_LINUX 1)
+    set(CLR_CMAKE_TARGET_EMSCRIPTEN 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
+
 if(CLR_CMAKE_TARGET_UNIX)
     if(CLR_CMAKE_TARGET_ARCH STREQUAL x64)
         set(CLR_CMAKE_TARGET_UNIX_AMD64 1)
@@ -317,6 +329,8 @@ if(CLR_CMAKE_TARGET_UNIX)
         set(CLR_CMAKE_TARGET_UNIX_ARM64 1)
     elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
         set(CLR_CMAKE_TARGET_UNIX_X86 1)
+    elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
+        set(CLR_CMAKE_TARGET_UNIX_WASM 1)
     else()
         clr_unknown_arch()
     endif()
@@ -343,7 +357,7 @@ else()
     endif()
 endif()
 
-if(NOT CLR_CMAKE_HOST_ARCH_WASM)
+if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
     # Skip check_pie_supported call on Android as ld from llvm toolchain with NDK API level 21
     # complains about missing linker flag `-no-pie` (while level 28's ld does support this flag,
     # but since we know that PIE is supported, we can safely skip this redundant check).
@@ -363,7 +377,7 @@ if(NOT CLR_CMAKE_HOST_ARCH_WASM)
     endif(NOT CLR_CMAKE_TARGET_ANDROID)
 
     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-endif(NOT CLR_CMAKE_HOST_ARCH_WASM)
+endif(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
 
 string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
 if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)
index 653c315..b63ab0f 100644 (file)
@@ -6,7 +6,7 @@ if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$")
   set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}")
 endif()
 
-if(NOT WIN32)
+if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
   if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
     if(APPLE)
       set(TOOLSET_PREFIX "")
index 4e39d16..f27bb33 100755 (executable)
@@ -87,6 +87,10 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then
     cmake_command="$SCAN_BUILD_COMMAND $cmake_command"
 fi
 
+if [[ "$build_arch" == "wasm" ]]; then
+    cmake_command="emcmake $cmake_command"
+fi
+
 # Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching
 $cmake_command \
   -G "$generator" \
index 2061511..fe0765b 100644 (file)
@@ -169,7 +169,7 @@ jobs:
       archType: wasm
       platform: WebAssembly_wasm
       container:
-        image: ubuntu-16.04-20200401182342-fe8b85d
+        image: ubuntu-18.04-webassembly-20200409132031-f70ea41
         registry: mcr
       jobParameters:
         runtimeFlavor: ${{ parameters.runtimeFlavor }}
index c1d343e..0208840 100644 (file)
@@ -63,6 +63,7 @@ jobs:
         - ${{ if and(eq(parameters.osGroup, 'Linux'), eq(parameters.osSubGroup, ''), eq(parameters.archType, 'arm')) }}:
           - _runtimeOSArg: /p:RuntimeOS=ubuntu.16.04
 
+        # force a value for OS when cross-building WebAssembly
         - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
           - _runtimeOSArg: -os ${{ parameters.osGroup }}
 
@@ -107,10 +108,6 @@ jobs:
           - _runtimeArtifactsPathArg: ' /p:RuntimeArtifactsPath=$(_runtimeDownloadPath)'
           - _testRunNamePrefixSuffix: $(runtimeFlavorName)_${{ parameters.liveRuntimeBuildConfig }}
 
-          # WebAssembly uses linux implementation detail
-          - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
-            - _runtimeArtifactName: 'CoreLib_Linux_x64_${{ parameters.liveRuntimeBuildConfig }}'
-
         # Windows variables
         - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
           - _runtimeOSArg: /p:RuntimeOS=win10
index 6fa4b12..3a1af6d 100644 (file)
@@ -49,21 +49,18 @@ jobs:
 
       ${{ if ne(parameters.liveRuntimeBuildConfig, '') }}:
         dependsOn:
-        - ${{ if ne(parameters.osGroup, 'WebAssembly') }}:
-          # Use corelib dependencies for coreclr and non test builds
-          - ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.testScope, '')) }}:
-            - ${{ format('coreclr_corelib_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.liveRuntimeBuildConfig) }}
-          - ${{ if or(ne(parameters.runtimeFlavor, 'coreclr'), ne(parameters.testScope, '')) }}:
-            - ${{ format('{0}_product_build_{1}{2}_{3}_{4}', parameters.runtimeFlavor, parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.liveRuntimeBuildConfig) }}
-        - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
-          - ${{ format('coreclr_corelib_build_{1}{2}_{3}_{4}', parameters.runtimeFlavor, 'linux', parameters.osSubgroup, 'x64', parameters.liveRuntimeBuildConfig) }}
+        # Use corelib dependencies for coreclr and non test builds
+        - ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.testScope, '')) }}:
+          - ${{ format('coreclr_corelib_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.liveRuntimeBuildConfig) }}
+        - ${{ if or(ne(parameters.runtimeFlavor, 'coreclr'), ne(parameters.testScope, '')) }}:
+          - ${{ format('{0}_product_build_{1}{2}_{3}_{4}', parameters.runtimeFlavor, parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.liveRuntimeBuildConfig) }}
 
       variables:
         - _subset: libs
         - _addtionalBuildArguments: ''
         - ${{ parameters.variables }}
         - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
-          - EMSDK_PATH: $(Build.BinariesDirectory)/emsdk
+          - EMSDK_PATH: /usr/local/emscripten
         - ${{ if eq(parameters.runTests, true) }}:
           - _subset: libs+libs.tests
           - _addtionalBuildArguments: /p:ArchiveTests=true
@@ -80,15 +77,6 @@ jobs:
               ln -s /usr/local/opt/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/
             displayName: Install Build Dependencies
 
-        - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
-          - script: |
-              EMSCRIPTEN_VERSION=1.38.47
-              git clone https://github.com/emscripten-core/emsdk.git $(EMSDK_PATH)
-              cd $(EMSDK_PATH)
-              ./emsdk install ${EMSCRIPTEN_VERSION}-upstream
-              ./emsdk activate --embedded ${EMSCRIPTEN_VERSION}-upstream
-            displayName: Install Emscripten
-
         - ${{ if eq(parameters.isOfficialBuild, true) }}:
           - template: /eng/pipelines/common/restore-internal-tools.yml
             parameters:
index 14c18d4..40f952d 100644 (file)
@@ -74,6 +74,13 @@ jobs:
     - ${{ if eq(parameters.osGroup, 'Android') }}:
       - name: osOverride
         value: -os Android
+    - ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
+      - name: EMSDK_PATH
+        value: /usr/local/emscripten
+      - name: archType
+        value: wasm
+      - name: osOverride
+        value: '-os WebAssembly'
     - ${{ parameters.variables }}
 
     steps:
index cded9f4..9e90f79 100644 (file)
@@ -266,6 +266,7 @@ jobs:
     - Linux_arm
     - Linux_arm64
     - Linux_musl_x64
+    - WebAssembly_wasm
     # - Linux_musl_arm64
     - Windows_NT_x64
     # - Windows_NT_x86
@@ -302,6 +303,7 @@ jobs:
     - Linux_arm
     - Linux_arm64
     - Linux_musl_x64
+    - WebAssembly_wasm
     # - Linux_musl_arm64
     - Windows_NT_x64
     # - Windows_NT_x86
@@ -420,6 +422,7 @@ jobs:
     # - iOS_arm # https://github.com/dotnet/runtime/issues/34465
     - iOS_arm64
     - iOS_x64
+    - WebAssembly_wasm
     jobParameters:
       liveRuntimeBuildConfig: release
 
@@ -438,6 +441,7 @@ jobs:
     # - iOS_arm # https://github.com/dotnet/runtime/issues/34465
     - iOS_arm64
     - iOS_x64
+    - WebAssembly_wasm
     jobParameters:
       liveRuntimeBuildConfig: debug
 
@@ -449,7 +453,6 @@ jobs:
     jobTemplate: /eng/pipelines/libraries/build-job.yml
     buildConfig: ${{ variables.debugOnPrReleaseOnRolling }}
     platforms:
-    - WebAssembly_wasm
     - ${{ if eq(variables['isFullMatrix'], false) }}:
       - Windows_NT_x86
     jobParameters:
index 3efe849..76742dd 100644 (file)
@@ -64,6 +64,9 @@ elseif (CLR_CMAKE_TARGET_ARCH_I386)
     add_definitions(-DTARGET_32BIT=1)
     add_definitions(-DTARGET_X86)
     add_definitions(-D_FILE_OFFSET_BITS=64)
+elseif (CLR_CMAKE_TARGET_ARCH_WASM)
+    add_definitions(-DTARGET_32BIT=1)
+    add_definitions(-DTARGET_WASM)
 elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
     add_definitions(-DTARGET_64BIT=1)
     add_definitions(-DTARGET_ARM64)
index 1cd9ca7..3315941 100644 (file)
@@ -1,6 +1,6 @@
 project(System.IO.Compression.Native C)
 
-if (CLR_CMAKE_TARGET_WASM)
+if (CLR_CMAKE_TARGET_ARCH_WASM)
     add_definitions(-s USE_ZLIB)
 elseif (CLR_CMAKE_TARGET_ANDROID)
     # need special case here since we want to link against libz.so but find_package() would resolve libz.a
index 698cf37..2c3da0d 100644 (file)
@@ -30,7 +30,7 @@ else ()
     set(NATIVE_SOURCES ${NATIVE_SOURCES} pal_console.c)
 endif ()
 
-if (CLR_CMAKE_TARGET_LINUX)
+if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
     set(NATIVE_SOURCES ${NATIVE_SOURCES} pal_networkchange.c)
 
     if (!HAVE_LINUX_RTNETLINK_H)
index 16ae31f..ac83f78 100644 (file)
@@ -51,7 +51,7 @@ int32_t SystemNative_GetOSArchitecture()
     return ARCH_ARM64;
 #elif defined(TARGET_AMD64)
     return ARCH_X64;
-#elif defined(TARGET_X86)
+#elif defined(TARGET_X86) || defined(TARGET_WASM) // TODO: add arch for WASM
     return ARCH_X86;
 #else
 #error Unidentified Architecture
@@ -71,7 +71,7 @@ int32_t SystemNative_GetProcessArchitecture()
     return ARCH_ARM64;
 #elif defined(TARGET_AMD64)
     return ARCH_X64;
-#elif defined(TARGET_X86)
+#elif defined(TARGET_X86) || defined(TARGET_WASM) // TODO: add arch for WASM
     return ARCH_X86;
 #else
 #error Unidentified Architecture
index 5538a6d..4846ab0 100644 (file)
@@ -10,6 +10,8 @@ include(CheckTypeSize)
 
 if (CLR_CMAKE_TARGET_ANDROID)
     set(PAL_UNIX_NAME \"ANDROID\")
+elseif (CLR_CMAKE_TARGET_ARCH_WASM)
+    set(PAL_UNIX_NAME \"WEBASSEMBLY\")
 elseif (CLR_CMAKE_TARGET_LINUX)
     set(PAL_UNIX_NAME \"LINUX\")
 elseif (CLR_CMAKE_TARGET_OSX)
@@ -28,8 +30,6 @@ elseif (CLR_CMAKE_TARGET_FREEBSD)
     set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
 elseif (CLR_CMAKE_TARGET_NETBSD)
     set(PAL_UNIX_NAME \"NETBSD\")
-elseif (CLR_CMAKE_TARGET_ARCH_WASM)
-    set(PAL_UNIX_NAME \"WEBASSEMBLY\")
 else ()
     message(FATAL_ERROR "Unknown platform.  Cannot define PAL_UNIX_NAME, used by RuntimeInformation.")
 endif ()
@@ -839,7 +839,7 @@ set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES})
 set (HAVE_INOTIFY 0)
 if (HAVE_INOTIFY_INIT AND HAVE_INOTIFY_ADD_WATCH AND HAVE_INOTIFY_RM_WATCH)
     set (HAVE_INOTIFY 1)
-elseif (CLR_CMAKE_TARGET_LINUX)
+elseif (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
     message(FATAL_ERROR "Cannot find inotify functions on a Linux platform.")
 endif()
 
index 0bc559a..1e8faa9 100755 (executable)
@@ -49,10 +49,13 @@ source "$__RepoRootDir"/eng/native/build-commons.sh
 
 if [[ "$__BuildArch" == wasm ]]; then
     if [[ -z "$EMSDK_PATH" ]]; then
-        echo "Error: Should set EMSDK_PATH environment variable pointing to emsdk root."
+        echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root."
         exit 1
     fi
     source "$EMSDK_PATH"/emsdk_env.sh
+
+    export CLR_CC=$(which emcc)
+    export CLR_CXX=$(which em++)
 elif [[ "$__TargetOS" == iOS ]]; then
     # nothing to do here
     true
index ec3d5f6..fed776d 100644 (file)
@@ -42,8 +42,9 @@
     <TargetsiOSSimulator Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x64'">true</TargetsiOSSimulator>
     <TargetstvOSSimulator Condition="'$(TargetstvOS)' == 'true' and '$(Platform)' == 'x64'">true</TargetstvOSSimulator>
     <TargetsAndroid Condition="'$(TargetOS)' == 'Android'">true</TargetsAndroid>
+    <TargetsWASM Condition="'$(TargetOS)' == 'WebAssembly'">true</TargetsWASM>
     <TargetsWindows Condition="'$(TargetOS)' == 'Windows_NT'">true</TargetsWindows>
-    <TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'">true</TargetsUnix>
+    <TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsWASM)' == 'true'">true</TargetsUnix>
   </PropertyGroup>
 
   <PropertyGroup>
index f4f43c2..5906a2a 100644 (file)
@@ -20,6 +20,8 @@
     <MonoStaticFileName Condition="'$(TargetsiOS)' == 'true'">libmono.a</MonoStaticFileName>
     <MonoStaticFileName Condition="'$(TargetstvOS)' == 'true'">libmono.a</MonoStaticFileName>
     <MonoStaticFileName Condition="'$(TargetsAndroid)' == 'true'">libmonosgen-2.0.a</MonoStaticFileName>
+    <MonoFileName Condition="'$(TargetsWASM)' == 'true'">libmono.a</MonoFileName>
+    <MonoStaticFileName Condition="'$(TargetsWASM)' == 'true'">libmono.a</MonoStaticFileName>
     <MonoFileName Condition="'$(MonoFileName)' == ''">$(CoreClrFileName)</MonoFileName>
     <CoreClrTestConfig Condition="'$(CoreClrTestConfig)' == ''">$(Configuration)</CoreClrTestConfig>
     <LibrariesTestConfig Condition="'$(LibrariesTestConfig)' == ''">$(Configuration)</LibrariesTestConfig>
       <_MonoSTRIPOption>STRIP="$(_MonoTuple)-strip"</_MonoSTRIPOption>
     </PropertyGroup>
 
+    <Error Condition="'$(TargetsWASM)' == 'true' and '$(EMSDK_PATH)' == ''" Text="The EMSDK_PATH environment variable should be set pointing to the emscripten SDK root dir."/>
+
+    <!-- WASM specific options -->
+    <ItemGroup Condition="'$(TargetsWASM)' == 'true'">
+      <_MonoConfigureParams Include="--host=wasm32"/>
+      <_MonoConfigureParams Include="--disable-boehm" />
+      <_MonoConfigureParams Include="--disable-btls" />
+      <_MonoConfigureParams Include="--disable-executables" />
+      <_MonoConfigureParams Include="--disable-iconv" />
+      <_MonoConfigureParams Include="--disable-mcs-build" />
+      <_MonoConfigureParams Include="--disable-nls" />
+      <_MonoConfigureParams Include="--disable-visibility-hidden" />
+      <_MonoConfigureParams Include="--enable-maintainer-mode" />
+      <_MonoConfigureParams Include="--enable-llvm-runtime"/>
+      <_MonoConfigureParams Include="--enable-icall-export"/>
+      <_MonoConfigureParams Include="--disable-icall-tables"/>
+      <_MonoConfigureParams Include="--disable-crash-reporting"/>
+      <_MonoConfigureParams Include="--with-bitcode=yes"/>
+      <_MonoConfigureParams Include="--enable-minimal=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,full_messages,appdomains,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"/>
+      <!-- FIXME: -Os -->
+      <_MonoCFLAGS Include="-fexceptions" />
+      <_MonoCXXFLAGS Include="-fexceptions -s DISABLE_EXCEPTION_CATCHING=0" />
+      <_MonoAC_VARS Include="ac_cv_func_shm_open_working_with_mmap=no" />
+    </ItemGroup>
+
     <!-- Linux options -->
     <ItemGroup Condition="'$(TargetsLinux)' == true">
       <_MonoCFLAGS Include="-Wl,--build-id" />
       <_MonoLDFLAGSOption Condition="@(_MonoLDFLAGS->Count()) &gt; 0">LDFLAGS="@(_MonoLDFLAGS, ' ')"</_MonoLDFLAGSOption>
       <_MonoCCLDFLAGSOption Condition="@(_MonoCCLDFLAGS->Count()) &gt; 0">CCLDFLAGS="@(_MonoCCLDFLAGS, ' ')"</_MonoCCLDFLAGSOption>
 
-      <_MonoConfigureCommand>@(_MonoConfigureParams, ' ') @(_MonoAC_VARS, ' ') $(_MonoCFLAGSOption) $(_MonoCXXFLAGSOption) $(_MonoCPPFLAGSOption) $(_MonoCXXCPPFLAGSOption) $(_MonoLDFLAGSOption) $(_MonoCCLDFLAGSOption) $(_MonoCCOption) $(_MonoCXXOption) $(_MonoAROption) $(_MonoASOption) $(_MonoCPPOption) $(_MonoCXXCPPOption) $(_MonoDLLTOOLOption) $(_MonoLDOption) $(_MonoOBJDUMPOption) $(_MonoRANLIBOption) $(_MonoCMAKEOption) $(_MonoSTRIPOption)</_MonoConfigureCommand>
-      <_MonoConfigureCommand Condition="'$(_MonoCCOption)' == '' and '$(_MonoCXXOption)' == ''">bash -c 'source $(RepositoryEngineeringDir)native/init-compiler.sh $(Platform) clang &amp;&amp; $(MonoProjectRoot)configure $(_MonoConfigureCommand)'</_MonoConfigureCommand>
-      <_MonoConfigureCommand Condition="'$(_MonoCCOption)' != '' and '$(_MonoCXXOption)' != ''">$(MonoProjectRoot)configure $(_MonoConfigureCommand)</_MonoConfigureCommand>
+      <_MonoConfigureOptions>@(_MonoConfigureParams, ' ') @(_MonoAC_VARS, ' ') $(_MonoCFLAGSOption) $(_MonoCXXFLAGSOption) $(_MonoCPPFLAGSOption) $(_MonoCXXCPPFLAGSOption) $(_MonoLDFLAGSOption) $(_MonoCCLDFLAGSOption) $(_MonoCCOption) $(_MonoCXXOption) $(_MonoAROption) $(_MonoASOption) $(_MonoCPPOption) $(_MonoCXXCPPOption) $(_MonoDLLTOOLOption) $(_MonoLDOption) $(_MonoOBJDUMPOption) $(_MonoRANLIBOption) $(_MonoCMAKEOption) $(_MonoSTRIPOption)</_MonoConfigureOptions>
+      <_MonoConfigureCommand Condition="'$(_MonoCCOption)' == '' and '$(_MonoCXXOption)' == ''">bash -c 'source $(RepositoryEngineeringDir)native/init-compiler.sh $(Platform) clang &amp;&amp; $(MonoProjectRoot)configure $(_MonoConfigureOptions)'</_MonoConfigureCommand>
+      <_MonoConfigureCommand Condition="'$(_MonoCCOption)' != '' and '$(_MonoCXXOption)' != ''">$(MonoProjectRoot)configure $(_MonoConfigureOptions)</_MonoConfigureCommand>
+      <_MonoConfigureCommand Condition="'$(TargetsWASM)' == 'true'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; emconfigure $(MonoProjectRoot)configure $(_MonoConfigureOptions)'</_MonoConfigureCommand>
     </PropertyGroup>
 
     <!-- AOT cross-compiler specific options -->
     <!-- Configure target runtime -->
     <MakeDir Directories="$(MonoObjDir)" />
     <Message Text="--- Configuring Mono with '$(_MonoConfigureCommand)' ---" Importance="High" />
-    <Exec Command="NOCONFIGURE=1 $(MonoProjectRoot)autogen.sh" />
+    <Exec Command="NOCONFIGURE=1 $(MonoProjectRoot)autogen.sh" IgnoreStandardErrorWarningFormat="true"/>
     <Exec Command="$(_MonoConfigureCommand)" WorkingDirectory="$(MonoObjDir)" IgnoreStandardErrorWarningFormat="true" />
     <Touch Files="$(MonoObjDir)config.h" />
 
 
   <Target Name="BuildMonoRuntimeUnix" Condition="'$(OS)' != 'Windows_NT'" DependsOnTargets="ConfigureMonoRuntimeUnix">
     <Message Text="--- Building Mono ---" Importance="High" />
-    <Exec Command="make -j$([System.Environment]::ProcessorCount)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />
+    <Exec Condition="'$(TargetsWASM)' != 'true'" Command="make -j$([System.Environment]::ProcessorCount)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />
+    <Exec Condition="'$(TargetsWASM)' == 'true'" Command="bash -c 'source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; make -j$([System.Environment]::ProcessorCount)'" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />
     <Exec Condition="'$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'" Command="make install -j$([System.Environment]::ProcessorCount)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />
 
     <Message Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'" Text="--- Building Mono AOT cross-compiler ---" Importance="High" />
       <_MonoRuntimeFilePath Condition="'$(TargetsiOS)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
       <_MonoRuntimeFilePath Condition="'$(TargetstvOS)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
       <_MonoRuntimeFilePath Condition="'$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.so</_MonoRuntimeFilePath>
+      <_MonoRuntimeFilePath Condition="'$(TargetsWASM)' == 'true'">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.a</_MonoRuntimeFilePath>
       <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.so</_MonoRuntimeFilePath>
       <_MonoRuntimeStaticFilePath Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a</_MonoRuntimeStaticFilePath>
       <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm64'">$(MonoObjDir)cross\out\bin\aarch64-darwin-mono-sgen</_MonoAotCrossFilePath>
     <Copy SourceFiles="@(_MonoIncludeArtifacts)"
           DestinationFiles="@(_MonoIncludeArtifacts->'$(BinDir)include\%(RecursiveDir)%(Filename)%(Extension)')"
           SkipUnchangedFiles="true"
-          Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or'$(TargetsAndroid)' == 'true'"/>
+          Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or'$(TargetsAndroid)' == 'true' or '$(TargetsWASM)' == 'true'"/>
 
     <Exec Condition="'$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" Command="install_name_tool -id @rpath/$(MonoFileName) $(BinDir)$(MonoFileName)" />
   </Target>
index 20ccd6c..48967bb 100644 (file)
@@ -18,7 +18,7 @@
     <!-- Force System.Private.CoreLib.dll into a special IL output directory -->
     <OutputPath>$(BinDir)IL/</OutputPath>
     <Configurations>Debug;Release;Checked</Configurations>
-    <Platforms>x64;x86;arm;arm64;wasm32</Platforms>
+    <Platforms>x64;x86;arm;arm64;wasm</Platforms>
 
     <ILLinkClearInitLocals>true</ILLinkClearInitLocals>
     <ILLinkTrimAssembly>true</ILLinkTrimAssembly>
@@ -82,7 +82,7 @@
     <PlatformTarget>AnyCPU</PlatformTarget>
     <DefineConstants>TARGET_64BIT;TARGET_ARM64;$(DefineConstants)</DefineConstants>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Platform)' == 'wasm32'">
+  <PropertyGroup Condition="'$(Platform)' == 'wasm'">
     <PlatformTarget>AnyCPU</PlatformTarget>
     <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
   </PropertyGroup>