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

[wasm] Initial emscripten 3.1.30 support #81215

Merged
merged 57 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ed80ed3
[wasm] Initial emscripten 3.1.30 support
radekdoulik Jan 26, 2023
96d59b8
Update icu dependency
radekdoulik Feb 10, 2023
6512388
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-emscr…
radekdoulik Feb 10, 2023
0d522ba
Update emsdk dependency
radekdoulik Feb 10, 2023
f5a205e
Use new docker images
radekdoulik Feb 10, 2023
7d2e8eb
Add "icudt68_dat" as JS imported function.
maraf Feb 13, 2023
44ede5e
Drop build-time support for undefined icudt68_dat.
maraf Feb 14, 2023
ab5c12e
Fix linker options
radekdoulik Feb 20, 2023
2e74270
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-emscr…
radekdoulik Feb 20, 2023
e275857
Fix remaining conflict
radekdoulik Feb 20, 2023
54dfd24
Limit new warnings option to browser
radekdoulik Feb 20, 2023
c302891
Try to force reinstall of certifi
radekdoulik Feb 20, 2023
9f145a3
Unset `FROZEN_CACHE` for `embuilder build MINIMAL`
radekdoulik Feb 21, 2023
d6f6a4e
Update emsdk deps
radekdoulik Feb 22, 2023
5067a1d
Remove assert for stack address
radekdoulik Feb 24, 2023
0bb6b01
Get back the stack base assert
radekdoulik Feb 27, 2023
04a83eb
Set stack size to 5MB
radekdoulik Feb 27, 2023
eb544bd
Disable WBT tests with SkiSharp
radekdoulik Feb 27, 2023
8b4a6e2
Disable more WBT tests with SkiSharp
radekdoulik Feb 28, 2023
6e8bd62
Set the stack size also in native targets
radekdoulik Feb 28, 2023
48464d3
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Feb 28, 2023
df724b5
Update icu deps
radekdoulik Mar 1, 2023
2d67a1f
Update emsdk deps
radekdoulik Mar 1, 2023
e6ecd14
Enable BigInt support
radekdoulik Mar 1, 2023
918a47a
Enable BigInt here as well
radekdoulik Mar 1, 2023
cde2398
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Mar 1, 2023
b7999eb
Temporarily allow undefined symbols
radekdoulik Mar 2, 2023
1107185
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Mar 2, 2023
4f5b216
Try to use pip-system-certs package
radekdoulik Mar 2, 2023
0b3ce3c
Fix merge damage for marking "icudt68_dat" a JS imported function + r…
maraf Mar 3, 2023
053f2d3
Try another python certifi package
radekdoulik Mar 3, 2023
a5a8498
Merge branch 'main' into pr-wasm-emscripten-3-1-30
lewing Mar 3, 2023
a977682
Try install pip-system-certs for emsdk's python
radekdoulik Mar 6, 2023
d8b1e10
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Mar 6, 2023
1e02d7c
Try to update machine certs for www.sqlite.org
radekdoulik Mar 6, 2023
e8f080b
Refactor + upgrade pip
radekdoulik Mar 6, 2023
031511d
Use new net8 images
radekdoulik Mar 8, 2023
889d036
Add `-s INCOMING_MODULE_JS_API=print,printErr`
radekdoulik Mar 8, 2023
f67ea5e
Introduce EmccStackSize msbuild property
radekdoulik Mar 8, 2023
37f4314
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Mar 8, 2023
c179e40
Remove FIXME from merge
radekdoulik Mar 8, 2023
d2ee742
Fixes around updateMemoryViews
radekdoulik Mar 8, 2023
84dbae9
Pass --experimental-wasm-bigint to v8
radekdoulik Mar 8, 2023
b94be3d
Try multiple --engine-arg options
radekdoulik Mar 9, 2023
b551626
Revert "Introduce EmccStackSize msbuild property"
radekdoulik Mar 9, 2023
4c45801
Disable 3 filesystem related tests
radekdoulik Mar 9, 2023
c5f073f
Add bigint to AOT test template
radekdoulik Mar 9, 2023
b2a99a8
Introduce EmccStackSize msbuild property
radekdoulik Mar 8, 2023
fda96f7
Update emsdk deps
radekdoulik Mar 9, 2023
55fddbf
Update icu deps
radekdoulik Mar 9, 2023
0da18d5
Revert "Add `-s INCOMING_MODULE_JS_API=print,printErr`"
radekdoulik Mar 9, 2023
eb7be72
Merge branch 'main' into pr-wasm-emscripten-3-1-30
radekdoulik Mar 9, 2023
3fcf10f
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-emscr…
radekdoulik Mar 10, 2023
6420bf6
Update emsdk deps
radekdoulik Mar 10, 2023
58b5c1d
Update icu deps
radekdoulik Mar 10, 2023
2a446e1
Disable one more file related test
radekdoulik Mar 10, 2023
ef6443c
Merge branch 'main' into pr-wasm-emscripten-3-1-30
lewing Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="8.0.0-preview.3.23159.2">
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="8.0.0-preview.3.23160.1">
<Uri>https://github.com/dotnet/icu</Uri>
<Sha>38d4086df0bf334ccf48e12e257b8759b0c9e97f</Sha>
<Sha>ce62ebe8dbfec7cdf79421d32b2c8eac439ad78c</Sha>
</Dependency>
<Dependency Name="System.Net.MsQuic.Transport" Version="8.0.0-alpha.1.23156.1">
<Uri>https://github.com/dotnet/msquic</Uri>
Expand Down Expand Up @@ -85,9 +85,9 @@
<Sha>b126490cd618d6066ed44e0369b4585e845cf9ab</Sha>
<SourceBuild RepoName="cecil" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-preview.3.23159.3">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-preview.3.23160.1">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>b211c38c398416b516ffab1806b8ba47d49c42da</Sha>
<Sha>352d64e0ce9b99a8cff6207621432a986920ffd9</Sha>
<SourceBuild RepoName="emsdk" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
<!-- Mono Cecil -->
<MicrosoftDotNetCecilVersion>0.11.4-alpha.23156.1</MicrosoftDotNetCecilVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-preview.3.23159.2</MicrosoftNETCoreRuntimeICUTransportVersion>
<MicrosoftNETCoreRuntimeICUTransportVersion>8.0.0-preview.3.23160.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- MsQuic -->
<MicrosoftNativeQuicMsQuicVersion>2.1.7</MicrosoftNativeQuicMsQuicVersion>
<SystemNetMsQuicTransportVersion>8.0.0-alpha.1.23156.1</SystemNetMsQuicTransportVersion>
Expand All @@ -238,7 +238,7 @@
Note: when the name is updated, make sure to update dependency name in eng/pipelines/common/xplat-setup.yml
like - DarcDependenciesChanged.Microsoft_NET_Workload_Emscripten_Current_Manifest-8_0_100-preview_2
-->
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-preview.3.23159.3</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-preview.3.23160.1</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETRuntimeEmscriptenVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion)</MicrosoftNETRuntimeEmscriptenVersion>
<!-- workloads -->
<SwixPackageVersion>1.1.87-gba258badda</SwixPackageVersion>
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/common/templates/pipeline-with-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ resources:
ROOTFS_DIR: /crossrootfs/ppc64le

- container: browser_wasm
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-webassembly
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-webassembly-net8

- container: wasi_wasm
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly-net8

- container: freebsd_x64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-freebsd-12
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/libraries/helix-queues-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ jobs:

# Browser WebAssembly windows
- ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}:
- (Windows.Amd64.Server2022.Open)windows.amd64.server2022.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly
- (Windows.Amd64.Server2022.Open)windows.amd64.server2022.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly-net8

${{ insert }}: ${{ parameters.jobParameters }}
46 changes: 28 additions & 18 deletions eng/pipelines/mono/update-machine-certs.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
# This seems to update the machine cert store so that python can download the files as required by emscripten's install
# Based on info at https://pypi.org/project/certifi/
pip install certifi
python -m pip install --upgrade pip
pip install --upgrade certifi pip-system-certs

$WebsiteURL="storage.googleapis.com"
Try {
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL,443)
function UpdateSite {

param (
$WebsiteURL
)

Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL,443)

$Cert = $Stream.Get_RemoteCertificate()
Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)

$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())
$Cert = $Stream.Get_RemoteCertificate()

Write-Host "`nConnection Successful" -ForegroundColor DarkGreen
Write-Host "Website: $WebsiteURL"
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`nError occurred connecting to $($WebsiteURL)" -ForegroundColor Yellow
$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())

Write-Host "`nConnection Successful" -ForegroundColor DarkGreen
Write-Host "Website: $WebsiteURL"
Write-Host "Status:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`nError occurred connecting to $($WebsiteURL)" -ForegroundColor Yellow
Write-Host "Website: $WebsiteURL"
Write-Host "Status:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
}

UpdateSite("storage.googleapis.com")
UpdateSite("www.sqlite.org")
10 changes: 5 additions & 5 deletions eng/testing/WasmRunnerAOTTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ if [[ -z "$XHARNESS_COMMAND" ]]; then
fi

if [[ "$XHARNESS_COMMAND" == "test" ]]; then
if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
fi

if [[ -z "$JS_ENGINE" ]]; then
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE="--engine=NodeJS"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
else
JS_ENGINE="--engine=V8"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd --engine-arg=--experimental-wasm-bigint"
fi
fi

if [[ -z "$MAIN_JS" ]]; then
MAIN_JS="--js-file=test-main.js"
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
fi
fi

if [[ -z "$XHARNESS_ARGS" ]]; then
Expand Down
6 changes: 5 additions & 1 deletion eng/testing/WasmRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
else
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000 --engine-arg=--experimental-wasm-bigint"
Copy link
Contributor

Choose a reason for hiding this comment

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

While we're at it shouldn't we enable SIMD?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not needed here, shouldn't harm though. I can do it in the follow up PR, to avoid more icu/emsdk package switch backs.

fi
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
</PropertyGroup>

<PropertyGroup>
<EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''">-Oz -Wl,-O0 -Wl,-lto-O0</EmccLinkOptimizationFlag>
<EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''">-Oz -Wl,-O0 -Wl,--lto-O0</EmccLinkOptimizationFlag>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void SetLastWriteTimeTicks()
{
string firstFile = GetTestFilePath();
Expand Down Expand Up @@ -184,6 +185,7 @@ public void SetDateTimeMax()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void SetLastAccessTimeTicks()
{
string firstFile = GetTestFilePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ public void LeaveOpenRespected_Basic(bool leaveOpen)
[Theory]
[InlineData(true)]
[InlineData(false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void LeaveOpenRespected_OutstandingViews(bool leaveOpen)
{
const int Capacity = 4096;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public void InvalidAfterDisposal()
/// Test to verify that we can still use a view after the associated map has been disposed.
/// </summary>
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void UseAfterMMFDisposal()
{
foreach (MemoryMappedFile mmf in CreateSampleMaps(8192))
Expand Down
1 change: 1 addition & 0 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten")
add_definitions(-D_THREAD_SAFE)
add_compile_options(-Wno-strict-prototypes)
add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
set(DISABLE_EXECUTABLES 1)
# FIXME: Is there a cmake option for this ?
set(DISABLE_SHARED_LIBS 1)
Expand Down
5 changes: 5 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<ActivateCmd>$(EMSDK_PATH)/emsdk$(EmsdkExt) activate $(EmscriptenVersion)</ActivateCmd>
<InstallCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command &quot;&amp; $(InstallCmd); Exit $LastExitCode &quot;</InstallCmd>
<ActivateCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command &quot;&amp; $(ActivateCmd); Exit $LastExitCode &quot;</ActivateCmd>
<PythonCmd Condition="'$(HostOS)' == 'windows'and '$(TargetsBrowser)' == 'true'">setlocal EnableDelayedExpansion &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; !EMSDK_PYTHON!</PythonCmd>
</PropertyGroup>

<RemoveDir Directories="$(EMSDK_PATH)" />
Expand All @@ -162,6 +163,10 @@
<Exec Command="git checkout $(EmscriptenVersion) &amp;&amp; $(InstallCmd) &amp;&amp; $(ActivateCmd)"
WorkingDirectory="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
<Exec Command="$(PythonCmd) -m pip install certifi &amp;&amp; $(PythonCmd) -m pip install pip-system-certs"
Condition="'$(HostOS)' == 'windows'"
WorkingDirectory="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
</Target>

<!-- Sets up WASI SDK if you don't have the WASI_SDK_PATH env variable set -->
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/utils/mono-threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ register_thread (MonoThreadInfo *info)
mono_native_tls_set_value (thread_info_key, info);

mono_thread_info_get_stack_bounds (&staddr, &stsize);

/* for wasm, the stack can be placed at the start of the linear memory */
#ifndef TARGET_WASM
g_assert (staddr);
radekdoulik marked this conversation as resolved.
Show resolved Hide resolved
#endif
g_assert (stsize);
info->stack_start_limit = staddr;
info->stack_end = staddr + stsize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config)
[InlineData("Release", /*build*/true, /*publish*/false)]
[InlineData("Release", /*build*/false, /*publish*/true)]
[InlineData("Release", /*build*/true, /*publish*/true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public async Task WithDllImportInMainAssembly(string config, bool build, bool publish)
{
// Based on https://github.com/dotnet/runtime/issues/59255
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/NativeRefTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public NativeRefTests(ITestOutputHelper output, SharedBuildPerTestClassFixture b
[Theory]
[InlineData("Debug")]
[InlineData("Release")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void WithNativeReference_AOTInProjectFile(string config)
{
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
Expand All @@ -41,6 +42,7 @@ public void WithNativeReference_AOTInProjectFile(string config)
[Theory]
[InlineData("Debug")]
[InlineData("Release")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void WithNativeReference_AOTOnCommandLine(string config)
{
string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void ProjectWithNativeReference(BuildArgs buildArgs, RunHost host, string
[Theory]
[BuildAndRun(aot: false)]
[BuildAndRun(aot: true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/82725")]
public void ProjectUsingSkiaSharp(BuildArgs buildArgs, RunHost host, string id)
{
string projectName = $"AppUsingSkiaSharp";
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp</_EmccLinkRsp>

<EmccInitialHeapSize Condition="'$(EmccInitialHeapSize)' == ''">$(EmccTotalMemory)</EmccInitialHeapSize>
<EmccStackSize Condition="'$(EmccStackSize)' == ''">5MB</EmccStackSize>
<WasmAllowUndefinedSymbols Condition="'$(WasmAllowUndefinedSymbols)' == ''">false</WasmAllowUndefinedSymbols>
</PropertyGroup>

Expand Down Expand Up @@ -322,10 +323,12 @@
<WriteLinesToFile Lines="@(_EmccCFlags)" File="$(_EmccCompileRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_EmccCompileRsp)" />
<EmscriptenMinimalBuildEnvVars Include="@(EmscriptenEnvVars)" />
Copy link
Member

Choose a reason for hiding this comment

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

It would be clearer to rename this to a private name like _EmscriptenEnvVarsForBuildMinimal.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do it in the follow up PR, to avoid more icu/emsdk package switch backs.

<EmscriptenMinimalBuildEnvVars Include="FROZEN_CACHE=" />
Copy link
Member

Choose a reason for hiding this comment

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

The Microsoft.NET.Runtime.Emscripten.Cache SDK overrides the WasmCachePath property. If we're unfreezing the cache here does that mean we can overwrite the nuget contents sometimes?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we do that on purpose IIRC

<!-- warm up the cache -->
<Exec Command="$(_EmBuilder) build MINIMAL" EnvironmentVariables="@(EmscriptenMinimalBuildEnvVars)" StandardOutputImportance="Low" StandardErrorImportance="Low" />
Is that right @radical?

Copy link
Member

Choose a reason for hiding this comment

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

the freezing/build was required before we were shipping the cache package we should probably review the logic there

Copy link
Member Author

Choose a reason for hiding this comment

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

to provide more context: the reason for the change itself is that the default value of FROZEN_CACHE proably changed with newer emscripten, and so the warming embuilder build MINIMAL build was now failing, complaining about not being able to update frozen cache.

Copy link
Member

Choose a reason for hiding this comment

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

This whole does need to be reviewed again. If the workload is installed in non-user-writable location then how does the build behave? How does the FROZEN_CACHE setting affect things? I have opened #83281 .

</ItemGroup>

<!-- warm up the cache -->
<Exec Command="$(_EmBuilder) build MINIMAL" EnvironmentVariables="@(EmscriptenEnvVars)" StandardOutputImportance="Low" StandardErrorImportance="Low" />
<Exec Command="$(_EmBuilder) build MINIMAL" EnvironmentVariables="@(EmscriptenMinimalBuildEnvVars)" StandardOutputImportance="Low" StandardErrorImportance="Low" />

<Message Text="Compiling native assets with emcc with $(EmccCompileOptimizationFlag). This may take a while ..." Importance="High" />
<ItemGroup>
Expand Down Expand Up @@ -419,6 +422,8 @@
<ItemGroup>
<!-- order matters -->
<_EmccLDSFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" />
<_EmccLDSFlags Include="-s STACK_SIZE=$(EmccStackSize)" />
<_EmccLDSFlags Include="-s WASM_BIGINT=1" />

<_WasmNativeFileForLinking Include="%(_BitcodeFile.ObjectFile)" />
<_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" />
Expand Down
4 changes: 3 additions & 1 deletion src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
- $(EmccExtraLDFlags) - Extra emcc flags for linking
- $(EmccExtraCFlags) - Extra emcc flags for compiling native files
- $(EmccInitialHeapSize) - Initial heap size specified with `emcc`. Default value: 16777216 or size of the DLLs, whichever is larger.
Corresponds to `INITIAL_MEMORY` arg for emcc.
Corresponds to `-s INITIAL_MEMORY=...` emcc arg.
(previously named EmccTotalMemory, which is still kept as an alias)
- $(EmccStackSize) - Stack size. Default value: 5MB.
Corresponds to `-s STACK_SIZE=...` emcc arg.

- $(WasmBuildAppAfterThisTarget) - This target is used as `AfterTargets` for `WasmBuildApp. this
is what triggers the wasm app building. Defaults to `Build`.
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/emscripten-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.12
3.1.30
16 changes: 8 additions & 8 deletions src/mono/wasm/runtime/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ export async function mono_download_assets(): Promise<void> {
// and we are not awating it here
Promise.all(promises_of_asset_instantiation).then(() => {
allAssetsInMemory.promise_control.resolve();
}).catch(err => {
Module.printErr("MONO_WASM: Error in mono_download_assets: " + err);
abort_startup(err, true);
}).catch(e => {
Module.err("MONO_WASM: Error in mono_download_assets: " + e);
abort_startup(e, true);
});
// OPTIMIZATION explained:
// we do it this way so that we could allocate memory immediately after asset is downloaded (and after onRuntimeInitialized which happened already)
// spreading in time
// rather than to block all downloads after onRuntimeInitialized or block onRuntimeInitialized after all downloads are done. That would create allocation burst.
} catch (err: any) {
Module.printErr("MONO_WASM: Error in mono_download_assets: " + err);
throw err;
} catch (e: any) {
Module.err("MONO_WASM: Error in mono_download_assets: " + e);
throw e;
}
}

Expand Down Expand Up @@ -282,7 +282,7 @@ async function start_asset_download_sources(asset: AssetEntryInternal): Promise<
err.status = response.status;
throw err;
} else {
Module.print(`MONO_WASM: optional download '${response.url}' for ${asset.name} failed ${response.status} ${response.statusText}`);
Module.out(`MONO_WASM: optional download '${response.url}' for ${asset.name} failed ${response.status} ${response.statusText}`);
return undefined;
}
}
Expand Down Expand Up @@ -426,7 +426,7 @@ function _instantiate_asset(asset: AssetEntry, url: string, bytes: Uint8Array) {
}
else if (asset.behavior === "icu") {
if (!mono_wasm_load_icu_data(offset!))
Module.printErr(`MONO_WASM: Error loading ICU asset ${asset.name}`);
Module.err(`MONO_WASM: Error loading ICU asset ${asset.name}`);
}
else if (asset.behavior === "resource") {
cwraps.mono_wasm_add_satellite_assembly(virtualName, asset.culture || "", offset!, bytes.length);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ declare interface EmscriptenModule {
HEAPF64: Float64Array;
_malloc(size: number): VoidPtr;
_free(ptr: VoidPtr): void;
print(message: string): void;
printErr(message: string): void;
out(message: string): void;
Copy link
Member

Choose a reason for hiding this comment

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

This is API breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we consider this API stable?

We can still get the deprecated ones with -sINCOMING_MODULE_JS_API=print,printErr if needed.

Copy link
Member

Choose a reason for hiding this comment

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

Do we consider this API stable?

No

We can still get the deprecated ones with -sINCOMING_MODULE_JS_API=print,printErr if needed.

Yes please, I think these 2 are widely enough used even by Uno.

Copy link
Member

Choose a reason for hiding this comment

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

They could be removed from .d.ts but should keep working.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we want to be in the business of maintaining unstable emscripten apis that emscripten has dropped long term but we should document the change and short term compat is fine.

err(message: string): void;
ccall<T>(ident: string, returnType?: string | null, argTypes?: string[], args?: any[], opts?: any): T;
cwrap<T extends Function>(ident: string, returnType: string, argTypes?: string[], opts?: any): T;
cwrap<T extends Function>(ident: string, ...args: any[]): T;
Expand Down
Loading