Issue linking cache interface in `rust-consumer`
Closed this issue · 6 comments
When following this awesome write-up I ran into issues linking the Wasm library to the rust-consumer
module with wasmlink
.
To get wasmlink
I cloned the wit-bindgen repo and followed the wasmlink README to build it. Specifically, I ran, cargo build -p wasmlink-cli
, which resulted in output built to wit-bindgen/target/debug/wasmlink
. I modified the first line of the rust-consumer
Makefile to target this binary for wasmlink
.
Then, I built (with make build
) and tried to link the WASI library and run the rust-consumer
with make link run
. make link
fails with:
[2021-12-27T17:44:56Z ERROR] failed to parse interface file `../cache.wit`
Caused by:
invalid character in identifier '_'
--> ../cache.wit:4:5
|
4 | runtime_error,
| ^
make: *** [Makefile:9: link] Error 1
The interface file was successfully used to build the Wasm library (rust_wasi_impl.wasm
); however, wasmlink
seems unable to use it. Is there a different way I should be building and running wasmlink
?
First, make sure to use the same revision for the wit-bindgen
crates and Wasmlink — specifically, https://github.com/bytecodealliance/wit-bindgen/tree/32e63116d469d8046727fae3c1333a7d35d0c5d3.
Install wasmlink-cli
from that commit, and let me know if that works.
(the article and this repo are pinned to a revision before some breaking changes to WIT, which happened in bytecodealliance/wit-bindgen#119)
See fermyon/wasi-experimental-toolkit#3 for some updates related to this change.
I installed wasmlink-cli
from the above commit and am pointing to it from the rust-consumer
Makefile; however, while make link
with wasmlink
succeeds, make run
is failing with the following error that the --enable-module-linking
subcommand DNE:
kagold@akri-dev:~/radu-demo/rust-consumer$ make link run
/home/kagold/radu-demo/wit-bindgen/target/debug/wasmlink ../rust-consumer/target/wasm32-wasi/release/rust-consumer.wasm \
--interface cache=../cache.wit \
--profile wasmtime \
--module cache=../rust-wasi-impl/target/wasm32-wasi/release/rust_wasi_impl.wasm \
--output linked.wasm
wasmtime --enable-module-linking --enable-multi-memory --mapdir=/cache::. linked.wasm
error: Found argument '--enable-module-linking' which wasn't expected, or isn't valid in this context
USAGE:
wasmtime <SUBCOMMAND>
For more information try --help
make: *** [Makefile:16: run] Error 1
I am using verion 0.33 of wasmtime
as recommended in the example -- I installed it from here.
Ah, you are correct.
I just pushed a new commit with the correct CLI usage.
Ah, you are correct. I just pushed a new commit with the correct CLI usage.
That did the trick! 🥳 😃 I also added this print statement to rust-consumer/src/main.rs
in order to make the make link run
output match that of the writeup. Thanks for all the help!
Yaay, glad it worked, and sorry for the version mismatch.