pyodide/emsdk/patches/dynCall_so.patch

35 lines
1.3 KiB
Diff

--- a/emsdk/fastcomp/emscripten/src/support.js
+++ b/emsdk/fastcomp/emscripten/src/support.js
@@ -338,6 +338,11 @@ function relocateExports(exports, memoryBase, tableBase, moduleLocal) {
}
#endif
}
+ if (e.startsWith("dynCall_")) {
+ if (!Module.hasOwnProperty(e)) {
+ Module[e] = value;
+ }
+ }
relocated[e] = value;
if (moduleLocal) {
#if WASM_BACKEND
@@ -510,7 +515,18 @@ function loadWebAssemblyModule(binary, flags) {
// 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() {