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

unknown import: __wbindgen_placeholder__::__wbindgen_cb_drop has not been defined #544

Open
jp4g opened this issue Jul 2, 2023 · 6 comments

Comments

@jp4g
Copy link

jp4g commented Jul 2, 2023

Hello,

I am trying to build a package halo2_backend I am working on and import it into javascript.

I can build the package with cargo build --lib --release --package noir_halo2_backend_pse --target wasm32-wasi. However, when I try to initialize using wasmer-js or wasi-js, or if I try to use wasmtime by the cli, it always produces the same error:

 > wasmtime target/wasm32-wasi/release/noir_halo2_backend_pse.wasm
Error: failed to run main module `target/wasm32-wasi/release/noir_halo2_backend_pse.wasm`

Caused by:
    0: failed to instantiate "target/wasm32-wasi/release/noir_halo2_backend_pse.wasm"
    1: unknown import: `__wbindgen_placeholder__::__wbindgen_cb_drop` has not been defined

I've tried removing as many references to wasm-bindgen in a separate branch, including sub-dependencies, but have not progressed. Any suggestions on how I debug this issue would be greatly appreciated!

@jp4g
Copy link
Author

jp4g commented Jul 2, 2023

Edit: I got it to compile by removing reqwest, but this neuters the functionality. New request for help: How do I get the reqwest functionality without breaking wasi?

@landonxjames
Copy link

I have a similar issue, although my error is:

$ wasmtime ./wasitest.wasm
Error: failed to run main module `./wasitest.wasm`

Caused by:
    0: failed to instantiate "./wasitest.wasm"
    1: unknown import: `./wasitest.rustc_bg.js::__wbindgen_string_new` has not been defined

Haven't traced it down to a particular dependency yet, but thats my next step. Would be ideal if this could be a compile time error (with some identifying information about what exactly introduces the issue) instead of a runtime error.

@pchickey
Copy link
Contributor

pchickey commented Jul 27, 2023

Those symbols are coming from bindings created by the wasm-bindgen crate. wasm-bindgen is not compatible with WASI. wasm-bindgen is intended to be used with those imports implemented in javascript, instantiating Wasm inside a JS engine (web browsers, nodejs, etc).

They are not implemented by wasmtime, and they won't be.

@landonxjames
Copy link

I think the confusion, at least on my end, comes from the fact that this .wasm file was generated by cargo wasi which is owned by the Bytecode Alliance (so presumably complies to the WASI standard), and does run a wasm-bindgen step as part of its compilation

@pchickey
Copy link
Contributor

Sorry that tripped you up. That README was written in 2019 when wasm-bindgen and the ideas of interface types were radically different. Its use of wasm-bindgen is super out of date at this point, the upstream wasm-bindgen has moved on and (as far as I can tell) eliminated that obsolete interface types implementation. wasm-bindgen is a rustwasm group project, which isn't part of the Bytecode Alliance. So, we should probably remove that functionality from cargo-wasi and its docs, when someone gets a chance. cc @alexcrichton

In the meantime, the name "interface types" has been subsumed by "component model". The term "interface types" only lives on in the .wit file extension, which is mostly because that extension had been reserved back in the interface types days and it seemed appropriate enough for use.

@alexcrichton
Copy link
Contributor

Thanks for the heads up, I've opened an issue about archiving cargo wasi and updating the README since that tool in general shouldn't be used for WASI any more.

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

4 participants