-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[library_dylink.js] How to link a Rust side module with C++ main module: missing invoke_
functions in proxyHandler
#22906
Comments
Rust doesn't support |
@carlopi I've encountered this problem before and your workaround looks pretty similar to what I did. It would also fix it to compile with |
Funnily enough I just submitted a change to remove All the There was an issue where these functions were not being correctly added to the global list when libraries were loaded with |
Or wait, I see you are on 3.1.68 already. Can you confirm, the which |
Imports that start with emscripten/src/library_dylink.js Lines 130 to 133 in 2e84cfd
|
I do need to be able to catch panics, but I am not sure this is connected to exceptional behaviour, this looks to me it's about regular handling of indirect calls. @sbc100:
And I get into Also strange that I see this problem after dlopen completed, but while executing regular code. Thanks a lot for the help obviously. I do have also another concern: are Emscripten versions expected to be compatible cross versions? My problem is that main module and side modules are built at different point in times, machines / setups, and it's not obvious they are on the same Emscripten version. Should I enforce that, or there is any way to get, given 2 Emscripten versions, whether they are ABI compatible? Or there is no such a guarantee? Is this in the roadmap? |
Sadly we don't currently offer guarantees about ABI compatibility so its best if you can build the main module and side modules with the same version of emscripten. By the way does the problem here go away if you do that? i.e. is this bug actually about ABI incompatibility between modules built with different versions of emscripten? Or is there something else here too? In terms of ABI compatibility we do hope that breakages are rare, and we do help to one day make stronger guarantees about this. |
@sbc100: Problem I encountered in local development, so same version of emscripten both to build main wasm module & accompanying JavaScript and side rust module. |
Can you verify if |
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.68 (ceee49d)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 5cc64bf60bc04b9315de3c679eb753de4d554a8a)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/carlo/emsdk/upstream/bin
The situation:
I work on duckdb-wasm, a C++ based codebase then compiled to Wasm via Emscripten.
To allow to extend the surface of the project, we allow, both in native and Wasm, to add code at run-time via extensions.
In the case of Wasm this means that main project comes with a JS and Wasm module, extension itself is a Wasm module, and via Emscripten's implementation of
dlopen
import / exports are remapped dynamically and then execution continues with additional functionality.This works end to end for C++ extensions, where on performing
dlopen
imports are correctly remapped in the JS layer and stuff works as expected.Basic is like:
(live demo at https://shell.duckdb.org/#queries=v0,SELECT-st_area('POLYGON((0-0%2C-0-1%2C-1-1%2C-1-0%2C-0-0))'%3A%3Ageometry)~,LOAD-spatial~,SELECT-st_area('POLYGON((0-0%2C-0-1%2C-1-1%2C-1-0%2C-0-0))'%3A%3Ageometry)~)
Now I am looking to do the same, but using Rust-based code, compiled with cargo with target
wasm32-unknown-emscripten
.The problem
Rust code compiles, but on
dlopen
there are some missing symbols errors that are raised by code that looks like to come from https://github.com/emscripten-core/emscripten/blob/main/src/library_dylink.js#L699 that is like:Error is that
invoke_viii
, orinvoke_vii
or similarly named functions are not present at the JavasScript level.The hack
Adding a conditional like:
solves the problem, and shows that basically the class of
invoke_
-functions are special in the fact that their code can be reconstructed starting from the signature to perform the correct indirect call.This workaround is very brittle, I am looking for a more proper solution / directions / material on how this can be properly supported.
The text was updated successfully, but these errors were encountered: