Skip to content

Commit

Permalink
Enable WASM AOT option in build and update MonoAOTCompiler (#44468)
Browse files Browse the repository at this point in the history
Allows creating AOT images for WASM with the AOT compiler and consuming them in the runtime.

Use `make build AOT=1` in `src/mono/netcore/sample/wasm/console` to try it out.

--

Also fix a regression in aot-compiler.c regarding SPC->corlib assembly name:

In 035ebea we added a simplified prefix for symbol names in System.Private.CoreLib.
However this shouldn't happen for the actual assembly name otherwise we aren't able to find the AOT module linked statically into the binary.
  • Loading branch information
akoeplinger authored Nov 13, 2020
1 parent 40cd998 commit 85d2df8
Show file tree
Hide file tree
Showing 22 changed files with 240 additions and 102 deletions.
3 changes: 2 additions & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
Include="
$(LibrariesNativeArtifactsPath)src\*.c;
$(LibrariesNativeArtifactsPath)src\*.js;"
$(LibrariesNativeArtifactsPath)src\*.js;
$(LibrariesNativeArtifactsPath)src\emcc-flags.txt;"
NativeSubDirectory="src"
IsNative="true" />
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
Expand Down
2 changes: 2 additions & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
Mode="Full"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
AotModulesTablePath="$(BundleDir)\modules.m"
AotModulesTableLanguage="ObjC"
UseLLVM="$(MonoEnableLLVM)"
LLVMPath="$(MicrosoftNetCoreAppRuntimePackNativeDir)cross">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
<PlatformManifestFileEntry Include="pinvoke.c" IsNative="true" />
<PlatformManifestFileEntry Include="pinvoke-table.h" IsNative="true" />
<PlatformManifestFileEntry Include="pinvoke.h" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-flags.txt" IsNative="true" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
<Target Name="AddFrameworkFilesToPackage" DependsOnTargets="ResolveLibrariesFromLocalBuild">
<ItemGroup>
<ReferenceCopyLocalPaths Include="@(LibrariesRuntimeFiles)"
Condition="'%(LibrariesRuntimeFiles.Extension)' != '.a' or '$(TargetsMobile)' == 'true'" />
Condition="'%(LibrariesRuntimeFiles.Extension)' != '.a' or '$(TargetsMobile)' == 'true'">
<TargetPath Condition="'%(LibrariesRuntimeFiles.NativeSubDirectory)' != ''">runtimes/$(RuntimeIdentifier)/native/%(LibrariesRuntimeFiles.NativeSubDirectory)%(RecursiveDir)</TargetPath>
</ReferenceCopyLocalPaths>
</ItemGroup>
</Target>

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<_MonoMinimal Condition="'$(Configuration)' == 'Release'">,assert_messages</_MonoMinimal>
</PropertyGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,logging,remoting,shared_perfcounters,sgen_debug_helpers,sgen_binary_protocol,soft_debug,interpreter,cleanup,mdb,gac,threads,eventpipe,aot,interpreter,qcalls$(_MonoMinimal)"/>
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,logging,remoting,shared_perfcounters,sgen_debug_helpers,sgen_binary_protocol,soft_debug,interpreter,cleanup,mdb,gac,threads,eventpipe,qcalls$(_MonoMinimal)"/>
<_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/>
<_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/>
<_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/>
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -11619,7 +11619,7 @@ emit_file_info (MonoAotCompile *acfg)
emit_string_symbol (acfg, "assembly_guid" , acfg->image->guid);

/* Emit a string holding the assembly name */
emit_string_symbol (acfg, "assembly_name", get_assembly_prefix (acfg->image));
emit_string_symbol (acfg, "assembly_name", acfg->image->assembly->aname.name);

info = g_new0 (MonoAotFileInfo, 1);
init_aot_file_info (acfg, info);
Expand All @@ -11633,7 +11633,7 @@ emit_file_info (MonoAotCompile *acfg)
* mono_aot_register_module (). The symbol points to a pointer to the the file info
* structure.
*/
sprintf (symbol, "%smono_aot_module_%s_info", acfg->user_symbol_prefix, get_assembly_prefix (acfg->image));
sprintf (symbol, "%smono_aot_module_%s_info", acfg->user_symbol_prefix, acfg->image->assembly->aname.name);

/* Get rid of characters which cannot occur in symbols */
p = symbol;
Expand Down
6 changes: 4 additions & 2 deletions src/mono/mono/mini/mini-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,23 +613,25 @@ tp_cb (void)
}
}

#ifdef HOST_WASM
void
mono_wasm_queue_tp_cb (void)
{
#ifdef HOST_WASM
mono_threads_schedule_background_job (tp_cb);
#endif
}
#endif

