From 06eb6de18eb1a7026ac7917a6f3fdc7300a23bf8 Mon Sep 17 00:00:00 2001 From: Thorsten Beier Date: Wed, 31 Jul 2024 07:09:11 +0200 Subject: [PATCH] Revert "Update emscripten (#1241)" (#1248) This reverts commit 58d834b717c05cc6f9eba0beafd245d1c3f8d8f8. --- ...Object-and-fs.readFile-in-loadLibDat.patch | 10 +-- ...-error-when-symbol-resolution-fails.patch} | 16 ++-- .../patches/0003-Changes-for-JSPI.patch | 87 ------------------- ...s-github.com-emscripten-core-emscrip.patch | 28 ------ ...0005-Raise-when-no-argument-is-given.patch | 31 ------- .../0006-Load-dependent-libs-globally.patch | 35 -------- .../emscripten_emscripten-wasm32/recipe.yaml | 4 +- 7 files changed, 15 insertions(+), 196 deletions(-) rename recipes/recipes/emscripten_emscripten-wasm32/patches/{0002-Add-useful-error-when-symbol-resolution-fails.patch => 0001-Add-useful-error-when-symbol-resolution-fails.patch} (71%) delete mode 100644 recipes/recipes/emscripten_emscripten-wasm32/patches/0003-Changes-for-JSPI.patch delete mode 100644 recipes/recipes/emscripten_emscripten-wasm32/patches/0004-Upstream-PR-https-github.com-emscripten-core-emscrip.patch delete mode 100644 recipes/recipes/emscripten_emscripten-wasm32/patches/0005-Raise-when-no-argument-is-given.patch delete mode 100644 recipes/recipes/emscripten_emscripten-wasm32/patches/0006-Load-dependent-libs-globally.patch diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-back-fs.findObject-and-fs.readFile-in-loadLibDat.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-back-fs.findObject-and-fs.readFile-in-loadLibDat.patch index 179450c27..5212949cd 100644 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-back-fs.findObject-and-fs.readFile-in-loadLibDat.patch +++ b/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-back-fs.findObject-and-fs.readFile-in-loadLibDat.patch @@ -1,7 +1,7 @@ -From 137dae4dbdf9a192551582cdae827b085510956f Mon Sep 17 00:00:00 2001 +From 0170462a78e86de9ee95017bfa7e4a3dd620a375 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 2 Jun 2023 11:59:32 -0700 -Subject: [PATCH 1/6] Add back fs.findObject and fs.readFile in loadLibData +Subject: [PATCH] Add back fs.findObject and fs.readFile in loadLibData See upstream PR: https://github.com/emscripten-core/emscripten/pull/19513 @@ -10,10 +10,10 @@ https://github.com/emscripten-core/emscripten/pull/19513 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/library_dylink.js b/src/library_dylink.js -index aa90bea2b..1e67818a1 100644 +index d7676cdc2..f616d230d 100644 --- a/src/library_dylink.js +++ b/src/library_dylink.js -@@ -994,14 +994,23 @@ var LibraryDylink = { +@@ -993,14 +993,23 @@ var LibraryDylink = { #endif // for wasm, we can use fetch for async, but for fs mode we can only imitate it @@ -40,5 +40,5 @@ index aa90bea2b..1e67818a1 100644 var libFile = locateFile(libName); if (flags.loadAsync) { -- -2.34.1 +2.25.1 diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0002-Add-useful-error-when-symbol-resolution-fails.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-useful-error-when-symbol-resolution-fails.patch similarity index 71% rename from recipes/recipes/emscripten_emscripten-wasm32/patches/0002-Add-useful-error-when-symbol-resolution-fails.patch rename to recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-useful-error-when-symbol-resolution-fails.patch index 2f49f6001..ec50727a1 100644 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0002-Add-useful-error-when-symbol-resolution-fails.patch +++ b/recipes/recipes/emscripten_emscripten-wasm32/patches/0001-Add-useful-error-when-symbol-resolution-fails.patch @@ -1,7 +1,7 @@ -From e0cb884277200310eba263dcce5a7b1c4567bae6 Mon Sep 17 00:00:00 2001 +From a8bdb50a29062ee70c8667e4fd94dde47917f8fa Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 19 May 2023 12:19:00 -0700 -Subject: [PATCH 2/6] Add useful error when symbol resolution fails +Subject: [PATCH] Add useful error when symbol resolution fails Currently if symbol resolution fails, we get: ```js @@ -19,19 +19,19 @@ symbol. 1 file changed, 3 insertions(+) diff --git a/src/library_dylink.js b/src/library_dylink.js -index 1e67818a1..cea3ce05d 100644 +index d96e6b425..7f63b5c5e 100644 --- a/src/library_dylink.js +++ b/src/library_dylink.js -@@ -709,6 +709,9 @@ var LibraryDylink = { +@@ -727,6 +727,9 @@ var LibraryDylink = { var resolved; - stubs[prop] = (...args) => { - resolved ||= resolveSymbol(prop); + stubs[prop] = function() { + if (!resolved) resolved = resolveSymbol(prop); + if (!resolved) { + throw new Error(`Dynamic linking error: cannot resolve symbol ${prop}`); + } - return resolved(...args); + return resolved.apply(null, arguments); }; } -- -2.34.1 +2.25.1 diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0003-Changes-for-JSPI.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0003-Changes-for-JSPI.patch deleted file mode 100644 index 42f189b2b..000000000 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0003-Changes-for-JSPI.patch +++ /dev/null @@ -1,87 +0,0 @@ -From d4d5d35072b6d28c5f98b77a0d578e01bd25ef7e Mon Sep 17 00:00:00 2001 -From: Hood Chatham -Date: Thu, 22 Jun 2023 18:53:22 -0700 -Subject: [PATCH 3/6] Changes for JSPI - ---- - src/library.js | 2 +- - src/library_dylink.js | 3 ++- - src/parseTools.mjs | 2 +- - src/preamble.js | 7 +++++++ - 4 files changed, 11 insertions(+), 3 deletions(-) - -diff --git a/src/library.js b/src/library.js -index 44531ee1d..f02e85ea2 100644 ---- a/src/library.js -+++ b/src/library.js -@@ -1269,7 +1269,7 @@ addToLibrary({ - #if EXCEPTION_STACK_TRACES - throw new EmscriptenSjLj; - #else -- throw Infinity; -+ throw Module.wrapException(Infinity); - #endif - }, - #elif !SUPPORT_LONGJMP -diff --git a/src/library_dylink.js b/src/library_dylink.js -index cea3ce05d..c3f3c2bbf 100644 ---- a/src/library_dylink.js -+++ b/src/library_dylink.js -@@ -73,6 +73,7 @@ var LibraryDylink = { - #if !DISABLE_EXCEPTION_CATCHING || SUPPORT_LONGJMP == 'emscripten' - $createInvokeFunction__internal: true, - $createInvokeFunction__deps: ['$dynCall', 'setThrew', '$stackSave', '$stackRestore'], -+ $createInvokeFunction__postset: "if(!Module.createInvoke) { Module.createInvoke = Module.createInvokeFunction; }", - $createInvokeFunction: (sig) => { - return function() { - var sp = stackSave(); -@@ -125,7 +126,7 @@ var LibraryDylink = { - // Asm.js-style exception handling: invoke wrapper generation - else if (symName.startsWith('invoke_')) { - // Create (and cache) new invoke_ functions on demand. -- sym = wasmImports[symName] = createInvokeFunction(symName.split('_')[1]); -+ sym = wasmImports[symName] = Module.createInvoke(symName.split('_')[1]); - } - #endif - #if !DISABLE_EXCEPTION_CATCHING -diff --git a/src/parseTools.mjs b/src/parseTools.mjs -index 7f20321c3..118a32078 100644 ---- a/src/parseTools.mjs -+++ b/src/parseTools.mjs -@@ -581,7 +581,7 @@ function makeThrow(excPtr) { - } - return `assert(false, '${assertInfo}');`; - } -- return `throw ${excPtr};`; -+ return `throw Module.wrapException(${excPtr});`; - } - - function storeException(varName, excPtr) { -diff --git a/src/preamble.js b/src/preamble.js -index 18cf93959..57a7245ab 100644 ---- a/src/preamble.js -+++ b/src/preamble.js -@@ -18,6 +18,10 @@ - #include "runtime_pthread.js" - #endif - -+if(!Module.wrapException) { -+ Module.wrapException = (e) => e; -+} -+ - #if RELOCATABLE - {{{ makeModuleReceiveWithVar('dynamicLibraries', undefined, '[]', true) }}} - #endif -@@ -942,6 +946,9 @@ function getWasmImports() { - // Receives the wasm imports, returns the exports. - function createWasm() { - var info = getWasmImports(); -+ if (Module.adjustWasmImports) { -+ Module.adjustWasmImports(info); -+ } - // Load the wasm module and create an instance of using native support in the JS engine. - // handle a generated wasm instance, receiving its exports and - // performing other necessary setup --- -2.34.1 - diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0004-Upstream-PR-https-github.com-emscripten-core-emscrip.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0004-Upstream-PR-https-github.com-emscripten-core-emscrip.patch deleted file mode 100644 index 294ded3f2..000000000 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0004-Upstream-PR-https-github.com-emscripten-core-emscrip.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 9352fac9a4618603fbe5ce7ad97a26a3963704bd Mon Sep 17 00:00:00 2001 -From: Joe Marshall -Date: Sat, 13 Apr 2024 21:41:11 +0100 -Subject: [PATCH 4/6] Upstream PR: - https://github.com/emscripten-core/emscripten/pull/21759 - ---- - src/library_dylink.js | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/library_dylink.js b/src/library_dylink.js -index c3f3c2bbf..e0fa4721c 100644 ---- a/src/library_dylink.js -+++ b/src/library_dylink.js -@@ -93,6 +93,10 @@ var LibraryDylink = { - if (e !== e+0) throw e; - #endif - _setThrew(1, 0); -+ // In theory this if could be done on creating the function, -+ // but I just added this to save wasting code space -+ // and it only happens on an exception -+ if (sig[0] == "j") return 0n; - } - } - }, --- -2.34.1 - diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0005-Raise-when-no-argument-is-given.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0005-Raise-when-no-argument-is-given.patch deleted file mode 100644 index 10963138e..000000000 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0005-Raise-when-no-argument-is-given.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 44983793a7f67009c228c5c95899f6fe735fd1c5 Mon Sep 17 00:00:00 2001 -From: ryanking13 -Date: Sat, 20 Jan 2024 19:02:32 +0900 -Subject: [PATCH 5/6] Raise when no argument is given - -Emscripten 3.1.51 does not raise an error when no argument is given. -Some build tools (e.g. ffmpeg) relies on this behavior, so we should -keep it. - -Upstream issue: https://github.com/emscripten-core/emscripten/issues/21116 ---- - emcc.py | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/emcc.py b/emcc.py -index 6be37b217..a77f41c4a 100644 ---- a/emcc.py -+++ b/emcc.py -@@ -628,6 +628,9 @@ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR P - print(libname) - return 0 - -+ if not input_files and not state.link_flags: -+ exit_with_error('no input files') -+ - if options.reproduce: - create_reproduce_file(options.reproduce, args) - --- -2.34.1 - diff --git a/recipes/recipes/emscripten_emscripten-wasm32/patches/0006-Load-dependent-libs-globally.patch b/recipes/recipes/emscripten_emscripten-wasm32/patches/0006-Load-dependent-libs-globally.patch deleted file mode 100644 index 0dba49e96..000000000 --- a/recipes/recipes/emscripten_emscripten-wasm32/patches/0006-Load-dependent-libs-globally.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 2f3ae3b30cf8ce8cd04d512ebb4c8b2218563085 Mon Sep 17 00:00:00 2001 -From: Hood Chatham -Date: Mon, 17 Jun 2024 18:32:07 -0700 -Subject: [PATCH 6/6] Load dependent libs globally - -I'm not 100% sure why, but we need all dependent shared libs to be loaded -globally. ---- - src/library_dylink.js | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/library_dylink.js b/src/library_dylink.js -index e0fa4721c..502bc7b25 100644 ---- a/src/library_dylink.js -+++ b/src/library_dylink.js -@@ -880,11 +880,15 @@ var LibraryDylink = { - - // now load needed libraries and the module itself. - if (flags.loadAsync) { -+ const origGlobal = flags.global; -+ flags.global = true; - return metadata.neededDynlibs - .reduce((chain, dynNeeded) => chain.then(() => - loadDynamicLibrary(dynNeeded, flags) - ), Promise.resolve()) -- .then(loadModule); -+ .then(() => { -+ flags.global = origGlobal; -+ }).then(loadModule); - } - - metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope)); --- -2.34.1 - diff --git a/recipes/recipes/emscripten_emscripten-wasm32/recipe.yaml b/recipes/recipes/emscripten_emscripten-wasm32/recipe.yaml index e374aa086..f826caabc 100644 --- a/recipes/recipes/emscripten_emscripten-wasm32/recipe.yaml +++ b/recipes/recipes/emscripten_emscripten-wasm32/recipe.yaml @@ -1,9 +1,9 @@ context: name: emscripten_emscripten-wasm32 - version: 3.1.58 + version: 3.1.45 build: - number: 0 + number: 29 outputs: - package: