From 487f24a5218f142a2acb39d9b9b7a710d260fd28 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 16:20:47 +0200 Subject: [PATCH 1/9] check for SIMD and EH support --- eng/testing/performance/performance-setup.sh | 2 +- src/mono/sample/wasm/Directory.Build.targets | 4 +- src/mono/sample/wasm/wasm.mk | 4 +- src/mono/wasm/runtime/loader/polyfills.ts | 21 ++++++++ src/mono/wasm/runtime/loader/run.ts | 11 +---- src/mono/wasm/runtime/package-lock.json | 52 ++++++++++++++++++++ src/mono/wasm/runtime/package.json | 6 ++- src/mono/wasm/runtime/rollup.config.js | 7 ++- src/mono/wasm/wasm.proj | 3 +- 9 files changed, 93 insertions(+), 17 deletions(-) diff --git a/eng/testing/performance/performance-setup.sh b/eng/testing/performance/performance-setup.sh index 0314580ab89535..457dea687b6172 100755 --- a/eng/testing/performance/performance-setup.sh +++ b/eng/testing/performance/performance-setup.sh @@ -403,7 +403,7 @@ if [[ -n "$wasm_bundle_directory" ]]; then wasm_bundle_directory_path=$payload_directory mv $wasm_bundle_directory/* $wasm_bundle_directory_path find $wasm_bundle_directory_path -type d - wasm_args="--expose_wasm" + wasm_args="--experimental-wasm-eh --expose_wasm" if [ "$javascript_engine" == "v8" ]; then # for es6 module support wasm_args="$wasm_args --module" diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets index b61806bd837dfa..7ee7a50412fae6 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -55,10 +55,10 @@ - + - + diff --git a/src/mono/sample/wasm/wasm.mk b/src/mono/sample/wasm/wasm.mk index 6984136c15d266..95f3eb81435363 100644 --- a/src/mono/sample/wasm/wasm.mk +++ b/src/mono/sample/wasm/wasm.mk @@ -45,7 +45,7 @@ run-console: cd bin/$(CONFIG)/AppBundle && $(V8_PATH) --stack-trace-limit=1000 --single-threaded --expose_wasm --module $(MAIN_JS) -- $(ARGS) run-console-node: - cd bin/$(CONFIG)/AppBundle && node --stack-trace-limit=1000 --single-threaded --expose_wasm $(MAIN_JS) $(ARGS) + cd bin/$(CONFIG)/AppBundle && node --stack-trace-limit=1000 --single-threaded --experimental-wasm-eh --expose_wasm $(MAIN_JS) $(ARGS) debug-console-node: - cd bin/$(CONFIG)/AppBundle && node --inspect=9222 --stack-trace-limit=1000 --single-threaded --expose_wasm $(MAIN_JS) $(ARGS) \ No newline at end of file + cd bin/$(CONFIG)/AppBundle && node --inspect=9222 --stack-trace-limit=1000 --single-threaded --experimental-wasm-eh --expose_wasm $(MAIN_JS) $(ARGS) \ No newline at end of file diff --git a/src/mono/wasm/runtime/loader/polyfills.ts b/src/mono/wasm/runtime/loader/polyfills.ts index d77ceabc0b79a6..c2833f29f25b2c 100644 --- a/src/mono/wasm/runtime/loader/polyfills.ts +++ b/src/mono/wasm/runtime/loader/polyfills.ts @@ -1,7 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +import { exceptions, simd } from "wasm-feature-detect"; + import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableSIMD from "consts:wasmEnableSIMD"; +import WasmEnableExceptionHandling from "consts:wasmEnableExceptionHandling"; import type { DotnetModuleInternal } from "../types/internal"; import { INTERNAL, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, loaderHelpers, ENVIRONMENT_IS_WEB, mono_assert } from "./globals"; @@ -31,6 +35,23 @@ export function verifyEnvironment() { // See https://github.com/dotnet/runtime/issues/84574 } +export async function verifyEnvironmentAsync() { + if (ENVIRONMENT_IS_NODE) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore: + const process = await import(/* webpackIgnore: true */"process"); + if (process.versions.node.split(".")[0] < 14) { + throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}'`); + } + } + if (WasmEnableSIMD) { + mono_assert(await simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version."); + } + if (WasmEnableExceptionHandling) { + mono_assert(await exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version."); + } +} + export async function detect_features_and_polyfill(module: DotnetModuleInternal): Promise { const scriptUrlQuery =/* webpackIgnore: true */import.meta.url; diff --git a/src/mono/wasm/runtime/loader/run.ts b/src/mono/wasm/runtime/loader/run.ts index 7d67f920837bc4..e7bee9aa7ab7ea 100644 --- a/src/mono/wasm/runtime/loader/run.ts +++ b/src/mono/wasm/runtime/loader/run.ts @@ -11,7 +11,7 @@ import { deep_merge_config, deep_merge_module, mono_wasm_load_config } from "./c import { mono_exit } from "./exit"; import { setup_proxy_console, mono_log_info } from "./logging"; import { resolve_asset_path, start_asset_download } from "./assets"; -import { detect_features_and_polyfill } from "./polyfills"; +import { detect_features_and_polyfill, verifyEnvironmentAsync } from "./polyfills"; import { runtimeHelpers, loaderHelpers } from "./globals"; import { init_globalization } from "./icu"; import { setupPreloadChannelToMainThread } from "./worker"; @@ -350,14 +350,7 @@ export class HostBuilder implements DotnetHostBuilder { if (ENVIRONMENT_IS_WEB && (module.config! as MonoConfigInternal).forwardConsoleLogsToWS && typeof globalThis.WebSocket != "undefined") { setup_proxy_console("main", globalThis.console, globalThis.location.origin); } - if (ENVIRONMENT_IS_NODE) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: - const process = await import(/* webpackIgnore: true */"process"); - if (process.versions.node.split(".")[0] < 14) { - throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}'`); - } - } + await verifyEnvironmentAsync(); mono_assert(module, "Null moduleConfig"); mono_assert(module.config, "Null moduleConfig.config"); await createEmscripten(module); diff --git a/src/mono/wasm/runtime/package-lock.json b/src/mono/wasm/runtime/package-lock.json index d40ce110212a05..55c859589b5145 100644 --- a/src/mono/wasm/runtime/package-lock.json +++ b/src/mono/wasm/runtime/package-lock.json @@ -248,6 +248,20 @@ "fastq": "^1.6.0" } }, + "@rollup/plugin-node-resolve": { + "version": "15.1.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", + "integrity": "sha1-n/zY6MRXCA26ibufy1g6Z3jcdX4=", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + } + }, "@rollup/plugin-terser": { "version": "0.4.3", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", @@ -298,6 +312,12 @@ "integrity": "sha1-1w+rpwOdX8pUyDx9urQQUdK29ss=", "dev": true }, + "@types/resolve": { + "version": "1.20.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha1-l9JuAM1KBCO0r2IKvs8+b0QreXU=", + "dev": true + }, "@types/semver": { "version": "7.5.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/semver/-/semver-7.5.0.tgz", @@ -485,6 +505,12 @@ "integrity": "sha1-KxRqb9cugLT1XSVfNe1Zo6mkG9U=", "dev": true }, + "builtin-modules": { + "version": "3.3.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha1-yuYoEriYAellYzbkYiPgMDhr57Y=", + "dev": true + }, "callsites": { "version": "3.1.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/callsites/-/callsites-3.1.0.tgz", @@ -554,6 +580,12 @@ "integrity": "sha1-pvLc5hL63S7x9Rm3NVHxfoUZmDE=", "dev": true }, + "deepmerge": { + "version": "4.3.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha1-RLXyFHzTsA1LVhN2hZZvJv0l3Uo=", + "dev": true + }, "dir-glob": { "version": "3.0.1", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/dir-glob/-/dir-glob-3.0.1.tgz", @@ -1019,6 +1051,15 @@ "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=", "dev": true }, + "is-builtin-module": { + "version": "3.2.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha1-8DJxcX2GVM/K8HqwRj+qNXFYEWk=", + "dev": true, + "requires": { + "builtin-modules": "^3.3.0" + } + }, "is-core-module": { "version": "2.12.1", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-core-module/-/is-core-module-2.12.1.tgz", @@ -1148,6 +1189,12 @@ "is-extglob": "^2.1.1" } }, + "is-module": { + "version": "1.0.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "is-number": { "version": "7.0.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-number/-/is-number-7.0.0.tgz", @@ -1706,6 +1753,11 @@ "punycode": "^2.1.0" } }, + "wasm-feature-detect": { + "version": "1.5.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wasm-feature-detect/-/wasm-feature-detect-1.5.1.tgz", + "integrity": "sha1-DbV6fX+MJrdD3ehThiFa4rE154o=" + }, "which": { "version": "2.0.2", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/which/-/which-2.0.2.tgz", diff --git a/src/mono/wasm/runtime/package.json b/src/mono/wasm/runtime/package.json index d1e462179d3588..801b8e6a62e36b 100644 --- a/src/mono/wasm/runtime/package.json +++ b/src/mono/wasm/runtime/package.json @@ -22,19 +22,23 @@ "author": "Microsoft", "license": "MIT", "devDependencies": { + "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-terser": "0.4.3", "@rollup/plugin-typescript": "11.1.2", "@rollup/plugin-virtual": "3.0.1", "@typescript-eslint/eslint-plugin": "5.59.1", "@typescript-eslint/parser": "5.59.1", - "magic-string": "0.30.1", "eslint": "8.44.0", "fast-glob": "3.3.0", "git-commit-info": "2.0.2", + "magic-string": "0.30.1", "rollup": "3.26.2", "rollup-plugin-dts": "5.3.0", "terser": "5.19.0", "tslib": "2.6.0", "typescript": "5.1.6" + }, + "dependencies": { + "wasm-feature-detect": "^1.5.1" } } diff --git a/src/mono/wasm/runtime/rollup.config.js b/src/mono/wasm/runtime/rollup.config.js index d37ba57955b012..add313dc53c5ae 100644 --- a/src/mono/wasm/runtime/rollup.config.js +++ b/src/mono/wasm/runtime/rollup.config.js @@ -2,6 +2,7 @@ import { defineConfig } from "rollup"; import typescript from "@rollup/plugin-typescript"; import terser from "@rollup/plugin-terser"; import virtual from "@rollup/plugin-virtual"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; import { readFile, writeFile, mkdir } from "fs/promises"; import * as fs from "fs"; import * as path from "path"; @@ -18,6 +19,8 @@ const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === const productVersion = process.env.ProductVersion || "8.0.0-dev"; const nativeBinDir = process.env.NativeBinDir ? process.env.NativeBinDir.replace(/"/g, "") : "bin"; const monoWasmThreads = process.env.MonoWasmThreads === "true" ? true : false; +const wasmEnableSIMD = process.env.WasmEnableSIMD === "true" ? true : false; +const wasmEnableExceptionHandling = process.env.WasmEnableExceptionHandling === "true" ? true : false; const wasmEnableLegacyJsInterop = process.env.DISABLE_LEGACY_JS_INTEROP !== "1" ? true : false; const monoDiagnosticsMock = process.env.MonoDiagnosticsMock === "true" ? true : false; const terserConfig = { @@ -90,6 +93,8 @@ const envConstants = { productVersion, configuration, monoWasmThreads, + wasmEnableSIMD, + wasmEnableExceptionHandling, monoDiagnosticsMock, gitHash, wasmEnableLegacyJsInterop, @@ -154,7 +159,7 @@ const loaderConfig = { } ], external: externalDependencies, - plugins: [regexReplace(inlineAssert), regexCheck([checkAssert, checkNoRuntime]), ...outputCodePlugins], + plugins: [nodeResolve(), regexReplace(inlineAssert), regexCheck([checkAssert, checkNoRuntime]), ...outputCodePlugins], onwarn: onwarn }; const runtimeConfig = { diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index c479a8cddf72e4..f714660e7ef3e3 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -25,6 +25,7 @@ $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib')) $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib')) true + true true false emcc @@ -517,7 +518,7 @@ - Configuration:$(Configuration),NativeBinDir:$(NativeBinDir),ProductVersion:$(ProductVersion),MonoWasmThreads:$(MonoWasmThreads),DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop),MonoDiagnosticsMock:$(MonoDiagnosticsMock),ContinuousIntegrationBuild:$(ContinuousIntegrationBuild) + Configuration:$(Configuration),NativeBinDir:$(NativeBinDir),ProductVersion:$(ProductVersion),MonoWasmThreads:$(MonoWasmThreads),WasmEnableSIMD:$(WasmEnableSIMD),WasmEnableExceptionHandling:$(WasmEnableExceptionHandling),DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop),MonoDiagnosticsMock:$(MonoDiagnosticsMock),ContinuousIntegrationBuild:$(ContinuousIntegrationBuild) From de2b8426b515196f8900d9691ac7b023bb389904 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 16:22:54 +0200 Subject: [PATCH 2/9] fix --- src/mono/wasm/runtime/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/runtime/package.json b/src/mono/wasm/runtime/package.json index 801b8e6a62e36b..7e8cf75d607cbe 100644 --- a/src/mono/wasm/runtime/package.json +++ b/src/mono/wasm/runtime/package.json @@ -39,6 +39,6 @@ "typescript": "5.1.6" }, "dependencies": { - "wasm-feature-detect": "^1.5.1" + "wasm-feature-detect": "1.5.1" } } From 35cf3438757d27bcd1f9d651dab3e1f3c7c91251 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 18:45:09 +0200 Subject: [PATCH 3/9] https://aka.ms/dotnet-wasm-features link and document --- src/mono/wasm/features.md | 33 +++++++++++++++++++++++ src/mono/wasm/runtime/http.ts | 4 +-- src/mono/wasm/runtime/loader/polyfills.ts | 13 ++++----- src/mono/wasm/runtime/web-socket.ts | 4 +-- 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 src/mono/wasm/features.md diff --git a/src/mono/wasm/features.md b/src/mono/wasm/features.md new file mode 100644 index 00000000000000..6eff9e1b020a6a --- /dev/null +++ b/src/mono/wasm/features.md @@ -0,0 +1,33 @@ +# Browser or JS engine features + +dotnet for wasm could be compiled with various MsBuild flags which enable use of browser features. If you need to target older version of the browser, you may need to disable some of the dotnet features or optimizations. + +For full set of MSBuild properties [see top of](src\mono\wasm\build\WasmApp.targets) +For set of [browser WASM features see](https://webassembly.org/roadmap/) + +# Multi-threading +Is enabled by `true`. +It requires HTTP headers similar to `Cross-Origin-Embedder-Policy:require-corp` and `Cross-Origin-Opener-Policy:same-origin`. +See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements + +# SIMD - Single instruction, multiple data +Is performance optimization enabled by default. It requires recent version of browser. +You can disable it by `falsetrue`. +[See also](https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md) + +# EH - Exception handling +Is performance optimization enabled by default. It requires recent version of browser. +You can disable it by `falsetrue`. +[See also](https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md) + +# BigInt +Is required if the application uses Int64 marshaling in JS interop. +[See also](https://github.com/WebAssembly/JS-BigInt-integration) + +# fetch browser API +Is required if the application uses [HttpClient](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) +NodeJS needs to install `node-fetch` and `node-abort-controller` npm packages. + +# WebSocket browser API +Is required if the application uses [WebSocketClient](https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket) +NodeJS needs to install `ws` npm package. diff --git a/src/mono/wasm/runtime/http.ts b/src/mono/wasm/runtime/http.ts index 165771082e76bf..1ad6a4fc457bbd 100644 --- a/src/mono/wasm/runtime/http.ts +++ b/src/mono/wasm/runtime/http.ts @@ -10,8 +10,8 @@ import type { VoidPtr } from "./types/emscripten"; function verifyEnvironment() { if (typeof globalThis.fetch !== "function" || typeof globalThis.AbortController !== "function") { const message = ENVIRONMENT_IS_NODE - ? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support." - : "This browser doesn't support fetch API. Please use a modern browser."; + ? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support. See also https://aka.ms/dotnet-wasm-features" + : "This browser doesn't support fetch API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features"; throw new Error(message); } } diff --git a/src/mono/wasm/runtime/loader/polyfills.ts b/src/mono/wasm/runtime/loader/polyfills.ts index c2833f29f25b2c..970610cd4c34ad 100644 --- a/src/mono/wasm/runtime/loader/polyfills.ts +++ b/src/mono/wasm/runtime/loader/polyfills.ts @@ -23,16 +23,13 @@ const URLPolyfill = class URL { }; export function verifyEnvironment() { - mono_assert(ENVIRONMENT_IS_SHELL || typeof globalThis.URL === "function", "This browser/engine doesn't support URL API. Please use a modern version."); - mono_assert(typeof globalThis.BigInt64Array === "function", "This browser/engine doesn't support BigInt64Array API. Please use a modern version."); + mono_assert(ENVIRONMENT_IS_SHELL || typeof globalThis.URL === "function", "This browser/engine doesn't support URL API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); + mono_assert(typeof globalThis.BigInt64Array === "function", "This browser/engine doesn't support BigInt64Array API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); if (MonoWasmThreads) { - mono_assert(!ENVIRONMENT_IS_SHELL && !ENVIRONMENT_IS_NODE, "This build of dotnet is multi-threaded, it doesn't support shell environments like V8 or NodeJS."); - mono_assert(globalThis.SharedArrayBuffer !== undefined, "SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers. See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements"); - mono_assert(typeof globalThis.EventTarget === "function", "This browser/engine doesn't support EventTarget API. Please use a modern version."); + mono_assert(!ENVIRONMENT_IS_SHELL && !ENVIRONMENT_IS_NODE, "This build of dotnet is multi-threaded, it doesn't support shell environments like V8 or NodeJS. See also https://aka.ms/dotnet-wasm-features"); + mono_assert(globalThis.SharedArrayBuffer !== undefined, "SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers. See also https://aka.ms/dotnet-wasm-features"); + mono_assert(typeof globalThis.EventTarget === "function", "This browser/engine doesn't support EventTarget API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); } - - // TODO detect other (WASM) features that are required for the runtime - // See https://github.com/dotnet/runtime/issues/84574 } export async function verifyEnvironmentAsync() { diff --git a/src/mono/wasm/runtime/web-socket.ts b/src/mono/wasm/runtime/web-socket.ts index 28b4e15ad89047..cd77c5060a3b9d 100644 --- a/src/mono/wasm/runtime/web-socket.ts +++ b/src/mono/wasm/runtime/web-socket.ts @@ -32,8 +32,8 @@ function verifyEnvironment() { } if (typeof globalThis.WebSocket !== "function") { const message = ENVIRONMENT_IS_NODE - ? "Please install `ws` npm package to enable networking support." - : "This browser doesn't support WebSocket API. Please use a modern browser."; + ? "Please install `ws` npm package to enable networking support. See also https://aka.ms/dotnet-wasm-features" + : "This browser doesn't support WebSocket API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features"; throw new Error(message); } } From 922ef63e249c052e87ddf071705a24274f24ce09 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 18:47:07 +0200 Subject: [PATCH 4/9] whitespace --- src/mono/wasm/features.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/features.md b/src/mono/wasm/features.md index 6eff9e1b020a6a..ee9904e22ae00d 100644 --- a/src/mono/wasm/features.md +++ b/src/mono/wasm/features.md @@ -6,17 +6,17 @@ For full set of MSBuild properties [see top of](src\mono\wasm\build\WasmApp.targ For set of [browser WASM features see](https://webassembly.org/roadmap/) # Multi-threading -Is enabled by `true`. +Is enabled by `true`. It requires HTTP headers similar to `Cross-Origin-Embedder-Policy:require-corp` and `Cross-Origin-Opener-Policy:same-origin`. See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements # SIMD - Single instruction, multiple data -Is performance optimization enabled by default. It requires recent version of browser. +Is performance optimization enabled by default. It requires recent version of browser. You can disable it by `falsetrue`. [See also](https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md) # EH - Exception handling -Is performance optimization enabled by default. It requires recent version of browser. +Is performance optimization enabled by default. It requires recent version of browser. You can disable it by `falsetrue`. [See also](https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md) From 72e68fb6cb6beec54d8b4e8eb6e2270cd04c6452 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 24 Jul 2023 22:05:30 +0200 Subject: [PATCH 5/9] Update src/mono/wasm/features.md Co-authored-by: Ankit Jain --- src/mono/wasm/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/features.md b/src/mono/wasm/features.md index ee9904e22ae00d..d6da52c0b792c0 100644 --- a/src/mono/wasm/features.md +++ b/src/mono/wasm/features.md @@ -1,6 +1,6 @@ # Browser or JS engine features -dotnet for wasm could be compiled with various MsBuild flags which enable use of browser features. If you need to target older version of the browser, you may need to disable some of the dotnet features or optimizations. +dotnet for wasm can be compiled with various MSBuild flags which enable the use of browser features. If you need to target an older version of the browser, then you may need to disable some of the dotnet features or optimizations. For full set of MSBuild properties [see top of](src\mono\wasm\build\WasmApp.targets) For set of [browser WASM features see](https://webassembly.org/roadmap/) From 1b788dbfc787e38c8d25877cb5b3dcba278102f9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 22:17:56 +0200 Subject: [PATCH 6/9] feedback --- src/mono/wasm/features.md | 4 ++++ src/mono/wasm/runtime/loader/polyfills.ts | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mono/wasm/features.md b/src/mono/wasm/features.md index d6da52c0b792c0..8e2b303d95cf09 100644 --- a/src/mono/wasm/features.md +++ b/src/mono/wasm/features.md @@ -31,3 +31,7 @@ NodeJS needs to install `node-fetch` and `node-abort-controller` npm packages. # WebSocket browser API Is required if the application uses [WebSocketClient](https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket) NodeJS needs to install `ws` npm package. + +# Shell environments - NodeJS & V8 +We pass most of the unit tests with NodeJS v 14 but it's not fully supported target platform. We would like to hear about community use-cases. +We also use v8 engine version 11 or higher to run some of the tests. The engine is lacking many APIs and features. \ No newline at end of file diff --git a/src/mono/wasm/runtime/loader/polyfills.ts b/src/mono/wasm/runtime/loader/polyfills.ts index 970610cd4c34ad..208a423d16bbab 100644 --- a/src/mono/wasm/runtime/loader/polyfills.ts +++ b/src/mono/wasm/runtime/loader/polyfills.ts @@ -37,15 +37,16 @@ export async function verifyEnvironmentAsync() { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: const process = await import(/* webpackIgnore: true */"process"); - if (process.versions.node.split(".")[0] < 14) { - throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}'`); + const minNodeVersion = 14; + if (process.versions.node.split(".")[0] < minNodeVersion) { + throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}', please use at least ${minNodeVersion}. See also https://aka.ms/dotnet-wasm-features`); } } if (WasmEnableSIMD) { - mono_assert(await simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version."); + mono_assert(await simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); } if (WasmEnableExceptionHandling) { - mono_assert(await exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version."); + mono_assert(await exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); } } From 8ad36574ddb1ceba2f8371614efb9e74ec628d9b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 24 Jul 2023 22:27:51 +0200 Subject: [PATCH 7/9] feedback --- src/mono/wasm/wasm.proj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index f714660e7ef3e3..409c31dd0072e0 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -517,8 +517,20 @@ + + <_MonoRollupEnvironmentVariable Include="Configuration:$(Configuration)" /> + <_MonoRollupEnvironmentVariable Include="NativeBinDir:$(NativeBinDir)" /> + <_MonoRollupEnvironmentVariable Include="ProductVersion:$(ProductVersion)" /> + <_MonoRollupEnvironmentVariable Include="MonoWasmThreads:$(MonoWasmThreads)" /> + <_MonoRollupEnvironmentVariable Include="WasmEnableSIMD:$(WasmEnableSIMD)" /> + <_MonoRollupEnvironmentVariable Include="WasmEnableExceptionHandling:$(WasmEnableExceptionHandling)" /> + <_MonoRollupEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop)" /> + <_MonoRollupEnvironmentVariable Include="MonoDiagnosticsMock:$(MonoDiagnosticsMock)" /> + <_MonoRollupEnvironmentVariable Include="ContinuousIntegrationBuild:$(ContinuousIntegrationBuild)" /> + + - Configuration:$(Configuration),NativeBinDir:$(NativeBinDir),ProductVersion:$(ProductVersion),MonoWasmThreads:$(MonoWasmThreads),WasmEnableSIMD:$(WasmEnableSIMD),WasmEnableExceptionHandling:$(WasmEnableExceptionHandling),DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop),MonoDiagnosticsMock:$(MonoDiagnosticsMock),ContinuousIntegrationBuild:$(ContinuousIntegrationBuild) + @(_MonoRollupEnvironmentVariable, ',') From 4499bc1ada9b47532b76ee8780c5cb9197c7db78 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 25 Jul 2023 16:03:08 +0200 Subject: [PATCH 8/9] simd and eh flags after relink --- src/mono/wasm/build/WasmApp.Native.targets | 4 ++++ src/mono/wasm/runtime/es6/dotnet.es6.lib.js | 4 ++++ src/mono/wasm/runtime/globals.ts | 4 ++++ src/mono/wasm/runtime/loader/globals.ts | 6 ++++++ src/mono/wasm/runtime/loader/polyfills.ts | 15 +-------------- src/mono/wasm/runtime/loader/run.ts | 9 ++++----- src/mono/wasm/runtime/rollup.config.js | 4 ++-- src/mono/wasm/runtime/startup.ts | 10 ++++++++-- src/mono/wasm/runtime/types/internal.ts | 6 ++++++ src/mono/wasm/wasm.proj | 18 ++++++++++++------ 10 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 34736613dd8f6a..2c306dbb70e947 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -275,6 +275,10 @@ + + + + diff --git a/src/mono/wasm/runtime/es6/dotnet.es6.lib.js b/src/mono/wasm/runtime/es6/dotnet.es6.lib.js index 8ea0b7deb2f891..dad64ed0713b2d 100644 --- a/src/mono/wasm/runtime/es6/dotnet.es6.lib.js +++ b/src/mono/wasm/runtime/es6/dotnet.es6.lib.js @@ -7,6 +7,8 @@ // because we can't pass custom define symbols to acorn optimizer, we use environment variables to pass other build options const DISABLE_LEGACY_JS_INTEROP = process.env.DISABLE_LEGACY_JS_INTEROP === "1"; +const WASM_ENABLE_SIMD = process.env.WASM_ENABLE_SIMD === "1"; +const WASM_ENABLE_EH = process.env.WASM_ENABLE_EH === "1"; const ENABLE_BROWSER_PROFILER = process.env.ENABLE_BROWSER_PROFILER === "1"; const ENABLE_AOT_PROFILER = process.env.ENABLE_AOT_PROFILER === "1"; @@ -62,6 +64,8 @@ function setup(linkerSetup) { const postset = ` DOTNET.setup({ `+ `linkerDisableLegacyJsInterop: ${DISABLE_LEGACY_JS_INTEROP ? "true" : "false"},` + + `linkerWasmEnableSIMD: ${WASM_ENABLE_SIMD ? "true" : "false"},` + + `linkerWasmEnableEH: ${WASM_ENABLE_EH ? "true" : "false"},` + `linkerEnableAotProfiler: ${ENABLE_AOT_PROFILER ? "true" : "false"}, ` + `linkerEnableBrowserProfiler: ${ENABLE_BROWSER_PROFILER ? "true" : "false"}` + `}); diff --git a/src/mono/wasm/runtime/globals.ts b/src/mono/wasm/runtime/globals.ts index d42ba56bf8a79d..9ca3d5d3a54b42 100644 --- a/src/mono/wasm/runtime/globals.ts +++ b/src/mono/wasm/runtime/globals.ts @@ -24,6 +24,8 @@ export let runtimeHelpers: RuntimeHelpers = null as any; export let loaderHelpers: LoaderHelpers = null as any; // this is when we link with workload tools. The consts:wasmEnableLegacyJsInterop is when we compile with rollup. export let linkerDisableLegacyJsInterop = false; +export let linkerWasmEnableSIMD = true; +export let linkerWasmEnableEH = true; export let linkerEnableAotProfiler = false; export let linkerEnableBrowserProfiler = false; export let _runtimeModuleLoaded = false; // please keep it in place also as rollup guard @@ -31,6 +33,8 @@ export let _runtimeModuleLoaded = false; // please keep it in place also as roll export function passEmscriptenInternals(internals: EmscriptenInternals): void { ENVIRONMENT_IS_PTHREAD = internals.isPThread; linkerDisableLegacyJsInterop = internals.linkerDisableLegacyJsInterop; + linkerWasmEnableSIMD = internals.linkerWasmEnableSIMD; + linkerWasmEnableEH = internals.linkerWasmEnableEH; linkerEnableAotProfiler = internals.linkerEnableAotProfiler; linkerEnableBrowserProfiler = internals.linkerEnableBrowserProfiler; runtimeHelpers.quit = internals.quit_; diff --git a/src/mono/wasm/runtime/loader/globals.ts b/src/mono/wasm/runtime/loader/globals.ts index 7fac0d5ac7e852..5f4e833faa512d 100644 --- a/src/mono/wasm/runtime/loader/globals.ts +++ b/src/mono/wasm/runtime/loader/globals.ts @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +import { exceptions, simd } from "wasm-feature-detect"; + import type { AssetEntryInternal, GlobalObjects, LoaderHelpers, RuntimeHelpers } from "../types/internal"; import type { MonoConfig, RuntimeAPI } from "../types"; import { assert_runtime_running, is_exited, is_runtime_running, mono_exit } from "./exit"; @@ -94,6 +96,10 @@ export function setLoaderGlobals( hasDebuggingEnabled, invokeLibraryInitializers, + // from wasm-feature-detect npm package + exceptions, + simd, + } as Partial); } diff --git a/src/mono/wasm/runtime/loader/polyfills.ts b/src/mono/wasm/runtime/loader/polyfills.ts index e54f9d05351b70..bf30a526601cd2 100644 --- a/src/mono/wasm/runtime/loader/polyfills.ts +++ b/src/mono/wasm/runtime/loader/polyfills.ts @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import { exceptions, simd } from "wasm-feature-detect"; - import MonoWasmThreads from "consts:monoWasmThreads"; -import WasmEnableSIMD from "consts:wasmEnableSIMD"; -import WasmEnableExceptionHandling from "consts:wasmEnableExceptionHandling"; import type { DotnetModuleInternal } from "../types/internal"; import { INTERNAL, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, loaderHelpers, ENVIRONMENT_IS_WEB, mono_assert } from "./globals"; @@ -32,7 +28,7 @@ export function verifyEnvironment() { } } -export async function verifyEnvironmentAsync() { +export async function detect_features_and_polyfill(module: DotnetModuleInternal): Promise { if (ENVIRONMENT_IS_NODE) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: @@ -42,15 +38,6 @@ export async function verifyEnvironmentAsync() { throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}', please use at least ${minNodeVersion}. See also https://aka.ms/dotnet-wasm-features`); } } - if (WasmEnableSIMD) { - mono_assert(await simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); - } - if (WasmEnableExceptionHandling) { - mono_assert(await exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); - } -} - -export async function detect_features_and_polyfill(module: DotnetModuleInternal): Promise { const scriptUrlQuery =/* webpackIgnore: true */import.meta.url; const queryIndex = scriptUrlQuery.indexOf("?"); diff --git a/src/mono/wasm/runtime/loader/run.ts b/src/mono/wasm/runtime/loader/run.ts index d486e4ddce31a9..1709c99571535d 100644 --- a/src/mono/wasm/runtime/loader/run.ts +++ b/src/mono/wasm/runtime/loader/run.ts @@ -11,7 +11,7 @@ import { deep_merge_config, deep_merge_module, mono_wasm_load_config } from "./c import { mono_exit } from "./exit"; import { setup_proxy_console, mono_log_info } from "./logging"; import { resolve_asset_path, start_asset_download } from "./assets"; -import { detect_features_and_polyfill, verifyEnvironmentAsync } from "./polyfills"; +import { detect_features_and_polyfill } from "./polyfills"; import { runtimeHelpers, loaderHelpers } from "./globals"; import { init_globalization } from "./icu"; import { setupPreloadChannelToMainThread } from "./worker"; @@ -363,7 +363,6 @@ export class HostBuilder implements DotnetHostBuilder { if (ENVIRONMENT_IS_WEB && (module.config! as MonoConfigInternal).forwardConsoleLogsToWS && typeof globalThis.WebSocket != "undefined") { setup_proxy_console("main", globalThis.console, globalThis.location.origin); } - await verifyEnvironmentAsync(); mono_assert(module, "Null moduleConfig"); mono_assert(module.config, "Null moduleConfig.config"); await createEmscripten(module); @@ -445,7 +444,7 @@ function importModules() { ]; } -function initializeModules(es6Modules: [RuntimeModuleExportsInternal, NativeModuleExportsInternal]) { +async function initializeModules(es6Modules: [RuntimeModuleExportsInternal, NativeModuleExportsInternal]) { const { initializeExports, initializeReplacements, configureEmscriptenStartup, configureWorkerStartup, setRuntimeGlobals, passEmscriptenInternals } = es6Modules[0]; const { default: emscriptenFactory } = es6Modules[1]; setRuntimeGlobals(globalObjectsRoot); @@ -484,7 +483,7 @@ async function createEmscriptenMain(): Promise { // TODO call mono_download_assets(); here in parallel ? const es6Modules = await Promise.all(promises); - initializeModules(es6Modules as any); + await initializeModules(es6Modules as any); await runtimeHelpers.dotnetReady.promise; @@ -500,7 +499,7 @@ async function createEmscriptenWorker(): Promise { const promises = importModules(); const es6Modules = await Promise.all(promises); - initializeModules(es6Modules as any); + await initializeModules(es6Modules as any); return module; } diff --git a/src/mono/wasm/runtime/rollup.config.js b/src/mono/wasm/runtime/rollup.config.js index add313dc53c5ae..d6c8ce04a1a64d 100644 --- a/src/mono/wasm/runtime/rollup.config.js +++ b/src/mono/wasm/runtime/rollup.config.js @@ -19,8 +19,8 @@ const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === const productVersion = process.env.ProductVersion || "8.0.0-dev"; const nativeBinDir = process.env.NativeBinDir ? process.env.NativeBinDir.replace(/"/g, "") : "bin"; const monoWasmThreads = process.env.MonoWasmThreads === "true" ? true : false; -const wasmEnableSIMD = process.env.WasmEnableSIMD === "true" ? true : false; -const wasmEnableExceptionHandling = process.env.WasmEnableExceptionHandling === "true" ? true : false; +const wasmEnableSIMD = process.env.WASM_ENABLE_SIMD === "true" ? true : false; +const wasmEnableExceptionHandling = process.env.WASM_ENABLE_EH === "true" ? true : false; const wasmEnableLegacyJsInterop = process.env.DISABLE_LEGACY_JS_INTEROP !== "1" ? true : false; const monoDiagnosticsMock = process.env.MonoDiagnosticsMock === "true" ? true : false; const terserConfig = { diff --git a/src/mono/wasm/runtime/startup.ts b/src/mono/wasm/runtime/startup.ts index 46f7ac4b8521ac..12e83419c7b7a5 100644 --- a/src/mono/wasm/runtime/startup.ts +++ b/src/mono/wasm/runtime/startup.ts @@ -5,7 +5,7 @@ import MonoWasmThreads from "consts:monoWasmThreads"; import WasmEnableLegacyJsInterop from "consts:wasmEnableLegacyJsInterop"; import { DotnetModuleInternal, CharPtrNull } from "./types/internal"; -import { linkerDisableLegacyJsInterop, ENVIRONMENT_IS_PTHREAD, exportedRuntimeAPI, INTERNAL, loaderHelpers, Module, runtimeHelpers, createPromiseController, mono_assert } from "./globals"; +import { linkerDisableLegacyJsInterop, ENVIRONMENT_IS_PTHREAD, exportedRuntimeAPI, INTERNAL, loaderHelpers, Module, runtimeHelpers, createPromiseController, mono_assert, linkerWasmEnableSIMD, linkerWasmEnableEH } from "./globals"; import cwraps, { init_c_exports } from "./cwraps"; import { mono_wasm_raise_debug_event, mono_wasm_runtime_ready } from "./debug"; import { toBase64StringImpl } from "./base64"; @@ -165,7 +165,6 @@ function preInit(userPreInit: (() => void)[]) { (async () => { try { // - init the rest of the polyfills - // - download Module.config from configSrc await mono_wasm_pre_init_essential_async(); // - start download assets like DLLs @@ -364,6 +363,13 @@ async function mono_wasm_pre_init_essential_async(): Promise { mono_log_debug("mono_wasm_pre_init_essential_async"); Module.addRunDependency("mono_wasm_pre_init_essential_async"); + if (linkerWasmEnableSIMD) { + mono_assert(await loaderHelpers.simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); + } + if (linkerWasmEnableEH) { + mono_assert(await loaderHelpers.exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); + } + await init_polyfills_async(); if (MonoWasmThreads) { diff --git a/src/mono/wasm/runtime/types/internal.ts b/src/mono/wasm/runtime/types/internal.ts index bc91e975c439ae..3b54d6b1eb6f14 100644 --- a/src/mono/wasm/runtime/types/internal.ts +++ b/src/mono/wasm/runtime/types/internal.ts @@ -150,6 +150,10 @@ export type LoaderHelpers = { isChromium: boolean, isFirefox: boolean + + // from wasm-feature-detect npm package + exceptions: () => Promise, + simd: () => Promise, } export type RuntimeHelpers = { config: MonoConfigInternal; @@ -266,6 +270,8 @@ export function is_nullish(value: T | null | undefined): value is null | unde export type EmscriptenInternals = { isPThread: boolean, linkerDisableLegacyJsInterop: boolean, + linkerWasmEnableSIMD: boolean, + linkerWasmEnableEH: boolean, linkerEnableAotProfiler: boolean, linkerEnableBrowserProfiler: boolean, quit_: Function, diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 409c31dd0072e0..609be27d03d389 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -400,9 +400,15 @@ cmake --build . --config $(Configuration) $(CmakeOptions) call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && $(CMakeBuildRuntimeCmd) bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && $(CMakeBuildRuntimeCmd)' - <_DisableLegacyJsInterop Condition="'$(WasmEnableLegacyJsInterop)' == 'false'">1 - <_DisableLegacyJsInterop Condition="'$(WasmEnableLegacyJsInterop)' != 'false'">0 + + <_CmakeEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP=1" Condition="'$(WasmEnableLegacyJsInterop)' == 'false'"/> + <_CmakeEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP=0" Condition="'$(WasmEnableLegacyJsInterop)' != 'false'"/> + <_CmakeEnvironmentVariable Include="WASM_ENABLE_SIMD=1" Condition="'$(WasmEnableSIMD)' != 'false'" /> + <_CmakeEnvironmentVariable Include="WASM_ENABLE_SIMD=0" Condition="'$(WasmEnableSIMD)' == 'false'" /> + <_CmakeEnvironmentVariable Include="WASM_ENABLE_EH=1" Condition="'$(WasmEnableExceptionHandling)' != 'false'" /> + <_CmakeEnvironmentVariable Include="WASM_ENABLE_EH=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" /> + + EnvironmentVariables="@(_CmakeEnvironmentVariable)" /> + EnvironmentVariables="@(_CmakeEnvironmentVariable)" /> @@ -522,8 +528,8 @@ <_MonoRollupEnvironmentVariable Include="NativeBinDir:$(NativeBinDir)" /> <_MonoRollupEnvironmentVariable Include="ProductVersion:$(ProductVersion)" /> <_MonoRollupEnvironmentVariable Include="MonoWasmThreads:$(MonoWasmThreads)" /> - <_MonoRollupEnvironmentVariable Include="WasmEnableSIMD:$(WasmEnableSIMD)" /> - <_MonoRollupEnvironmentVariable Include="WasmEnableExceptionHandling:$(WasmEnableExceptionHandling)" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:$(WasmEnableSIMD)" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:$(WasmEnableExceptionHandling)" /> <_MonoRollupEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop)" /> <_MonoRollupEnvironmentVariable Include="MonoDiagnosticsMock:$(MonoDiagnosticsMock)" /> <_MonoRollupEnvironmentVariable Include="ContinuousIntegrationBuild:$(ContinuousIntegrationBuild)" /> From e66791c7f87715eb9b29fac548b3a5d164b17d86 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 25 Jul 2023 18:12:46 +0200 Subject: [PATCH 9/9] fix --- src/mono/wasm/runtime/rollup.config.js | 4 ++-- src/mono/wasm/wasm.proj | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/runtime/rollup.config.js b/src/mono/wasm/runtime/rollup.config.js index d6c8ce04a1a64d..94333d60f55a63 100644 --- a/src/mono/wasm/runtime/rollup.config.js +++ b/src/mono/wasm/runtime/rollup.config.js @@ -19,8 +19,8 @@ const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === const productVersion = process.env.ProductVersion || "8.0.0-dev"; const nativeBinDir = process.env.NativeBinDir ? process.env.NativeBinDir.replace(/"/g, "") : "bin"; const monoWasmThreads = process.env.MonoWasmThreads === "true" ? true : false; -const wasmEnableSIMD = process.env.WASM_ENABLE_SIMD === "true" ? true : false; -const wasmEnableExceptionHandling = process.env.WASM_ENABLE_EH === "true" ? true : false; +const wasmEnableSIMD = process.env.WASM_ENABLE_SIMD === "1" ? true : false; +const wasmEnableExceptionHandling = process.env.WASM_ENABLE_EH === "1" ? true : false; const wasmEnableLegacyJsInterop = process.env.DISABLE_LEGACY_JS_INTEROP !== "1" ? true : false; const monoDiagnosticsMock = process.env.MonoDiagnosticsMock === "true" ? true : false; const terserConfig = { diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 609be27d03d389..14d502155c3c55 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -528,9 +528,12 @@ <_MonoRollupEnvironmentVariable Include="NativeBinDir:$(NativeBinDir)" /> <_MonoRollupEnvironmentVariable Include="ProductVersion:$(ProductVersion)" /> <_MonoRollupEnvironmentVariable Include="MonoWasmThreads:$(MonoWasmThreads)" /> - <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:$(WasmEnableSIMD)" /> - <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:$(WasmEnableExceptionHandling)" /> - <_MonoRollupEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP:$(_DisableLegacyJsInterop)" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:1" Condition="'$(WasmEnableSIMD)' != 'false'" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:0" Condition="'$(WasmEnableSIMD)' == 'false'" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:1" Condition="'$(WasmEnableExceptionHandling)' != 'false'" /> + <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" /> + <_MonoRollupEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP:1" Condition="'$(WasmEnableLegacyJsInterop)' == 'false'" /> + <_MonoRollupEnvironmentVariable Include="DISABLE_LEGACY_JS_INTEROP:0" Condition="'$(WasmEnableLegacyJsInterop)' != 'false'" /> <_MonoRollupEnvironmentVariable Include="MonoDiagnosticsMock:$(MonoDiagnosticsMock)" /> <_MonoRollupEnvironmentVariable Include="ContinuousIntegrationBuild:$(ContinuousIntegrationBuild)" />