void
mono_arch_register_icall (void)
{
#ifdef HOST_WASM
#ifdef ENABLE_NETCORE
mono_add_internal_call_internal ("System.Threading.TimerQueue::SetTimeout", mono_wasm_set_timeout);
mono_add_internal_call_internal ("System.Threading.ThreadPool::QueueCallback", mono_wasm_queue_tp_cb);
#else
mono_add_internal_call_internal ("System.Threading.WasmRuntime::SetTimeout", mono_wasm_set_timeout);
#endif
#endif
}

void
Expand Down
9 changes: 6 additions & 3 deletions src/mono/netcore/sample/iOS/Program.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,27 @@
<AppDir>$(MSBuildThisFileDirectory)$(PublishDir)\app</AppDir>
<IosSimulator Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'x86'">iPhone 11</IosSimulator>
<Optimized Condition="'$(Configuration)' == 'Release'">True</Optimized>
<RunAOTCompilation Condition="'$(IosSimulator)' == '' or '$(UseAotForSimulator)' == 'true'">true</RunAOTCompilation>
</PropertyGroup>

<RemoveDir Directories="$(AppDir)" />

<ItemGroup>
<BundleAssemblies Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll" />
<AotInputAssemblies Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll">
<BundleAssemblies Condition="'$(RunAOTCompilation)' != 'true'" Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll" />
<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll">
<AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
<ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
</AotInputAssemblies>
</ItemGroup>

<MonoAOTCompiler
Condition="'$(IosSimulator)' == '' or '$(UseAotForSimulator)' == 'true'"
Condition="'$(RunAOTCompilation)' == 'true'"
CompilerBinaryPath="$(MicrosoftNetCoreAppRuntimePackDir)native\cross\mono-aot-cross"
Mode="Full"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
AotModulesTablePath="$(AppDir)\modules.m"
AotModulesTableLanguage="ObjC"
UseLLVM="$(UseLLVM)"
LLVMPath="$(MicrosoftNetCoreAppRuntimePackDir)native\cross">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/netcore/sample/wasm/browser/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
TOP=../../../../../..
DOTNET=$(TOP)/dotnet.sh

ifeq ($(V),)
DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary
else
DOTNET_Q_ARGS=--nologo
endif

CONFIG?=Release

all: build

build:
$(TOP)/.dotnet/dotnet build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj
$(DOTNET) build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj

clean:
rm -rf bin
Expand Down
6 changes: 3 additions & 3 deletions src/mono/netcore/sample/wasm/browser/WasmSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
</ItemGroup>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration);MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Properties="Configuration=Debug;MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Targets="Restore"/>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration)"
Properties="Configuration=Debug"
Targets="Build;Publish"/>
</Target>

<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\$(Configuration)\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\Debug\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>

<Target Name="BuildApp" DependsOnTargets="RebuildWasmAppBuilder;Build">
<ItemGroup>
Expand Down
13 changes: 8 additions & 5 deletions src/mono/netcore/sample/wasm/console/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
TOP=../../../../../..
DOTNET=$(TOP)/dotnet.sh

ifeq ($(V),)
DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary
else
DOTNET_Q_ARGS=--nologo
DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug
endif

ifneq ($(AOT),)
DOTNET_RUN_AOT_COMPILATION_ARGS=/p:RunAOTCompilation=true
endif

CONFIG?=Release

all: build

build:
$(TOP)/.dotnet/dotnet publish $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj
$(DOTNET) publish $(DOTNET_Q_ARGS) $(DOTNET_RUN_AOT_COMPILATION_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj

clean:
rm -rf bin

run:
cd bin/$(CONFIG)/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --run WasmSample.dll

runtimepack:
EMSDK_PATH=$(abspath $(TOP)/src/mono/wasm/emsdk) $(TOP)/build.sh -c $(CONFIG) -os Browser -arch wasm -subset Mono+Libs
cd bin/$(CONFIG)/AppBundle && ~/.jsvu/v8 --expose_wasm runtime.js -- $(DOTNET_MONO_LOG_LEVEL) --run WasmSample.dll
64 changes: 58 additions & 6 deletions src/mono/netcore/sample/wasm/console/WasmSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
<TargetOS>Browser</TargetOS>
<MicrosoftNetCoreAppRuntimePackDir>$(ArtifactsBinDir)microsoft.netcore.app.runtime.browser-wasm\$(Configuration)\runtimes\browser-wasm\</MicrosoftNetCoreAppRuntimePackDir>
<BuildDir>$(MSBuildThisFileDirectory)obj\$(Configuration)\wasm</BuildDir>
<AppDir>$(MSBuildThisFileDirectory)bin\$(Configuration)\publish</AppDir>
<AppDir>$(MSBuildThisFileDirectory)bin\$(Configuration)\AppBundle\</AppDir>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<RunAnalyzers>false</RunAnalyzers>
<RunAOTCompilation Condition="'$(RunAOTCompilation)' == ''">false</RunAOTCompilation>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' != 'Debug'">
<!-- Runtime feature defaults to trim unnecessary code -->
<EventSourceSupport>false</EventSourceSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<DebuggerSupport>false</DebuggerSupport>
</PropertyGroup>

<!-- Redirect 'dotnet publish' to in-tree runtime pack -->
Expand All @@ -33,28 +43,70 @@
</ItemGroup>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration);MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Properties="Configuration=Debug;MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Targets="Restore"/>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration)"
Properties="Configuration=Debug"
Targets="Build;Publish"/>
</Target>

