emscripten-core / emscripten-core/emscripten
JSPI and dynamic linking messed up by stub trampoline
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
The dynamic linking code will generate a stub if it's not resolved when first imported:
```js
// Return a stub function that will resolve the symbol
// when first called.
if (!(prop in stubs)) {
var resolved;
stubs[prop] = (...args) => {
resolved ||= resolveSymbol(prop);
return resolved(...args);
};
}
```
https://github.com/emscripten-core/emscripten/blob/main/src/library_dylink.js?plain=1#L724-L727
This causes trouble when mixed with stack switching. Working around it will be a bit convoluted, but it should be possible with a little helper wasm module.
Contributor guide
Assessment
This issue has not been assessed yet.