Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beginnings of WebAssembly build support for mono. #33551

Merged
merged 10 commits into from
Apr 10, 2020
3 changes: 2 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<PropertyGroup>
<DefaultSubsetCategories>libraries-installer-coreclr-mono</DefaultSubsetCategories>
<DefaultSubsetCategories Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android'">libraries-installer-mono</DefaultSubsetCategories>
<DefaultSubsetCategories Condition="'$(TargetOS)' == 'WebAssembly'">libraries-mono</DefaultSubsetCategories>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -79,7 +80,7 @@
</PropertyGroup>

<PropertyGroup>
<RuntimeFlavor Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android'">Mono</RuntimeFlavor>
<RuntimeFlavor Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'WebAssembly'">Mono</RuntimeFlavor>
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == '' and $(_subsetCategory.Contains('mono')) and !$(_subsetCategory.Contains('coreclr'))">Mono</RuntimeFlavor>
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == ''">CoreCLR</RuntimeFlavor>
</PropertyGroup>
Expand Down
9 changes: 7 additions & 2 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="$?"
Expand Down
20 changes: 17 additions & 3 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,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)

#--------------------------------------------
Expand Down Expand Up @@ -184,6 +185,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)
Expand Down Expand Up @@ -225,6 +229,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()
Expand Down Expand Up @@ -289,6 +295,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)
Expand All @@ -300,6 +312,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()
Expand All @@ -326,7 +340,7 @@ else()
endif()
endif()

if(NOT CLR_CMAKE_HOST_ARCH_WASM)
if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
if(NOT CLR_CMAKE_TARGET_ANDROID) # Android requires PIC and CMake handles this so we don't need the check
# All code we build should be compiled as position independent
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
Expand All @@ -342,4 +356,4 @@ if(NOT CLR_CMAKE_TARGET_ANDROID) # Android requires PIC and CMake handles this s
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif(NOT CLR_CMAKE_TARGET_ANDROID)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)
endif(NOT CLR_CMAKE_TARGET_EMSCRIPTEN)
2 changes: 1 addition & 1 deletion eng/native/configuretools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
4 changes: 4 additions & 0 deletions eng/native/gen-buildsys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
archType: wasm
platform: WebAssembly_wasm
container:
image: ubuntu-16.04-20200401182342-fe8b85d
image: ubuntu-18.04-webassembly-20200407092345-059fef0
registry: mcr
jobParameters:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
Expand Down
11 changes: 1 addition & 10 deletions eng/pipelines/libraries/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- _addtionalBuildArguments: ''
- ${{ parameters.variables }}
- ${{ if eq(parameters.osGroup, 'WebAssembly') }}:
- EMSDK_PATH: $(Build.BinariesDirectory)/emsdk
- EMSDK_PATH: /usr/local/emscripten
- ${{ if eq(parameters.runTests, true) }}:
- _addtionalBuildArguments: /p:IncludeLibrariesTestSubset=true /p:ArchiveTests=true

Expand All @@ -78,15 +78,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:
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/mono/templates/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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:
Expand Down
1 change: 1 addition & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ jobs:
- Linux_arm
- Linux_arm64
- Linux_musl_x64
- WebAssembly_wasm
# - Linux_musl_arm64
- Windows_NT_x64
# - Windows_NT_x86
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,8 +28,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 ()
Expand Down Expand Up @@ -825,7 +825,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()

Expand Down
5 changes: 4 additions & 1 deletion src/libraries/Native/build-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Comment on lines +57 to +58
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit, typically posix-y command -v is preferred over which in this repo. (same goes for which false below)

Copy link
Member

@akoeplinger akoeplinger Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@am11 I tried that but it didn't work since we expect the full path in CLR_CC and command -v doesn't do that (for false at least)

elif [[ "$__TargetOS" == iOS ]]; then
# nothing to do here
true
Expand Down
3 changes: 2 additions & 1 deletion src/mono/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<TargetsiOSSimulator Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x64'">true</TargetsiOSSimulator>
<TargetsAndroid Condition="'$(TargetOS)' == 'Android'">true</TargetsAndroid>
<TargetsWindows Condition="'$(TargetOS)' == 'Windows_NT'">true</TargetsWindows>
<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'">true</TargetsUnix>
<TargetsWASM Condition="'$(TargetOS)' == 'WebAssembly'">true</TargetsWASM>
<TargetsUnix Condition="'$(TargetsFreeBSD)' == 'true' or '$(TargetsLinux)' == 'true' or '$(TargetsNetBSD)' == 'true' or '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsWASM)' == 'true'">true</TargetsUnix>
</PropertyGroup>

<PropertyGroup>
Expand Down
43 changes: 37 additions & 6 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<MonoFileName Condition="'$(TargetsAndroid)' == 'true'">libmonosgen-2.0.so</MonoFileName>
<MonoStaticFileName Condition="'$(TargetsiOS)' == '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>
Expand Down Expand Up @@ -411,6 +413,31 @@
<_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" />
Expand Down Expand Up @@ -443,9 +470,10 @@
<_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 -->
Expand All @@ -464,7 +492,7 @@
<!-- 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" />

Expand All @@ -480,7 +508,9 @@

<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="'$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'" Command="make install -j$([System.Environment]::ProcessorCount)" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MonoObjDir)" />

<Message Condition="'$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true'" Text="--- Building Mono AOT cross-compiler ---" Importance="High" />
Expand Down Expand Up @@ -664,6 +694,7 @@
<_MonoRuntimeFilePath Condition="'$(TargetsOSX)' == 'true'">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsiOS)' == '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 '$(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>
Expand Down Expand Up @@ -691,7 +722,7 @@
<Copy SourceFiles="@(_MonoIncludeArtifacts)"
DestinationFiles="@(_MonoIncludeArtifacts->'$(BinDir)include\%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="true"
Condition="'$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true'"/>
Condition="'$(TargetsiOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsWASM)' == 'true'"/>

<Exec Condition="'$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true'" Command="install_name_tool -id @rpath/$(MonoFileName) $(BinDir)$(MonoFileName)" />
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down