<Import Project="$(RepoTasksDir)mobile.tasks\AotCompilerTask\MonoAOTCompiler.props" />
<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\$(Configuration)\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\Debug\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>

<UsingTask TaskName="MonoAOTCompiler"
AssemblyFile="$(ArtifactsBinDir)MonoAOTCompiler\Debug\$(NetCoreAppCurrent)\MonoAOTCompiler.dll" />

<Target Name="BuildApp" AfterTargets="CopyFilesToPublishDirectory" DependsOnTargets="RebuildWasmAppBuilder;Build">
<RemoveDir Directories="$(AppDir)" />

<ItemGroup>
<BundleAssemblies Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll" />
<BundleAssemblies Condition="'$(RunAOTCompilation)' != 'true'" Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll" />
<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(MSBuildThisFileDirectory)$(PublishDir)\*.dll">
<AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
<ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
</AotInputAssemblies>
</ItemGroup>

<Error Condition="'$(RunAOTCompilation)' == 'true' and '$(EMSDK_PATH)' == ''" Text="The EMSDK_PATH environment variable should be set pointing to the emscripten SDK root dir when using AOT."/>

<MonoAOTCompiler
Condition="'$(RunAOTCompilation)' == 'true'"
CompilerBinaryPath="$(MicrosoftNetCoreAppRuntimePackDir)native\cross\mono-aot-cross"
Mode="LLVMOnly"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
UseAotDataFile="false"
AotModulesTablePath="$(MSBuildThisFileDirectory)$(PublishDir)driver-gen.c"
UseLLVM="true"
LLVMPath="$(EMSDK_PATH)\upstream\bin">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />
</MonoAOTCompiler>

<ReadLinesFromFile File="$(MicrosoftNetCoreAppRuntimePackDir)native\src\emcc-flags.txt">
<Output TaskParameter="Lines" PropertyName="EmccFlags" />
</ReadLinesFromFile>

<Exec Condition="'$(RunAOTCompilation)' == 'true'" Command="source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; emcc $(EmccFlags) -DCORE_BINDINGS -DENABLE_AOT=1 -DDRIVER_GEN=1 -I$(MicrosoftNetCoreAppRuntimePackDir)native/include/mono-2.0 -I$(MicrosoftNetCoreAppRuntimePackDir)native/include/wasm -I$(MSBuildThisFileDirectory)$(PublishDir) $(MicrosoftNetCoreAppRuntimePackDir)native/src/driver.c -c -o driver.o" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MSBuildThisFileDirectory)$(PublishDir)" />
<Exec Condition="'$(RunAOTCompilation)' == 'true'" Command="source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; emcc $(EmccFlags) -I$(MicrosoftNetCoreAppRuntimePackDir)native/include/mono-2.0 $(MicrosoftNetCoreAppRuntimePackDir)native/src/corebindings.c -c -o corebindings.o" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MSBuildThisFileDirectory)$(PublishDir)" />
<Exec Condition="'$(RunAOTCompilation)' == 'true'" Command="source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; emcc $(EmccFlags) -DGEN_PINVOKE=1 -I$(MicrosoftNetCoreAppRuntimePackDir)native/include/wasm $(MicrosoftNetCoreAppRuntimePackDir)native/src/pinvoke.c -c -o pinvoke.o" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MSBuildThisFileDirectory)$(PublishDir)" />
<Exec Condition="'$(RunAOTCompilation)' == 'true'" Command="source $(EMSDK_PATH)/emsdk_env.sh &amp;&amp; emcc $(EmccFlags) --js-library $(MicrosoftNetCoreAppRuntimePackDir)native/src/library_mono.js --js-library $(MicrosoftNetCoreAppRuntimePackDir)native/src/binding_support.js --js-library $(MicrosoftNetCoreAppRuntimePackDir)native/src/dotnet_support.js --js-library $(MicrosoftNetCoreAppRuntimePackDir)native/src/pal_random.js driver.o pinvoke.o corebindings.o @(BundleAssemblies->'%(LlvmBitcodeFile)', ' ') libmono-ee-interp.a libmonosgen-2.0.a libmono-ilgen.a libmono-icall-table.a libSystem.Native.a libSystem.IO.Compression.Native.a libicuuc.a libicui18n.a -o dotnet.js" IgnoreStandardErrorWarningFormat="true" WorkingDirectory="$(MSBuildThisFileDirectory)$(PublishDir)" />

<WasmAppBuilder
AppDir="$(AppDir)"
MicrosoftNetCoreAppRuntimePackDir="$(MicrosoftNetCoreAppRuntimePackDir)"
MainAssembly="$(PublishDir)\WasmSample.dll"
MainJS="$(MonoProjectRoot)wasm\runtime-test.js"
Assemblies="@(BundleAssemblies)"/>
<Exec Command="chmod a+x $(AppDir)/run-v8.sh" />
<Exec Command="chmod a+x $(AppDir)run-v8.sh" />

<!-- Run mono-cil-strip on the assemblies -->
<!-- TODO: replace this with a linker task -->
<ItemGroup>
<_managedAppAssemblies Include="$(AppDir)managed\*.dll"/>
</ItemGroup>
<Exec Condition="'$(RunAOTCompilation)' == 'true'" Command="mono-cil-strip %(_managedAppAssemblies.Identity)" />
</Target>

<ItemGroup>
Expand Down
19 changes: 12 additions & 7 deletions src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TOP=$(realpath $(CURDIR)/../../..)
-include Make.config

escape_quote = $(subst ",\",$(1))

DOTNET=$(TOP)/dotnet.sh
JSVU=$(HOME)/.jsvu
CHROMEDRIVER?=$(HOME)/.chromedriver
Expand Down Expand Up @@ -71,13 +73,13 @@ EMCC_RELEASE_FLAGS=-Oz --llvm-opts 2 -DENABLE_NETCORE=1
STRIP_CMD=&& $(EMSDK_PATH)/upstream/bin/wasm-opt --strip-dwarf $(NATIVE_BIN_DIR)/dotnet.wasm -o $(NATIVE_BIN_DIR)/dotnet.wasm

#
# Interpreter builds
# Wasm builds
#

# $(1) - EMCC_FLAGS
# $(2) - libs
# $(3) - strip cmd
define InterpBuildTemplate
define WasmBuildTemplate

$(NATIVE_BIN_DIR):
mkdir -p $$@
Expand All @@ -97,23 +99,26 @@ $(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvok
$(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 runtime/corebindings.c | $(BUILDS_OBJ_DIR)
$(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)/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) -I$(MONO_INCLUDE_DIR) runtime/pinvoke.c -c -o $$@
$(EMCC) $(EMCC_FLAGS) $(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 $$@

build-native: $(NATIVE_BIN_DIR)/dotnet.js
$(NATIVE_BIN_DIR)/src/emcc-flags.txt: | $(NATIVE_BIN_DIR)/src
echo "$(call escape_quote,$(EMCC_FLAGS)) $(1) -Oz" > $$@

build-native: $(NATIVE_BIN_DIR)/dotnet.js $(NATIVE_BIN_DIR)/src/emcc-flags.txt

endef

ifeq ($(CONFIG),Debug)
$(eval $(call InterpBuildTemplate,$(EMCC_DEBUG_FLAGS),$(MONO_LIBS),))
$(eval $(call WasmBuildTemplate,$(EMCC_DEBUG_FLAGS),$(MONO_LIBS),))
else
$(eval $(call InterpBuildTemplate,$(EMCC_RELEASE_FLAGS),$(MONO_LIBS),$(STRIP_CMD)))
$(eval $(call WasmBuildTemplate,$(EMCC_RELEASE_FLAGS),$(MONO_LIBS),$(STRIP_CMD)))
endif

clean-emsdk:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
</ItemGroup>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration);MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Properties="Configuration=Debug;MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Targets="Restore"/>

<MSBuild Projects="@(WasmAppBuildProject)"
Properties="Configuration=$(Configuration)"
Properties="Configuration=Debug"
Targets="Build;Publish"/>
</Target>

<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\$(Configuration)\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>
AssemblyFile="$(ArtifactsBinDir)WasmAppBuilder\Debug\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll"/>

<Target Name="BuildApp" DependsOnTargets="RebuildWasmAppBuilder;Build">
<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/wasm.proj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<ItemGroup>
<IcuDataFiles Include="$(NativeBinDir)*.dat" />
<WasmSrcFiles Include="$(NativeBinDir)src\*.c;
$(NativeBinDir)src\*.js;" />
$(NativeBinDir)src\*.js;
$(NativeBinDir)src\emcc-flags.txt" />
<WasmHeaderFiles Include="$(NativeBinDir)include\wasm\*.h" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 85d2df8

Please sign in to comment.