forked from emscripten-forge/recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update emscripten (emscripten-forge#1241)
* 3.1.58 * remove outdated patch
- Loading branch information
1 parent
af2f393
commit 58d834b
Showing
7 changed files
with
196 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
From 0170462a78e86de9ee95017bfa7e4a3dd620a375 Mon Sep 17 00:00:00 2001 | ||
From 137dae4dbdf9a192551582cdae827b085510956f Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <[email protected]> | ||
Date: Fri, 2 Jun 2023 11:59:32 -0700 | ||
Subject: [PATCH] Add back fs.findObject and fs.readFile in loadLibData | ||
Subject: [PATCH 1/6] 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 d7676cdc2..f616d230d 100644 | ||
index aa90bea2b..1e67818a1 100644 | ||
--- a/src/library_dylink.js | ||
+++ b/src/library_dylink.js | ||
@@ -993,14 +993,23 @@ var LibraryDylink = { | ||
@@ -994,14 +994,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 d7676cdc2..f616d230d 100644 | |
var libFile = locateFile(libName); | ||
if (flags.loadAsync) { | ||
-- | ||
2.25.1 | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
From a8bdb50a29062ee70c8667e4fd94dde47917f8fa Mon Sep 17 00:00:00 2001 | ||
From e0cb884277200310eba263dcce5a7b1c4567bae6 Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <[email protected]> | ||
Date: Fri, 19 May 2023 12:19:00 -0700 | ||
Subject: [PATCH] Add useful error when symbol resolution fails | ||
Subject: [PATCH 2/6] 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 d96e6b425..7f63b5c5e 100644 | ||
index 1e67818a1..cea3ce05d 100644 | ||
--- a/src/library_dylink.js | ||
+++ b/src/library_dylink.js | ||
@@ -727,6 +727,9 @@ var LibraryDylink = { | ||
@@ -709,6 +709,9 @@ var LibraryDylink = { | ||
var resolved; | ||
stubs[prop] = function() { | ||
if (!resolved) resolved = resolveSymbol(prop); | ||
stubs[prop] = (...args) => { | ||
resolved ||= resolveSymbol(prop); | ||
+ if (!resolved) { | ||
+ throw new Error(`Dynamic linking error: cannot resolve symbol ${prop}`); | ||
+ } | ||
return resolved.apply(null, arguments); | ||
return resolved(...args); | ||
}; | ||
} | ||
-- | ||
2.25.1 | ||
2.34.1 | ||
|
87 changes: 87 additions & 0 deletions
87
recipes/recipes/emscripten_emscripten-wasm32/patches/0003-Changes-for-JSPI.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
From d4d5d35072b6d28c5f98b77a0d578e01bd25ef7e Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <[email protected]> | ||
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 | ||
|
28 changes: 28 additions & 0 deletions
28
...emscripten-wasm32/patches/0004-Upstream-PR-https-jackfan.us.kg-emscripten-core-emscrip.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From 9352fac9a4618603fbe5ce7ad97a26a3963704bd Mon Sep 17 00:00:00 2001 | ||
From: Joe Marshall <[email protected]> | ||
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 | ||
|
31 changes: 31 additions & 0 deletions
31
...s/recipes/emscripten_emscripten-wasm32/patches/0005-Raise-when-no-argument-is-given.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
From 44983793a7f67009c228c5c95899f6fe735fd1c5 Mon Sep 17 00:00:00 2001 | ||
From: ryanking13 <[email protected]> | ||
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 | ||
|
35 changes: 35 additions & 0 deletions
35
recipes/recipes/emscripten_emscripten-wasm32/patches/0006-Load-dependent-libs-globally.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 2f3ae3b30cf8ce8cd04d512ebb4c8b2218563085 Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <[email protected]> | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters