diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets
index 66da71ac53f75..11ea3bf8f3aea 100644
--- a/eng/liveBuilds.targets
+++ b/eng/liveBuilds.targets
@@ -175,8 +175,8 @@
Include="
$(LibrariesNativeArtifactsPath)src\*.c;
$(LibrariesNativeArtifactsPath)src\*.js;
- $(LibrariesNativeArtifactsPath)src\emcc-flags.txt;
- $(LibrariesNativeArtifactsPath)src\emcc-version.txt;"
+ $(LibrariesNativeArtifactsPath)src\emcc-default.rsp;
+ $(LibrariesNativeArtifactsPath)src\Emcc.props;"
NativeSubDirectory="src"
IsNative="true" />
-
-
+
+
diff --git a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj
index 522d70fa1e4b3..874775fe7e47f 100644
--- a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj
+++ b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj
@@ -13,6 +13,8 @@
+
+
diff --git a/src/mono/sample/wasm/wasm.mk b/src/mono/sample/wasm/wasm.mk
index 1858ca3791182..2eb4adcfb4585 100644
--- a/src/mono/sample/wasm/wasm.mk
+++ b/src/mono/sample/wasm/wasm.mk
@@ -23,7 +23,7 @@ run-browser:
echo "The tool dotnet-serve could not be found. Install with: $(DOTNET) tool install --global dotnet-serve"; \
exit 1; \
else \
- $(DOTNET) serve -d bin/$(CONFIG)/AppBundle -p 8000; \
+ $(DOTNET) serve -d:bin/$(CONFIG)/AppBundle -p:8000; \
fi
run-console:
diff --git a/src/mono/wasm/Makefile b/src/mono/wasm/Makefile
index abb93b97f4068..8a69822976bfe 100644
--- a/src/mono/wasm/Makefile
+++ b/src/mono/wasm/Makefile
@@ -20,10 +20,9 @@ MONO_BIN_DIR?=$(BINDIR)/mono/Browser.wasm.$(CONFIG)
NATIVE_BIN_DIR?=$(BINDIR)/native/net6.0-Browser-$(CONFIG)-wasm
ICU_LIBDIR?=
SYSTEM_NATIVE_LIBDIR?=$(TOP)/src/libraries/Native/Unix/System.Native
-ENABLE_ES6?=false
_MSBUILD_WASM_BUILD_ARGS=/p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=$(CONFIG)
-ENABLE_METADATA_UPDATE?=false
XHARNESS_BROWSER?=chrome
+EMCC_DEFAULT_RSP=$(NATIVE_BIN_DIR)/src/emcc-default.rsp
all: build-native icu-files source-files header-files
@@ -63,14 +62,6 @@ MONO_LIBS = \
$(ICU_LIBDIR)/libicuuc.a \
$(ICU_LIBDIR)/libicui18n.a
-EMCC_FLAGS=--profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s FORCE_FILESYSTEM=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
-ifneq ($(ENABLE_ES6),false)
- EMCC_FLAGS+=-s MODULARIZE=1 -s EXPORT_ES6=1
-endif
-ifeq ($(ENABLE_METADATA_UPDATE),true)
- EMCC_FLAGS+=-DENABLE_METADATA_UPDATE=1
-endif
-
EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DDEBUG=1
EMCC_RELEASE_FLAGS=-Oz --llvm-opts 2
@@ -101,28 +92,28 @@ $(NATIVE_BIN_DIR)/include/wasm:
$(BUILDS_OBJ_DIR):
mkdir -p $$@
-$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/library_mono.js runtime/binding_support.js runtime/dotnet_support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) | $(NATIVE_BIN_DIR)
- $(EMCC) $(EMCC_FLAGS) $(1) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)
+$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/library_mono.js runtime/binding_support.js runtime/dotnet_support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) $(EMCC_DEFAULT_RSP) | $(NATIVE_BIN_DIR)
+ $(EMCC) @$(EMCC_DEFAULT_RSP) $(1) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)
$(BUILDS_OBJ_DIR)/pinvoke-table.h: $(PINVOKE_TABLE) | $(BUILDS_OBJ_DIR)
if cmp -s $(PINVOKE_TABLE) $$@ ; then : ; else cp $(PINVOKE_TABLE) $$@ ; fi
-$(BUILDS_OBJ_DIR)/driver.o: runtime/driver.c | $(BUILDS_OBJ_DIR)
- $(EMCC) $(EMCC_FLAGS) $(1) -Oz -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@
+$(BUILDS_OBJ_DIR)/driver.o: runtime/driver.c $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
+ $(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@
-$(BUILDS_OBJ_DIR)/pinvoke.o: runtime/pinvoke.c runtime/pinvoke.h $(BUILDS_OBJ_DIR)/pinvoke-table.h | $(BUILDS_OBJ_DIR)
- $(EMCC) $(EMCC_FLAGS) $(1) -Oz -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@
+$(BUILDS_OBJ_DIR)/pinvoke.o: runtime/pinvoke.c runtime/pinvoke.h $(BUILDS_OBJ_DIR)/pinvoke-table.h $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
+ $(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@
-$(BUILDS_OBJ_DIR)/corebindings.o: runtime/corebindings.c | $(BUILDS_OBJ_DIR)
- $(EMCC) $(EMCC_FLAGS) $(1) -Oz -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@
+$(BUILDS_OBJ_DIR)/corebindings.o: runtime/corebindings.c $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
+ $(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@
-$(NATIVE_BIN_DIR)/src/emcc-flags.txt: | $(NATIVE_BIN_DIR)/src Makefile
- echo "$(call escape_quote,$(EMCC_FLAGS)) $(1)" > $$@
+$(EMCC_DEFAULT_RSP): $(CURDIR)/wasm.proj | $(NATIVE_BIN_DIR)/src Makefile
+ $(DOTNET) build $(CURDIR)/wasm.proj /p:Configuration=$(CONFIG) /t:GenerateEmccPropsAndRspFiles
-$(NATIVE_BIN_DIR)/src/emcc-version.txt: $(EMSDK_PATH)/upstream/.emsdk_version | $(NATIVE_BIN_DIR)/src
- $(EMCC) --version | head -1 > $$@
+$(NATIVE_BIN_DIR)/src/Emcc.props: $(EMSDK_PATH)/upstream/.emsdk_version | $(NATIVE_BIN_DIR)/src
+ $(DOTNET) build $(CURDIR)/wasm.proj /p:Configuration=$(CONFIG) /t:GenerateEmccPropsAndRspFiles
-build-native: $(NATIVE_BIN_DIR)/dotnet.js $(NATIVE_BIN_DIR)/src/emcc-flags.txt $(NATIVE_BIN_DIR)/src/emcc-version.txt
+build-native: $(NATIVE_BIN_DIR)/dotnet.js $(NATIVE_BIN_DIR)/src/emcc-default.rsp $(NATIVE_BIN_DIR)/src/Emcc.props
endef
diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets
new file mode 100644
index 0000000000000..9288eb7f01986
--- /dev/null
+++ b/src/mono/wasm/build/WasmApp.Native.targets
@@ -0,0 +1,445 @@
+
+
+
+
+
+
+
+ <_WasmBuildNativeCoreDependsOn>
+ _CheckEmccIsExpectedVersion;
+ _PrepareForWasmBuildNative;
+ _GenerateDriverGenC;
+ _GeneratePInvokeTable;
+ _GenerateICallTable;
+ _WasmCompileNativeFiles;
+ _WasmLinkDotNet;
+ _CompleteWasmBuildNative
+
+
+
+ _PrepareForWasmBuildNativeOnly;
+ _WasmBuildNativeCore;
+
+
+ <_BeforeWasmBuildAppDependsOn>
+ $(_BeforeWasmBuildAppDependsOn);
+ _SetupEmscripten;
+ _SetWasmBuildNativeDefaults
+
+
+ <_ExeExt Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">.exe
+ true
+
+ $([MSBuild]::NormalizeDirectory($(NuGetPackageRoot), 'microsoft.netcore.app.runtime.mono.browser-wasm', '$(BundledNETCoreAppPackageVersion)'))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackDir), 'runtimes', 'browser-wasm'))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir)))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir), 'native'))
+
+ <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include'))
+ <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src'))
+ <_EmccPropsPath>$(_WasmRuntimePackSrcDir)Emcc.props
+
+
+
+
+
+
+
+
+
+
+
+
+ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
+ <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" />
+
+
+
+
+
+
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenSdkToolsPath)' == '' or !Exists('$(EmscriptenSdkToolsPath)'))">%24(EmscriptenSdkToolsPath)=$(EmscriptenSdkToolsPath)
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenNodeToolsPath)' == '' or !Exists('$(EmscriptenNodeToolsPath)'))">%24(EmscriptenNodeToolsPath)=$(EmscriptenNodeToolsPath)
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenUpstreamBinPath)' == '' or !Exists('$(EmscriptenUpstreamBinPath)'))">%24(EmscriptenUpstreamBinPath)=$(EmscriptenUpstreamBinPath)
+
+
+
+ <_EMSDKMissingErrorMessage Condition="'$(EMSDK_PATH)' == '' and '$(EmscriptenSdkToolsPath)' == ''">Could not find emscripten sdk. Either set %24(EMSDK_PATH), or use workloads to get the sdk.
+
+ <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' != 'true' and '$(_EMSDKMissingPaths)' != ''">Emscripten from the workload is missing some paths: $(_EMSDKMissingPaths).
+ <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and !Exists($(EMSDK_PATH))">Could not find Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH) .
+ <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and '$(_EMSDKMissingPaths)' != ''">Specified Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH) is missing some paths: $(_EMSDKMissingPaths).
+
+ <_IsEMSDKMissing Condition="'$(_EMSDKMissingErrorMessage)' != ''">true
+
+
+
+ $([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath)))
+ $([MSBuild]::NormalizeDirectory($(EmscriptenNodeToolsPath)))
+ $([MSBuild]::NormalizeDirectory($(EmscriptenUpstreamBinPath)))
+
+
+
+
+
+
+
+
+
+
+ <_EmscriptenPrependPATHTrimmed Include="$([MSBuild]::ValueOrDefault('%(EmscriptenPrependPATH.Identity)\', '').TrimEnd('\/'))" />
+
+
+
+
+
+
+ <_PathSeparator Condition="'$(OS)' == 'Windows_NT'">%3B
+ <_PathSeparator Condition="'$(OS)' != 'Windows_NT'">:
+
+ <_EmscriptenPrependPATHProperty>@(EmscriptenPrependPATH -> '%(Identity)', '$(_PathSeparator)')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ false
+ true
+ false
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+ <_EmccDefaultFlagsRsp>$([MSBuild]::NormalizePath($(_WasmRuntimePackSrcDir), 'emcc-default.rsp'))
+ true
+ true
+ $(WasmBuildNative)
+ <_WasmICallTablePath>$(_WasmIntermediateOutputPath)icall-table.h
+ <_WasmRuntimeICallTablePath>$(_WasmIntermediateOutputPath)runtime-icall-table.h
+ <_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)pinvoke-table.h
+
+ <_EmccOptimizationFlagDefault Condition="'$(_WasmDevel)' == 'true'">-O0
+ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == '' and '$(OS)' != 'Windows_NT' and '$(Configuration)' == 'Debug'">-Os
+ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == '' and '$(Configuration)' != 'Debug'">-Oz
+ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == ''">-Oz
+
+ $(_EmccOptimizationFlagDefault)
+ $(_EmccOptimizationFlagDefault)
+
+
+
+ <_EmccCommonFlags Include="$(_DefaultEmccFlags)" />
+ <_EmccCommonFlags Include="$(EmccFlags)" />
+ <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" />
+ <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" />
+ <_EmccCommonFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" />
+ <_EmccCommonFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" />
+ <_EmccCommonFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" />
+ <_EmccCommonFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" />
+ <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" />
+
+
+
+ <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include'))
+ <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src'))
+
+
+
+ <_WasmObjectsToBuild Include="$(_WasmRuntimePackSrcDir)\*.c" />
+ <_WasmObjectsToBuild OutputPath="$(_WasmIntermediateOutputPath)%(FileName).o" />
+
+ <_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)\*.js" />
+ <_WasmPInvokeModules Include="%(_WasmNativeFileForLinking.FileName)" />
+
+
+
+
+
+ <_WasmPInvokeModules Include="libSystem.Native" />
+ <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" />
+ <_WasmPInvokeModules Include="libSystem.Globalization.Native" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" />
+ <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" />
+ <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" />
+
+
+ <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" />
+ <_EmccCFlags Include="@(_EmccCommonFlags)" />
+ <_EmccCFlags Include="-DCORE_BINDINGS" />
+ <_EmccCFlags Include="-DGEN_PINVOKE=1" />
+ <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" />
+ <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" />
+ <_EmccCFlags Include="-s EXPORTED_FUNCTIONS='[@(_ExportedFunctions->'"%(Identity)"', ',')]'" Condition="@(_ExportedFunctions->Count()) > 0" />
+
+ <_EmccCFlags Include="$(EmccExtraCFlags)" />
+
+
+
+ <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp
+
+
+
+
+
+
+
+
+
+
+ <_WasmRuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" />
+ <_WasmObjects Include="@(_WasmRuntimePackNativeLibs)" />
+ <_WasmObjects Include="@(_WasmObjectsToBuild->'%(OutputPath)')" />
+
+
+ <_EmccLDFlags Include="$(EmccLinkOptimizationFlag)" />
+ <_EmccLDFlags Include="@(_EmccCommonFlags)" />
+ <_EmccLDFlags Include="-s TOTAL_MEMORY=536870912" />
+ <_EmccLDFlags Include="$(EmccExtraLDFlags)" />
+
+ <_EmccLDFlags Include="--js-library "%(_DotnetJSSrcFile.Identity)"" />
+ <_EmccLDFlags Include="--js-library "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' == 'js-library'" />
+
+ <_EmccLDFlags Include="--pre-js "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' == 'pre-js'" />
+ <_EmccLDFlags Include="--post-js "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' == 'post-js'" />
+
+ <_EmccLDFlags Include=""%(_WasmNativeFileForLinking.Identity)"" />
+ <_EmccLDFlags Include=""%(_WasmObjects.Identity)"" />
+ <_EmccLDFlags Include="-o "$(_WasmIntermediateOutputPath)dotnet.js"" />
+
+
+
+ <_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(EmccFlags) -DDRIVER_GEN=1
+
+void mono_profiler_init_aot (const char *desc)%3B
+EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_profiler_init_aot (desc)%3B }
+
+
+ <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ReversedVersionLines Include="@(_VersionLines->Reverse())" />
+
+
+ %(_ReversedVersionLines.Identity)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_AotInputAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'">
+ @(MonoAOTCompilerDefaultAotArguments, ';')
+ @(MonoAOTCompilerDefaultProcessArguments, ';')
+
+ <_AOT_InternalForceInterpretAssemblies Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" />
+
+ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
+
+ <_WasmAOTSearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)" />
+ <_WasmAOTSearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)\lib\net6.0" />
+
+
+
+
+ LLVMOnlyInterp
+
+
+
+
+
+
+
+
+ <_WasmDedupAssembly>$(_WasmIntermediateOutputPath)\aot-instances.dll
+
+
+
+
+ <_AotInputAssemblies Include="$(_WasmDedupAssembly)">
+ @(MonoAOTCompilerDefaultAotArguments, ';')
+ @(MonoAOTCompilerDefaultProcessArguments, ';')
+
+
+
+
+
+
+
+
+
+
+
+ <_WasmAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" />
+
+ <_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" />
+ <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" />
+
+ <_WasmNativeFileForLinking Include="@(_BitcodeFile)" />
+
+
+
+
+
+
+
+
+ <_WasmStrippedAssembliesPath>$([MSBuild]::NormalizeDirectory($(_WasmIntermediateOutputPath), 'stripped-assemblies'))
+
+
+
+ <_WasmStrippedAssemblies
+ Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'"
+ Include="@(_WasmAssembliesInternal->'$(_WasmStrippedAssembliesPath)%(FileName)%(Extension)')"
+ OriginalPath="%(_WasmAssembliesInternal.Identity)" />
+ <_WasmInterpOnlyAssembly Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" />
+
+
+
+
+
+
+
+
+ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
+ <_WasmAssembliesInternal Include="@(_WasmStrippedAssemblies);@(_WasmInterpOnlyAssembly)" />
+
+
+
+
diff --git a/src/mono/wasm/build/WasmApp.props b/src/mono/wasm/build/WasmApp.props
index 6f496caa81e08..3942eba7f9129 100644
--- a/src/mono/wasm/build/WasmApp.props
+++ b/src/mono/wasm/build/WasmApp.props
@@ -10,7 +10,7 @@
_WasmResolveReferences;
_WasmAotCompileApp;
_WasmStripAOTAssemblies;
- _WasmBuildNative;
+ _WasmBuildNativeCore;
_WasmGenerateAppBundle;
_AfterWasmBuildApp
diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets
index 0467636bd6c72..2141cce41b69b 100644
--- a/src/mono/wasm/build/WasmApp.targets
+++ b/src/mono/wasm/build/WasmApp.targets
@@ -1,8 +1,6 @@
-
-
- false
false
- <_ExeExt Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">.exe
- true
-
- <_WasmNativeBuildDependsOn>
- _CheckEmccIsExpectedVersion;
- _PrepareForWasmBuildNative;
- _GenerateDriverGenC;
- _GeneratePInvokeTable;
- _GenerateICallTable;
- _WasmCompileNativeFiles;
- _WasmLinkDotNet;
- _CompleteWasmBuildNative
-
+ false
+
+ $([MSBuild]::NormalizeDirectory($(NuGetPackageRoot), 'microsoft.netcore.app.runtime.mono.browser-wasm', '$(BundledNETCoreAppPackageVersion)'))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackDir), 'runtimes', 'browser-wasm'))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir)))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir), 'native'))
+
+ <_BeforeWasmBuildAppDependsOn />
-
+
-
-
-
-
-
-
-
-
-
-
-
-
- <_AotInputAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'">
- @(MonoAOTCompilerDefaultAotArguments, ';')
- @(MonoAOTCompilerDefaultProcessArguments, ';')
-
- <_AOT_InternalForceInterpretAssemblies Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" />
-
- <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
-
- <_WasmAOTSearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)" />
- <_WasmAOTSearchPaths Include="$(MicrosoftNetCoreAppRuntimePackRidDir)\lib\net6.0" />
-
-
-
-
- LLVMOnlyInterp
-
-
-
-
-
-
-
-
- <_WasmDedupAssembly>$(_WasmIntermediateOutputPath)\aot-instances.dll
-
-
-
-
- <_AotInputAssemblies Include="$(_WasmDedupAssembly)">
- @(MonoAOTCompilerDefaultAotArguments, ';')
- @(MonoAOTCompilerDefaultProcessArguments, ';')
-
-
-
-
-
-
-
-
-
-
-
- <_WasmAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" />
-
- <_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" />
- <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" />
-
- <_WasmNativeFileForLinking Include="@(_BitcodeFile)" />
-
-
-
-
-
-
-
-
- <_WasmStrippedAssembliesPath>$([MSBuild]::NormalizeDirectory($(_WasmIntermediateOutputPath), 'stripped-assemblies'))
-
-
-
- <_WasmStrippedAssemblies
- Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'"
- Include="@(_WasmAssembliesInternal->'$(_WasmStrippedAssembliesPath)%(FileName)%(Extension)')"
- OriginalPath="%(_WasmAssembliesInternal.Identity)" />
- <_WasmInterpOnlyAssembly Include="@(_WasmAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" />
-
-
-
-
-
-
-
-
- <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
- <_WasmAssembliesInternal Include="@(_WasmStrippedAssemblies);@(_WasmInterpOnlyAssembly)" />
-
-
-
-
-
-
-
-
-
- <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
- <_WasmAssembliesInternal Include="@(_TmpWasmAssemblies)" />
-
-
-
-
-
- $([MSBuild]::NormalizeDirectory($(NuGetPackageRoot), 'microsoft.netcore.app.runtime.mono.browser-wasm', '$(BundledNETCoreAppPackageVersion)'))
- $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackDir), 'runtimes', 'browser-wasm'))
-
+
+
true
- true
$([MSBuild]::NormalizeDirectory($(OutputPath), 'AppBundle'))
$(TargetFileName)
$([MSBuild]::NormalizeDirectory($(WasmAppDir)))
- $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir)))
- $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir), 'native'))
<_WasmIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm'))
@@ -263,85 +118,6 @@
-
-
- <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenSdkToolsPath)' == '' or !Exists('$(EmscriptenSdkToolsPath)'))">%24(EmscriptenSdkToolsPath)=$(EmscriptenSdkToolsPath)
- <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenNodeToolsPath)' == '' or !Exists('$(EmscriptenNodeToolsPath)'))">%24(EmscriptenNodeToolsPath)=$(EmscriptenNodeToolsPath)
- <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenUpstreamBinPath)' == '' or !Exists('$(EmscriptenUpstreamBinPath)'))">%24(EmscriptenUpstreamBinPath)=$(EmscriptenUpstreamBinPath)
-
-
-
- <_EMSDKMissingErrorMessage Condition="'$(EMSDK_PATH)' == '' and '$(EmscriptenSdkToolsPath)' == ''">Could not find emscripten sdk. Either set %24(EMSDK_PATH), or use workloads to get the sdk.
-
- <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' != 'true' and '$(_EMSDKMissingPaths)' != ''">Emscripten from the workload is missing some paths: $(_EMSDKMissingPaths).
- <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and !Exists($(EMSDK_PATH))">Could not find Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH) .
- <_EMSDKMissingErrorMessage Condition="'$(_EMSDKMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and '$(_EMSDKMissingPaths)' != ''">Specified Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH) is missing some paths: $(_EMSDKMissingPaths).
-
- <_IsEMSDKMissing Condition="'$(_EMSDKMissingErrorMessage)' != ''">true
-
-
-
- $([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath)))
- $([MSBuild]::NormalizeDirectory($(EmscriptenNodeToolsPath)))
- $([MSBuild]::NormalizeDirectory($(EmscriptenUpstreamBinPath)))
-
-
-
-
-
-
-
-
-
-
- <_EmscriptenPrependPATHTrimmed Include="$([MSBuild]::ValueOrDefault('%(EmscriptenPrependPATH.Identity)\', '').TrimEnd('\/'))" />
-
-
-
-
-
-
- <_PathSeparator Condition="'$(OS)' == 'Windows_NT'">%3B
- <_PathSeparator Condition="'$(OS)' != 'Windows_NT'">:
-
- <_EmscriptenPrependPATHProperty>@(EmscriptenPrependPATH -> '%(Identity)', '$(_PathSeparator)')
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- false
- true
- false
-
-
-
-
-
-
- false
-
-
-
-
-
@@ -380,163 +156,6 @@
-
-
-
-
- $([MSBuild]::NormalizePath($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src', 'emcc-flags.txt'))
- true
- $(WasmBuildNative)
- <_WasmICallTablePath>$(_WasmIntermediateOutputPath)icall-table.h
- <_WasmRuntimeICallTablePath>$(_WasmIntermediateOutputPath)runtime-icall-table.h
- <_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)pinvoke-table.h
-
- <_EmccOptimizationFlagDefault Condition="'$(_WasmDevel)' == 'true'">-O0
-
- $(_EmccOptimizationFlagDefault)
- $(_EmccOptimizationFlagDefault)
-
-
-
-
-
-
-
- <_EmccCommonFlags Include="$(_DefaultEmccFlags)" />
- <_EmccCommonFlags Include="$(EmccFlags)" />
- <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" />
- <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" />
- <_EmccCommonFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" />
- <_EmccCommonFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" />
- <_EmccCommonFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" />
- <_EmccCommonFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" />
- <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" />
-
-
-
- <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include'))
- <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src'))
-
-
-
- <_WasmRuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" />
- <_WasmObjectsToBuild Include="$(_WasmRuntimePackSrcDir)\*.c" />
- <_WasmObjectsToBuild OutputPath="$(_WasmIntermediateOutputPath)%(FileName).o" />
-
- <_WasmObjects Include="@(_WasmRuntimePackNativeLibs)" />
- <_WasmObjects Include="@(_WasmObjectsToBuild->'%(OutputPath)')" />
-
- <_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)\*.js" />
-
-
-
-
-
- <_WasmPInvokeModules Include="libSystem.Native" />
- <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" />
- <_WasmPInvokeModules Include="libSystem.Globalization.Native" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" />
- <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" />
- <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" />
-
-
- <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" />
- <_EmccCFlags Include="@(_EmccCommonFlags)" />
- <_EmccCFlags Include="-DCORE_BINDINGS" />
- <_EmccCFlags Include="-DGEN_PINVOKE=1" />
- <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" />
- <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" />
- <_EmccCFlags Include="$(EmccExtraCFlags)" />
-
-
-
- <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp
-
-
-
-
-
-
-
-
-
-
- <_WasmRuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" />
- <_WasmObjects Include="@(_WasmRuntimePackNativeLibs)" />
- <_WasmObjects Include="@(_WasmObjectsToBuild->'%(OutputPath)')" />
-
-
- <_EmccLDFlags Include="$(EmccLinkOptimizationFlag)" />
- <_EmccLDFlags Include="@(_EmccCommonFlags)" />
- <_EmccLDFlags Include="-s TOTAL_MEMORY=536870912" />
- <_EmccLDFlags Include="$(EmccExtraLDFlags)" />
-
- <_EmccLDFlags Include="--js-library "%(_DotnetJSSrcFile.Identity)"" />
- <_EmccLDFlags Include=""%(_WasmNativeFileForLinking.Identity)"" />
- <_EmccLDFlags Include=""%(_WasmObjects.Identity)"" />
-
- <_EmccLDFlags Include="-o "$(_WasmIntermediateOutputPath)dotnet.js"" />
-
-
-
- <_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(EmccFlags) -DDRIVER_GEN=1
-
-void mono_profiler_init_aot (const char *desc)%3B
-EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_profiler_init_aot (desc)%3B }
-
-
- <_DriverGenCPath>$(_WasmIntermediateOutputPath)driver-gen.c
-
-
-
-
-
-
-
-
-
-
$(WasmAppDir)run-v8.sh
@@ -556,28 +175,18 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
- <_ReversedVersionLines Include="@(_VersionLines->Reverse())" />
+ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
+ <_WasmAssembliesInternal Include="@(_TmpWasmAssemblies)" />
-
- %(_ReversedVersionLines.Identity)
-
-
-
diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj
index 8f958e8e2f0a1..064cb445bfac8 100644
--- a/src/mono/wasm/wasm.proj
+++ b/src/mono/wasm/wasm.proj
@@ -13,6 +13,9 @@
false
false
true
+ emcc
+ $(ArtifactsObjDir)wasm
+ <_EmccDefaultsRspPath>$(NativeBinDir)src\emcc-default.rsp
@@ -67,21 +70,99 @@
OutputFileName="$(TimeZonesDataPath)" />
+
+
+ <_EmccCommonFlags Include="-s ALLOW_MEMORY_GROWTH=1" />
+ <_EmccCommonFlags Include="-s NO_EXIT_RUNTIME=1" />
+ <_EmccCommonFlags Include="-s FORCE_FILESYSTEM=1" />
+ <_EmccCommonFlags Include="-s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']"" />
+ <_EmccCommonFlags Include="-s "EXPORTED_FUNCTIONS=['_putchar']"" />
+ <_EmccCommonFlags Include="--source-map-base http://example.com" />
+ <_EmccCommonFlags Include="-emit-llvm" />
+
+ <_EmccCommonFlags Include="-s MODULARIZE=1" Condition="'$(WasmEnableES6)' != 'false'" />
+ <_EmccCommonFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' != 'false'" />
+
+
+
+ <_EmccFlags Include="--profiling-funcs" />
+ <_EmccFlags Include="@(_EmccCommonFlags)" />
+
+ <_EmccFlags Include="-DENABLE_METADATA_UPDATE=1" Condition="'$(WasmEnableMetadataUpdate)' == 'true'" />
+
+
+
+ <_EmccFlags Include="@(_EmccCommonFlags)" />
+
+ <_EmccFlags Include="-s WASM=1" />
+ <_EmccFlags Include="-s BINARYEN=1" />
+ <_EmccFlags Include="-s ALIASING_FUNCTION_POINTERS=0" />
+ <_EmccFlags Include="-s USE_ZLIB=1" />
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ReversedVersionLines Include="@(_VersionLines->Reverse())" />
+
+
+ <_EmccVersionRaw>%(_ReversedVersionLines.Identity)
+
+ <_EmccVersionRegexPattern>^ *emcc \([^\)]+\) *([^ \(]+) *\(([^\)]+)\)$
+ <_EmccVersion>$([System.Text.RegularExpressions.Regex]::Match($(_EmccVersionRaw), $(_EmccVersionRegexPattern)).Groups[1].Value)
+ <_EmccVersionHash>$([System.Text.RegularExpressions.Regex]::Match($(_EmccVersionRaw), $(_EmccVersionRegexPattern)).Groups[2].Value)
+
+ <_EmccPropsContent>
+
+
+ $(_EmccVersionRaw)
+ $(_EmccVersion)
+ $(_EmccVersionHash)
+
+
+]]>
+
+
+
+
+
+
+
+
+ DependsOnTargets="GenerateEmccPropsAndRspFiles;BuildPInvokeTable;BundleTimeZones">
-
+ $(_EmccDefaultsRspPath);
+ $(NativeBinDir)src\Emcc.props" />
@@ -109,12 +190,9 @@
+ DependsOnTargets="GenerateEmccPropsAndRspFiles;BuildPInvokeTable;BundleTimezones">
- emcc
- --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
- $(EmccFlags) -s MODULARIZE=1 -s EXPORT_ES6=1
-g -Os -s ASSERTIONS=1 -DENABLE_NETCORE=1 -DDEBUG=1
-Oz --llvm-opts 2 -DENABLE_NETCORE=1
"$(EMSDK_PATH)/upstream/bin/wasm-opt" --strip-dwarf "$(NativeBinDir)dotnet.wasm" -o "$(NativeBinDir)dotnet.wasm"
@@ -137,11 +215,11 @@
-
-
@@ -149,11 +227,11 @@
DestinationFolder="$(MonoObjDir)"
SkipUnchangedFiles="true" />
-
-
@@ -164,31 +242,17 @@
-
-
- <_ReversedVersionLines Include="@(_VersionLines->Reverse())" />
-
-
- %(_ReversedVersionLines.Identity)
-
-
-
-
-
+
@@ -196,10 +260,6 @@
DestinationFolder="$(NativeBinDir)"
SkipUnchangedFiles="true" />
-
-
+ $(_EmccDefaultsRspPath);
+ $(NativeBinDir)src\Emcc.props" />
-
+
diff --git a/src/tests/Common/Directory.Build.targets b/src/tests/Common/Directory.Build.targets
index bf9be0cc4d712..31e55c12ccfc0 100644
--- a/src/tests/Common/Directory.Build.targets
+++ b/src/tests/Common/Directory.Build.targets
@@ -129,7 +129,13 @@
WasmAppBuilder expects in native/-->
+ TargetDir="runtimepack/native/%(LibrariesRuntimeFiles.NativeSubDirectory)/"
+ Condition="'%(LibrariesRuntimeFiles.NativeSubDirectory)' != ''" />
+
+