-
Notifications
You must be signed in to change notification settings - Fork 259
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
Why does emscripten.Instantiate and InstantiateForModule differ drastically? #1781
Comments
Maybe @jerbob92 (the creator of wazero-emscripten-embind and our resident emscripten expert) can help? |
That's because Emscripten dynamically registers host functions as needed, which are called invoke_xxx, where xxx is the function signature. Wazero needs to know which dynamically registered host functions are imported by the module so that it can generate the function as well (https://github.com/tetratelabs/wazero/blob/main/internal/emscripten/emscripten.go#L43). If Wazero wouldn't do this, it would need to register any combination possible, which is not feasible. I suspect Please note that real C++ exceptions is not supported by Wazero yet, I have been building that here: And it does work, but I don't like the implementation so I'm still waiting for a response on #1654 to make a PR. |
OK. Should I make a PR to change the documentation to use InstantiateForModule (since it sounds like Instantiate should be deprecated)? |
Also as an aside, I'm interested in using wazero to run Tesseract, compiled to WASM via Emscripten. Do you think this project is feasible with the current support of emscripten in wazero? |
Yeah, sounds good!
I don't know what these imports are, but generally you would need to recompile for a standalone WASM file, then you will have way less emscripten specific imports. I use this branch to compile my stuff so that it uses WASI for things like filesystem operations: emscripten-core/emscripten#18285 So it is feasible, but you might need to do some special steps to get there. |
One imports all the host functions needed, and the other barely imports anything. The documentation point you towards Instantiate, which won't work for any C++ module requiring exception support, for example.
Why don't they both set the same emscription host functions?
The text was updated successfully, but these errors were encountered: