pyodide/emsdk/patches/dynCall_so.patch

37 lines
1.3 KiB
Diff

diff --git a/emsdk/fastcomp/emscripten/src/support.js b/emsdk/fastcomp/emscripten/src/support.js
index 8e1df8e82..4d07d6bef 100644
--- a/emsdk/fastcomp/emscripten/src/support.js
+++ b/emsdk/fastcomp/emscripten/src/support.js
@@ -471,7 +471,18 @@
// present in the dynamic library but not in the main JS,
// and the dynamic library cannot provide JS for it. Use
// the generic "X" invoke for it.
- return obj[prop] = invoke_X;
+ var dynCallName = 'dynCall_' + prop.slice(7);
+ return obj[prop] = function() {
+ var sp = stackSave();
+ try {
+ var args = Array.prototype.slice.call(arguments);
+ return Module[dynCallName].apply(null, args);
+ } catch(e) {
+ stackRestore(sp);
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ Module["setThrew"](1, 0);
+ }
+ }
}
// otherwise this is regular function import - call it indirectly
return obj[prop] = function() {
@@ -530,6 +541,11 @@
}
#endif
}
+ if (e.startsWith("dynCall_")) {
+ if (!Module.hasOwnProperty(e)) {
+ Module[e] = value;
+ }
+ }
exports[e] = value;
#if WASM_BACKEND
moduleLocal['_' + e] = value;