Skip to content
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

Support for dynamic linking #437

Closed
munjalpatel opened this issue Jun 3, 2023 · 5 comments · Fixed by #596
Closed

Support for dynamic linking #437

munjalpatel opened this issue Jun 3, 2023 · 5 comments · Fixed by #596

Comments

@munjalpatel
Copy link
Contributor

wasmtime supports dynamic linking using —preload. Is dynamic linking supported by this library?

Example use case: https://github.com/bytecodealliance/javy#creating-and-running-a-dynamically-linked-module-on-the-cli

@tessi
Copy link
Owner

tessi commented Jun 3, 2023

Hey @munjalpatel thanks for your question, it's a good one! :)

Wasmex does currently not support dynamic linking between WASM modules. But if you're up to implement that support, I'd be happy to review a pull request. I'd be happy to give some pointers, if you want to tackle this topic.

A workaround is to implement all functions in the javy_quickjs_provider_v1 namespace in Elixir and pass them in as imported functions to my_code.wasm from your linked example. But I see that it's probably a (fun) challenge to implement javy again in pure elixir when it is already implemented in another WASM file.

@bhelx
Copy link

bhelx commented Jun 28, 2024

Curious if this is still the case as it may limit us switching to wasmex. Happy to contribute the feature if it's not done!

@munjalpatel
Copy link
Contributor Author

@bhelx I believe this still needs implementation.

If I am reading the code correctly, I think we need to instantiate the module to link with the same linker before the instantiation of the user-provided module here:

let mut linker = Linker::new(store_or_caller.engine());

Reference: https://docs.wasmtime.dev/examples-rust-linking.html

@bhelx
Copy link

bhelx commented Jun 28, 2024

Yes, I can look into it a little bit more. Would be curious what @tessi thinks the API should be before we propose any changes. We could expose some more of the bits of linking to the caller, or we could create a datastructure that you pass and the rust code ties everything together. We do something similar in extism but we're trying to abstract away the runtime interface so that may not be appropriate here.

@tessi
Copy link
Owner

tessi commented Jul 3, 2024

Would be curious what @tessi thinks the API should be before we propose any changes.

thanks! Actually I already looked into @munjalpatel 's PR on the topic and love the start 💛 . I gave some inputs on API design on my review. So there is a discussion over in #596 - but I believe it shouldn't be too hard to implement either way.

@tessi tessi closed this as completed in #596 Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants