未验证 提交 fe95ddbe 编写于 作者: R Radek Doulik 提交者: GitHub

[wasm] Initial emscripten 3.1.30 support (#81215)

* [wasm] Initial emscripten 3.1.30 support

* Update icu dependency

* Update emsdk dependency

* Use new docker images

* Add "icudt68_dat" as JS imported function.

It's an undefined symbol in ICU, because we are not linking in a lib, that should in the end be linked out.
Updated version of emscripten has by default turned on the LLD_REPORT_UNDEFINED .

* Drop build-time support for undefined icudt68_dat.

* Fix linker options

Should be `--lto-O0`

* Fix remaining conflict

* Limit new warnings option to browser

* Try to force reinstall of certifi

* Unset `FROZEN_CACHE` for `embuilder build MINIMAL`

* Update emsdk deps

* Remove assert for stack address

The linker puts stack at 0 sometime, so just check that the stack size
is not zero.

* Get back the stack base assert

For non-wasm targets. Add comment.

* Set stack size to 5MB

Which was the default size in older emscripten versions. Let see if it
is related to some of the issues.

* Disable WBT tests with SkiSharp

context: https://github.com/dotnet/runtime/issues/82725

* Disable more WBT tests with SkiSharp

* Set the stack size also in native targets

* Update icu deps

* Update emsdk deps

* Enable BigInt support
Co-authored-by: Npavelsavara <pavel.savara@gmail.com>

* Enable BigInt here as well

* Temporarily allow undefined symbols

To unblock other work. After merge of main we are now again getting
linker errors with:

    .nuget/packages/microsoft.netcore.runtime.icu.transport/8.0.0-preview.3.23128.1/runtimes/browser-wasm/native/lib/libicuuc.a(udata.ao): undefined symbol: icudt68_dat

* Try to use pip-system-certs package
Co-authored-by: NAnkit Jain <radical@gmail.com>

* Fix merge damage for marking "icudt68_dat" a JS imported function + revert temporal fix.

* Try another python certifi package

* Try install pip-system-certs for emsdk's python

* Try to update machine certs for www.sqlite.org

* Refactor + upgrade pip

Also use the newer pip-system-certs again

* Use new net8 images

* Add `-s INCOMING_MODULE_JS_API=print,printErr`

* Introduce EmccStackSize msbuild property

* Remove FIXME from merge

We don't have afterUpdateGlobalBufferAndViews anymore

* Fixes around updateMemoryViews

* Pass --experimental-wasm-bigint to v8

Ubuntu 18.04 helix image has old v8

* Try multiple --engine-arg options

* Revert "Introduce EmccStackSize msbuild property"

This reverts commit f67ea5e303421bb89f5521f425f22a82aa5d6f46.

* Disable 3 filesystem related tests

* Add bigint to AOT test template

* Introduce EmccStackSize msbuild property

* Update emsdk deps

* Update icu deps

* Revert "Add `-s INCOMING_MODULE_JS_API=print,printErr`"

This reverts commit 889d0366e4438880029c85ac800d4403f713dfff.

* Update emsdk deps

* Update icu deps

* Disable one more file related test

---------
Co-authored-by: NMarek Fišera <mara@neptuo.com>
Co-authored-by: Npavelsavara <pavel.savara@gmail.com>
Co-authored-by: NAnkit Jain <radical@gmail.com>
Co-authored-by: NLarry Ewing <lewing@microsoft.com>
上级 8d9ca3fc
<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>
......@@ -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>
......
......@@ -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>
......@@ -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_Transport
-->
<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>
......
......@@ -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
......
......@@ -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 }}
# 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")
......@@ -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
......
......@@ -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"
fi
fi
fi
......
......@@ -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>
......
......@@ -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();
......@@ -184,6 +185,7 @@ public void SetDateTimeMax()
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/83197", TestPlatforms.Browser)]
public void SetLastAccessTimeTicks()
{
string firstFile = GetTestFilePath();
......
......@@ -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;
......
......@@ -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))
......
......@@ -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)
......
......@@ -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)" />
......@@ -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 -->
......
......@@ -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);
#endif
g_assert (stsize);
info->stack_start_limit = staddr;
info->stack_end = staddr + stsize;
......
......@@ -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
......
......@@ -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()}";
......@@ -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()}";
......
......@@ -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";
......
......@@ -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>
......@@ -322,10 +323,12 @@
<WriteLinesToFile Lines="@(_EmccCFlags)" File="$(_EmccCompileRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_EmccCompileRsp)" />
<EmscriptenMinimalBuildEnvVars Include="@(EmscriptenEnvVars)" />
<EmscriptenMinimalBuildEnvVars Include="FROZEN_CACHE=" />
</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>
......@@ -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)" />
......
......@@ -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`.
......
3.1.12
\ No newline at end of file
3.1.30
\ No newline at end of file
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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);
......
......@@ -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;
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;
......
......@@ -32,7 +32,7 @@ __dotnet_replacement_PThread.loadWasmModuleToWorker = PThread.loadWasmModuleToWo
__dotnet_replacement_PThread.threadInitTLS = PThread.threadInitTLS;
__dotnet_replacement_PThread.allocateUnusedWorker = PThread.allocateUnusedWorker;
` : ''}
let __dotnet_replacements = {scriptUrl: import.meta.url, fetch: globalThis.fetch, require, updateGlobalBufferAndViews, pthreadReplacements: __dotnet_replacement_PThread};
let __dotnet_replacements = {scriptUrl: import.meta.url, fetch: globalThis.fetch, require, updateMemoryViews, pthreadReplacements: __dotnet_replacement_PThread};
if (ENVIRONMENT_IS_NODE) {
__dotnet_replacements.requirePromise = __requirePromise;
}
......@@ -40,7 +40,7 @@ let __dotnet_exportedAPI = __initializeImportsAndExports(
{ isGlobal:false, isNode:ENVIRONMENT_IS_NODE, isWorker:ENVIRONMENT_IS_WORKER, isShell:ENVIRONMENT_IS_SHELL, isWeb:ENVIRONMENT_IS_WEB, isPThread:${isPThread}, quit_, ExitStatus, requirePromise:__dotnet_replacements.requirePromise },
{ mono:MONO, binding:BINDING, internal:INTERNAL, module:Module, marshaled_imports: IMPORTS },
__dotnet_replacements, __callbackAPI);
updateGlobalBufferAndViews = __dotnet_replacements.updateGlobalBufferAndViews;
updateMemoryViews = __dotnet_replacements.updateMemoryViews;
fetch = __dotnet_replacements.fetch;
_scriptDir = __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
if (ENVIRONMENT_IS_NODE) {
......@@ -97,6 +97,8 @@ let linked_functions = [
"mono_wasm_invoke_import",
"mono_wasm_bind_cs_function",
"mono_wasm_marshal_promise",
"icudt68_dat",
];
if (monoWasmThreads) {
......
......@@ -18,7 +18,7 @@ import { mono_wasm_gc_lock, mono_wasm_gc_unlock } from "./gc-lock";
export function export_internal(): any {
return {
// tests
mono_wasm_exit: (exit_code: number) => { Module.printErr("MONO_WASM: early exit " + exit_code); },
mono_wasm_exit: (exit_code: number) => { Module.err("MONO_WASM: early exit " + exit_code); },
mono_wasm_enable_on_demand_gc: cwraps.mono_wasm_enable_on_demand_gc,
mono_wasm_profiler_init_aot: cwraps.mono_wasm_profiler_init_aot,
mono_wasm_profiler_init_browser: cwraps.mono_wasm_profiler_init_browser,
......
......@@ -80,11 +80,11 @@ function initializeImportsAndExports(
module.configSrc = "./mono-config.json";
}
if (!module.print) {
module.print = console.log.bind(console);
if (!module.out) {
module.out = console.log.bind(console);
}
if (!module.printErr) {
module.printErr = console.error.bind(console);
if (!module.err) {
module.err = console.error.bind(console);
}
if (typeof module.disableDotnet6Compatibility === "undefined") {
......
......@@ -25,7 +25,7 @@ export function http_wasm_abort_response(res: ResponseExtension): void {
if (res.__reader) {
res.__reader.cancel().catch((err) => {
if (err && err.name !== "AbortError") {
Module.printErr("MONO_WASM: Error in http_wasm_abort_response: " + err);
Module.err("MONO_WASM: Error in http_wasm_abort_response: " + err);
}
// otherwise, it's expected
});
......
......@@ -40,7 +40,7 @@ export function mono_wasm_globalization_init(): void {
invariantMode = true;
} else {
const msg = "invariant globalization mode is inactive and no ICU data archives were loaded";
Module.printErr(`MONO_WASM: ERROR: ${msg}`);
Module.err(`MONO_WASM: ERROR: ${msg}`);
throw new Error(msg);
}
}
......
......@@ -91,7 +91,7 @@ export function mono_wasm_bind_cs_function(fully_qualified_name: MonoStringRef,
wrap_no_error_root(is_exception, resultRoot);
}
catch (ex: any) {
Module.printErr(ex.toString());
Module.err(ex.toString());
wrap_error_root(is_exception, ex, resultRoot);
} finally {
resultRoot.release();
......
......@@ -90,7 +90,7 @@ export function mono_wasm_bind_js_function(function_name: MonoStringRef, module_
endMeasure(mark, MeasuredBlock.bindJsFunction, js_function_name);
} catch (ex: any) {
setI32_unchecked(function_js_handle, 0);
Module.printErr(ex.toString());
Module.err(ex.toString());
wrap_error_root(is_exception, ex, resultRoot);
} finally {
resultRoot.release();
......
......@@ -10,7 +10,6 @@ import cwraps, { I52Error } from "./cwraps";
const alloca_stack: Array<VoidPtr> = [];
const alloca_buffer_size = 32 * 1024;
let alloca_base: VoidPtr, alloca_offset: VoidPtr, alloca_limit: VoidPtr;
let HEAPI64: BigInt64Array = <any>null;
function _ensure_allocated(): void {
if (alloca_base)
......@@ -20,7 +19,8 @@ function _ensure_allocated(): void {
alloca_limit = <VoidPtr>(<any>alloca_base + alloca_buffer_size);
}
const is_bigint_supported = typeof BigInt !== "undefined" && typeof BigInt64Array !== "undefined";
const max_int64_big = BigInt("9223372036854775807");
const min_int64_big = BigInt("-9223372036854775808");
export function temp_malloc(size: number): VoidPtr {
_ensure_allocated();
......@@ -135,11 +135,10 @@ export function setU52(offset: MemOffset, value: number): void {
}
export function setI64Big(offset: MemOffset, value: bigint): void {
mono_assert(is_bigint_supported, "BigInt is not supported.");
mono_assert(typeof value === "bigint", () => `Value is not an bigint: ${value} (${typeof (value)})`);
mono_assert(value >= min_int64_big && value <= max_int64_big, () => `Overflow: value ${value} is out of ${min_int64_big} ${max_int64_big} range`);
HEAPI64[<any>offset >>> 3] = value;
Module.HEAP64[<any>offset >>> 3] = value;
}
export function setF32(offset: MemOffset, value: number): void {
......@@ -218,8 +217,7 @@ export function getU52(offset: MemOffset): number {
}
export function getI64Big(offset: MemOffset): bigint {
mono_assert(is_bigint_supported, "BigInt is not supported.");
return HEAPI64[<any>offset >>> 3];
return Module.HEAP64[<any>offset >>> 3];
}
export function getF32(offset: MemOffset): number {
......@@ -230,16 +228,6 @@ export function getF64(offset: MemOffset): number {
return Module.HEAPF64[<any>offset >>> 3];
}
let max_int64_big: BigInt;
let min_int64_big: BigInt;
export function afterUpdateGlobalBufferAndViews(buffer: ArrayBufferLike): void {
if (is_bigint_supported) {
max_int64_big = BigInt("9223372036854775807");
min_int64_big = BigInt("-9223372036854775808");
HEAPI64 = new BigInt64Array(buffer);
}
}
/// Allocates a new buffer of the given size on the Emscripten stack and passes a pointer to it to the callback.
/// Returns the result of the callback. As usual with stack allocations, the buffer is freed when the callback returns.
/// Do not attempt to use the stack pointer after the callback is finished.
......
......@@ -4,7 +4,6 @@
import BuildConfiguration from "consts:configuration";
import MonoWasmThreads from "consts:monoWasmThreads";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, INTERNAL, Module, runtimeHelpers } from "./imports";
import { afterUpdateGlobalBufferAndViews } from "./memory";
import { replaceEmscriptenPThreadLibrary } from "./pthreads/shared/emscripten-replacements";
import { DotnetModuleConfigImports, EarlyReplacements } from "./types";
import { TypedArray } from "./types/emscripten";
......@@ -175,10 +174,9 @@ export function init_polyfills(replacements: EarlyReplacements): void {
}
// memory
const originalUpdateGlobalBufferAndViews = replacements.updateGlobalBufferAndViews;
runtimeHelpers.updateGlobalBufferAndViews = replacements.updateGlobalBufferAndViews = (buffer: ArrayBufferLike) => {
originalUpdateGlobalBufferAndViews(buffer);
afterUpdateGlobalBufferAndViews(buffer);
const originalUpdateMemoryViews = replacements.updateMemoryViews;
runtimeHelpers.updateMemoryViews = replacements.updateMemoryViews = () => {
originalUpdateMemoryViews();
};
}
......
......@@ -111,11 +111,11 @@ function set_exit_code_and_quit_now(exit_code: number, reason?: any): void {
if (reason && !(reason instanceof runtimeHelpers.ExitStatus)) {
if (!runtimeHelpers.config.logExitCode) {
if (reason instanceof Error)
Module.printErr(mono_wasm_stringify_as_error_with_stack(reason));
Module.err(mono_wasm_stringify_as_error_with_stack(reason));
else if (typeof reason == "string")
Module.printErr(reason);
Module.err(reason);
else
Module.printErr(JSON.stringify(reason));
Module.err(JSON.stringify(reason));
}
}
else {
......
......@@ -100,7 +100,7 @@ function instantiateWasm(
// this is called so early that even Module exports like addRunDependency don't exist yet
if (!Module.configSrc && !Module.config && !userInstantiateWasm) {
Module.print("MONO_WASM: configSrc nor config was specified");
Module.out("MONO_WASM: configSrc nor config was specified");
}
normalizeConfig();
......@@ -392,10 +392,10 @@ async function mono_wasm_after_user_runtime_initialized(): Promise<void> {
function _print_error(message: string, err: any): void {
Module.printErr(`${message}: ${JSON.stringify(err)}`);
Module.err(`${message}: ${JSON.stringify(err)}`);
if (err.stack) {
Module.printErr("MONO_WASM: Stacktrace: \n");
Module.printErr(err.stack);
Module.err("MONO_WASM: Stacktrace: \n");
Module.err(err.stack);
}
}
......
......@@ -230,7 +230,7 @@ export type RuntimeHelpers = {
loadedFiles: string[],
preferredIcuAsset: string | null,
timezone: string | null,
updateGlobalBufferAndViews: (buffer: ArrayBufferLike) => void
updateMemoryViews: () => void
}
export type GlobalizationMode =
......@@ -368,7 +368,7 @@ export type EarlyReplacements = {
require: any,
requirePromise: Promise<Function>,
noExitRuntime: boolean,
updateGlobalBufferAndViews: Function,
updateMemoryViews: Function,
pthreadReplacements: PThreadReplacements | undefined | null
scriptDirectory: string;
scriptUrl: string
......
......@@ -26,6 +26,7 @@ export declare interface EmscriptenModule {
HEAP8: Int8Array,
HEAP16: Int16Array;
HEAP32: Int32Array;
HEAP64: BigInt64Array;
HEAPU8: Uint8Array;
HEAPU16: Uint16Array;
HEAPU32: Uint32Array;
......@@ -37,8 +38,8 @@ export declare interface EmscriptenModule {
_free(ptr: VoidPtr): void;
// this should match emcc -s EXPORTED_RUNTIME_METHODS
print(message: string): void;
printErr(message: string): void;
out(message: string): void;
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;
......
......@@ -33,7 +33,6 @@
<_EmccDefaultsRspPath>$(NativeBinDir)src\emcc-default.rsp</_EmccDefaultsRspPath>
<_EmccCompileRspPath>$(NativeBinDir)src\emcc-compile.rsp</_EmccCompileRspPath>
<_EmccLinkRspPath>$(NativeBinDir)src\emcc-link.rsp</_EmccLinkRspPath>
<_EmccLinkUndefinedSymbolsFile>$(WasmObjDir)src\symbols.undefined</_EmccLinkUndefinedSymbolsFile>
<WasmNativeStrip Condition="'$(ContinuousIntegrationBuild)' == 'true'">false</WasmNativeStrip>
<EmSdkLLVMAr>$(EMSDK_PATH)\upstream\bin\llvm-ar</EmSdkLLVMAr>
<EmSdkLLVMAr Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(EmSdkLLVMAr).exe</EmSdkLLVMAr>
......@@ -186,7 +185,8 @@
<ItemGroup>
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="print" />
<EmccExportedRuntimeMethod Include="out" />
<EmccExportedRuntimeMethod Include="err" />
<EmccExportedRuntimeMethod Include="ccall" />
<EmccExportedRuntimeMethod Include="cwrap" />
<EmccExportedRuntimeMethod Include="setValue" />
......@@ -275,9 +275,11 @@
<_EmccExportedRuntimeMethods>&quot;[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]&quot;</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
<EmccInitialHeapSize>16777216</EmccInitialHeapSize>
<EmccStackSize>5MB</EmccStackSize>
</PropertyGroup>
<ItemGroup>
<_EmccLinkFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" />
<_EmccLinkFlags Include="-s STACK_SIZE=$(EmccStackSize)" />
<_EmccCommonFlags Condition="'$(WasmEnableSIMD)' == 'true'" Include="-msimd128" />
<_EmccCommonFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s USE_PTHREADS=1" />
<_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-Wno-pthreads-mem-growth" />
......@@ -292,6 +294,7 @@
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)" />
<_EmccLinkFlags Include="--source-map-base http://example.com" />
<_EmccLinkFlags Include="-s STRICT_JS=1" />
<_EmccLinkFlags Include="-s WASM_BIGINT=1" />
<_EmccLinkFlags Include="-s EXPORT_NAME=&quot;'createDotnetRuntime'&quot;" />
<_EmccLinkFlags Include="-s MODULARIZE=1"/>
......@@ -299,8 +302,6 @@
<!-- remove -Wno-limited-postlink-optimizations once below issue is fixed
active issue: https://github.com/emscripten-core/emscripten/pull/16727 -->
<_EmccLinkFlags Include="-Wno-limited-postlink-optimizations"/>
<_EmccLinkUndefinedSymbols Include="icudt68_dat" />
</ItemGroup>
<ItemGroup Condition="'$(MonoWasmThreads)' == 'true'">
......@@ -355,10 +356,6 @@
Lines="@(_EmccLinkFlags)"
WriteOnlyWhenDifferent="true"
Overwrite="true" />
<WriteLinesToFile File="$(_EmccLinkUndefinedSymbolsFile)"
Lines="@(_EmccLinkUndefinedSymbols)"
WriteOnlyWhenDifferent="true"
Overwrite="true" />
</Target>
<!-- This is a documented target that is invoked by developers in their innerloop work. -->
......@@ -382,7 +379,6 @@
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Release'">-O2</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags>$(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags>$(CMakeConfigurationLinkFlags) -Wl,--allow-undefined-file=$(_EmccLinkUndefinedSymbolsFile)</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags Condition="'$(MonoWasmThreads)' == 'true'">$(CMakeConfigurationLinkFlags) -Wno-pthreads-mem-growth</CMakeConfigurationLinkFlags>
<CMakeConfigurationLinkFlags >$(CMakeConfigurationLinkFlags) --emit-symbol-map</CMakeConfigurationLinkFlags>
......
......@@ -156,6 +156,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
add_compile_options(-Wno-typedef-redefinition)
add_compile_options(-Wno-c11-extensions)
add_compile_options(-Wno-thread-safety-analysis)
if (CLR_CMAKE_TARGET_BROWSER)
add_compile_options(-Wno-unsafe-buffer-usage)
add_compile_options(-Wno-cast-function-type-strict)
endif ()
endif ()
add_subdirectory(System.Native)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册