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

Wasmex and wasm_bindgen: unknown import: wbg::__wbindgen_object_drop_ref has not been defined #618

Closed
erszcz opened this issue Aug 7, 2024 · 2 comments

Comments

@erszcz
Copy link

erszcz commented Aug 7, 2024

Hi,

First of all, thanks for all the effort put into making this project!

I wanted to build ywasm and run it in Elixir with Wasmex, but have run into the following issue:

iex(2)> {:ok, pid} = Wasmex.start_link(%{bytes: bytes})
** (MatchError) no match of right hand side value: {:error, "unknown import: `wbg::__wbindgen_object_drop_ref` has not been defined"}
    (stdlib 5.2.3) erl_eval.erl:498: :erl_eval.expr/6
    iex:2: (file)

I figured out I can pass in imports and provided a stub for __wbindgen_object_drop_ref:

iex(2)> {:ok, pid} = Wasmex.start_link(%{bytes: bytes, imports: %{wbg: %{:'__wbindgen_object_drop_ref' => {:fn, [:i32], [], fn _ -> :ok end}}}})
** (MatchError) no match of right hand side value: {:error, "unknown import: `wbg::__wbindgen_object_clone_ref` has not been defined"}
    (stdlib 5.2.3) erl_eval.erl:498: :erl_eval.expr/6
    iex:2: (file)

And then a few others (__wbindgen_object_clone_ref, __wbindgen_is_undefined), but this leads me to conclude that I'm doing something wrong and these functions should actually be provided by another WASM module. What would be the next steps to get this running properly (i.e. a WASM module with a dependency on wasm_bindgen)? I'd be grateful for any pointers, including external reading material, if such exists.

@munjalpatel
Copy link
Contributor

@erszcz yes, from errors, it appears your target wasm is dependent on imports that are missing.

Is your target module dependent on another wasm module(s) that provides the missing functions?
If so, you'll need to dynamically link those wasm modules so that you don't have to manually specify all missing imports.

We recently added support to dynamically link external modules.
#596

@erszcz
Copy link
Author

erszcz commented Aug 8, 2024

Aha, perfect! Thank you for the pointer, @munjalpatel, I'll dig into that thread!
I'll close the issue, since it's not really a Wasmex problem that needs addressing.

@erszcz erszcz closed this as completed Aug 8, 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

No branches or pull requests

2 participants