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

Wasmer Wasi Runtime Missing Import #160

Open
AmeanAsad opened this issue Dec 17, 2022 · 3 comments
Open

Wasmer Wasi Runtime Missing Import #160

AmeanAsad opened this issue Dec 17, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@AmeanAsad
Copy link
Contributor

Hello!

Background:

I am using fp-bindgen to create bindings for a wasm plugin that I wrote in Rust.
The flow is that I create a protocol then export a plugin and a rust-wasmer-wasi runtime. I use the plugin to generate bindings for my wasm plugin and use the runtime to import the wasm module into Rust and test out the exported functions.

Also just incase this is relevant, I am importing the latest fp-bindgen version from the git main branch.

Issue Description:

When using the RustWasmerWasiRuntime option. The created bindings.rs file contains a Runtime impl with a fn new() function to initialize it. That function has this line:

let env_from_instance = RuntimeInstanceData::from_instance(&mut store, &instance);

The from_instance function checks that the three functions are exported from the WASM module:

  • __fp_free
  • __fp_guest_resolve_async_value
  • __fp_malloc

By default, when you use the RustPlugin with no dependencies it will add fp-bindgen-support with the guest feature as as dependecny as part of the generated rust-plugin crate. This however, only exports the __fp_free and __fp_malloc as the guest feature is enabled. The __fp_guest_resolve_async_value is left out because the async feature is not enabled. This will in turn break the line of code I referenced above and usage of the generated rust-wasmer-wasi-runtime bindings will break.

Therefore, you have to add fp-bindgen-support as a CargoDependency as part of the dependencies option for the RustPlugin and add async as a dependency manually. I am not sure if this is the intended behavior but it seems a bit odd as if all those three functions are expected to be exported by default when generating the RuntimeInstanceData.

Happy to provide more info, apologies if I missed something in the docs!

@arendjr arendjr added the bug Something isn't working label Jan 3, 2023
@arendjr
Copy link
Contributor

arendjr commented Jan 3, 2023

Thanks for the report! I'll have to confirm this, but it sounds like the plugin generator correctly leaves out the async feature when the protocol doesn't contain any async functions, whereas the runtime generator doesn't correctly disable the check in that case. This would be definitely something we'll need to fix.

@AmeanAsad
Copy link
Contributor Author

@arendjr Im happy to try and tackle this issue if that is okay with you.

@arendjr
Copy link
Contributor

arendjr commented Jan 4, 2023

Absolutely, that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants