Dennis-Zhang-SH opened issue #5281:
Hi,
I met following issues that I could not resolve.
cargo clean cargo build --target wasm32-wasi --release Compiling proc-macro2 v1.0.47 Compiling unicode-ident v1.0.5 Compiling quote v1.0.21 Compiling syn v1.0.103 Compiling log v0.4.17 Compiling wasm-bindgen-shared v0.2.83 Compiling cfg-if v1.0.0 Compiling once_cell v1.16.0 Compiling bumpalo v3.11.1 Compiling wasm-bindgen v0.2.83 Compiling wasm-bindgen-backend v0.2.83 Compiling wasm-bindgen-macro-support v0.2.83 Compiling wasm-bindgen-macro v0.2.83 Compiling libadd v0.1.0 (/Users/dennis/Documents/code/libadd) Finished release [optimized] target(s) in 8.44s wasmtime --invoke greet ./target/wasm32-wasi/release/libadd.wasm "Wasmtime CLI" Error: failed to run main module `./target/wasm32-wasi/release/libadd.wasm` Caused by: 0: failed to instantiate "./target/wasm32-wasi/release/libadd.wasm" 1: unknown import: `__wbindgen_placeholder__::__wbindgen_describe` has not been defined cargo wasi build --release Finished release [optimized] target(s) in 0.03s thread 'main' panicked at 'unknown instruction LocalTee(LocalTee { local: Id { idx: 331 } })', crates/wasm-interpreter/src/lib.rs:363:18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: failed to process wasm at `/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm` Caused by: failed to execute "/Users/dennis/Library/Caches/cargo-wasi/0.1.26/wasm-bindgen/0.2.83/wasm-bindgen" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm" "--out-dir" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/.tmpsc1F5p" "--out-name" "foo" status: exit status: 101
the original codes and toml are:
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn add(left: i32, right: i32) -> i32 { left + right } #[wasm_bindgen] pub fn greet(name: &str) -> String { format!("Hello, {}!", name) } // Cargo.toml [lib] crate-type = ['cdylib'] [dependencies] wasm-bindgen = "0.2.83"
Can somebody help me with it?
Dennis-Zhang-SH edited issue #5281:
Hi,
I met following issues that I could not resolve.
cargo clean cargo build --target wasm32-wasi --release Compiling proc-macro2 v1.0.47 Compiling unicode-ident v1.0.5 Compiling quote v1.0.21 Compiling syn v1.0.103 Compiling log v0.4.17 Compiling wasm-bindgen-shared v0.2.83 Compiling cfg-if v1.0.0 Compiling once_cell v1.16.0 Compiling bumpalo v3.11.1 Compiling wasm-bindgen v0.2.83 Compiling wasm-bindgen-backend v0.2.83 Compiling wasm-bindgen-macro-support v0.2.83 Compiling wasm-bindgen-macro v0.2.83 Compiling libadd v0.1.0 (/Users/dennis/Documents/code/libadd) Finished release [optimized] target(s) in 8.44s wasmtime --invoke greet ./target/wasm32-wasi/release/libadd.wasm "Wasmtime CLI" Error: failed to run main module `./target/wasm32-wasi/release/libadd.wasm` Caused by: 0: failed to instantiate "./target/wasm32-wasi/release/libadd.wasm" 1: unknown import: `__wbindgen_placeholder__::__wbindgen_describe` has not been defined cargo wasi build --release Finished release [optimized] target(s) in 0.03s thread 'main' panicked at 'unknown instruction LocalTee(LocalTee { local: Id { idx: 331 } })', crates/wasm-interpreter/src/lib.rs:363:18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: failed to process wasm at `/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm` Caused by: failed to execute "/Users/dennis/Library/Caches/cargo-wasi/0.1.26/wasm-bindgen/0.2.83/wasm-bindgen" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm" "--out-dir" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/.tmpsc1F5p" "--out-name" "foo" status: exit status: 101
the original codes and toml are:
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn add(left: i32, right: i32) -> i32 { left + right } #[wasm_bindgen] pub fn greet(name: &str) -> String { format!("Hello, {}!", name) } // Cargo.toml [lib] crate-type = ['cdylib'] [dependencies] wasm-bindgen = "0.2.83"
Can somebody help me with it?
bjorn3 commented on issue #5281:
Wasm-bindgen is for the web only. It is not compatible with wasi. You probably want to use wit-bindgen instead.
Dennis-Zhang-SH commented on issue #5281:
Wasm-bindgen is for the web only. It is not compatible with wasi. You probably want to use wit-bindgen instead.
thanks, I totally missed that the feature has been removed on the wasmtime book, my bad, I will check out wit-bindgen.
Dennis-Zhang-SH closed issue #5281:
Hi,
I met following issues that I could not resolve.
cargo clean cargo build --target wasm32-wasi --release Compiling proc-macro2 v1.0.47 Compiling unicode-ident v1.0.5 Compiling quote v1.0.21 Compiling syn v1.0.103 Compiling log v0.4.17 Compiling wasm-bindgen-shared v0.2.83 Compiling cfg-if v1.0.0 Compiling once_cell v1.16.0 Compiling bumpalo v3.11.1 Compiling wasm-bindgen v0.2.83 Compiling wasm-bindgen-backend v0.2.83 Compiling wasm-bindgen-macro-support v0.2.83 Compiling wasm-bindgen-macro v0.2.83 Compiling libadd v0.1.0 (/Users/dennis/Documents/code/libadd) Finished release [optimized] target(s) in 8.44s wasmtime --invoke greet ./target/wasm32-wasi/release/libadd.wasm "Wasmtime CLI" Error: failed to run main module `./target/wasm32-wasi/release/libadd.wasm` Caused by: 0: failed to instantiate "./target/wasm32-wasi/release/libadd.wasm" 1: unknown import: `__wbindgen_placeholder__::__wbindgen_describe` has not been defined cargo wasi build --release Finished release [optimized] target(s) in 0.03s thread 'main' panicked at 'unknown instruction LocalTee(LocalTee { local: Id { idx: 331 } })', crates/wasm-interpreter/src/lib.rs:363:18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: failed to process wasm at `/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm` Caused by: failed to execute "/Users/dennis/Library/Caches/cargo-wasi/0.1.26/wasm-bindgen/0.2.83/wasm-bindgen" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/libadd.rustc.wasm" "--out-dir" "/Users/dennis/Documents/code/libadd/target/wasm32-wasi/release/.tmpsc1F5p" "--out-name" "foo" status: exit status: 101
the original codes and toml are:
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn add(left: i32, right: i32) -> i32 { left + right } #[wasm_bindgen] pub fn greet(name: &str) -> String { format!("Hello, {}!", name) } // Cargo.toml [lib] crate-type = ['cdylib'] [dependencies] wasm-bindgen = "0.2.83"
Can somebody help me with it?
Dennis-Zhang-SH commented on issue #5281:
@bjorn3 Does it mean currently wasmtime could not load any wasm file as module? I removed wasm-bindgen and build with
cargo wasi build --release
, but it still won't work, sayingUnsupported feature: Support for interface types has temporarily been removed from wasmtime
bjorn3 commented on issue #5281:
cargo-wasi seems to use interface types, which has been removed from wasmtime as the interface types proposal for webassembly is currently inactive in favor of the component model proposal. Using
cargo build --target wasm32-wasi
rather thancargo wasi build
should work just fine. This will build a regular wasm module that doesn't use interface types.
Dennis-Zhang-SH commented on issue #5281:
cargo-wasi seems to use interface types, which has been removed from wasmtime as the interface types proposal for webassembly is currently inactive in favor of the component model proposal. Using
cargo build --target wasm32-wasi
rather thancargo wasi build
should work just fine. This will build a regular wasm module that doesn't use interface types.Thanks for explaining, so the whole cargo wasi and wasm-bindgen are abandon right? It would be better to update the document.
bjorn3 commented on issue #5281:
Wasm-bindgen is universally used when targeting the web. Just not when targeting wasi. As for cargo-wasi I'm not sure what the plan for it is.
Dennis-Zhang-SH commented on issue #5281:
@bjorn3 okay, is there any wasmtime community? I would like to join, I have some questions haha, such as why println! macro could work in bin wasmtime while not in lib wasm
bjorn3 commented on issue #5281:
There is https://bytecodealliance.zulipchat.com.
Last updated: Dec 23 2024 at 12:05 UTC