From 810a36b18bc2e167da719c18da27d3b87263c7a0 Mon Sep 17 00:00:00 2001 From: kvpanch <223931578+kvpanch@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:48:07 -0500 Subject: [PATCH] Update EMSDK to 5.0.0 (#479) Emscripten 4.0.12 introduced breaking change by changing module factory to always return promise even if `WASM_ASYNC_COMPILATION=0`. To overcome this, build emscripten compiler without MODULARIZE with custom export of `createRevive`. --- .cargo/config.toml | 4 ++-- .github/actions/get-emsdk/action.yml | 2 +- .github/workflows/release-llvm.yml | 4 ++++ CHANGELOG.md | 1 + crates/llvm-builder/src/utils.rs | 2 +- js/emscripten/embed/extern-post.js | 6 ++++++ js/emscripten/embed/extern-pre.js | 2 ++ js/emscripten/examples/node/revive.js | 2 +- js/emscripten/examples/web/worker.js | 2 +- 9 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 js/emscripten/embed/extern-post.js create mode 100644 js/emscripten/embed/extern-pre.js diff --git a/.cargo/config.toml b/.cargo/config.toml index 3bf5f97..fb2c62d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,9 +5,9 @@ rustflags = [ "-Clink-arg=-sEXIT_RUNTIME=1", "-Clink-arg=-sALLOW_MEMORY_GROWTH=1", "-Clink-arg=-sEXPORTED_RUNTIME_METHODS=FS,callMain,stringToNewUTF8", - "-Clink-arg=-sMODULARIZE=1", - "-Clink-arg=-sEXPORT_NAME=createRevive", "-Clink-arg=-sWASM_ASYNC_COMPILATION=0", + "-Clink-arg=--extern-pre-js=js/emscripten/embed/extern-pre.js", + "-Clink-arg=--extern-post-js=js/emscripten/embed/extern-post.js", "-Clink-arg=-sDYNAMIC_EXECUTION=0", "-Clink-arg=-sALLOW_TABLE_GROWTH=1", "-Clink-arg=--js-library=js/emscripten/embed/soljson_interface.js", diff --git a/.github/actions/get-emsdk/action.yml b/.github/actions/get-emsdk/action.yml index dcb8e3d..cc7b710 100644 --- a/.github/actions/get-emsdk/action.yml +++ b/.github/actions/get-emsdk/action.yml @@ -3,7 +3,7 @@ inputs: version: description: "" required: false - default: "4.0.9" + default: "5.0.0" runs: diff --git a/.github/workflows/release-llvm.yml b/.github/workflows/release-llvm.yml index 7ae680b..3a5b9d0 100644 --- a/.github/workflows/release-llvm.yml +++ b/.github/workflows/release-llvm.yml @@ -79,6 +79,10 @@ jobs: rustflags: "" cache-key: ${{ matrix.target }} + - name: Enable long paths (Windows) + if: runner.os == 'Windows' + run: git config --system core.longpaths true + - name: Install Dependencies if: ${{ matrix.host == 'linux' }} run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 622b50e..6776f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This is a development pre-release. - Updated `musl` to `1.2.5` - Updated `inkwell` to `0.8.0` - Updated `polkavm-*` to `0.31.0` +- Updated `EMSDK` to `5.0.0` ## v1.0.0 diff --git a/crates/llvm-builder/src/utils.rs b/crates/llvm-builder/src/utils.rs index fbd2b33..f9b9e5a 100644 --- a/crates/llvm-builder/src/utils.rs +++ b/crates/llvm-builder/src/utils.rs @@ -38,7 +38,7 @@ pub const MUSL_SNAPSHOTS_URL: &str = "https://git.musl-libc.org/cgit/musl/snapsh pub const EMSDK_SOURCE_URL: &str = "https://github.com/emscripten-core/emsdk.git"; /// The emscripten SDK version. -pub const EMSDK_VERSION: &str = "4.0.9"; +pub const EMSDK_VERSION: &str = "5.0.0"; /// The subprocess runner. /// diff --git a/js/emscripten/embed/extern-post.js b/js/emscripten/embed/extern-post.js new file mode 100644 index 0000000..7b48f34 --- /dev/null +++ b/js/emscripten/embed/extern-post.js @@ -0,0 +1,6 @@ +return Module; +} +if (typeof module === "object" && typeof module.exports === "object") { + module.exports = createRevive; +} else if (typeof define === "function" && define["amd"]) + define([], () => createRevive); diff --git a/js/emscripten/embed/extern-pre.js b/js/emscripten/embed/extern-pre.js new file mode 100644 index 0000000..e46e2b6 --- /dev/null +++ b/js/emscripten/embed/extern-pre.js @@ -0,0 +1,2 @@ +function createRevive(moduleArg) { +var Module = moduleArg || {}; diff --git a/js/emscripten/examples/node/revive.js b/js/emscripten/examples/node/revive.js index 8fe1173..83f96ea 100644 --- a/js/emscripten/examples/node/revive.js +++ b/js/emscripten/examples/node/revive.js @@ -1,7 +1,7 @@ const soljson = require("solc/soljson"); const createRevive = require("./resolc.js"); -async function compile(standardJsonInput) { +function compile(standardJsonInput) { if (!standardJsonInput) { throw new Error("Input JSON for the Solidity compiler is required."); } diff --git a/js/emscripten/examples/web/worker.js b/js/emscripten/examples/web/worker.js index aa39b58..9fe888e 100644 --- a/js/emscripten/examples/web/worker.js +++ b/js/emscripten/examples/web/worker.js @@ -1,7 +1,7 @@ importScripts("./resolc_web.js"); // Handle messages from the main thread -onmessage = async function (e) { +onmessage = function (e) { const m = createRevive(); // Set input data for stdin