Stream: general

Topic: Wasm module linking from Rust


view this post on Zulip Enrico Loparco (Dec 01 2023 at 02:23):

Hello, I'm playing around with module linking.
Something similar to what is done in the Wasmtime examples linking1.wat and linking2.wat.
Or in WAMR from .c files.

How can I do that starting from a Rust project? I want to create a submodule that would be linked by another module.
I set up a sample project https://github.com/eloparco/multi-module but it doesn't compile.

cargo build --release --target wasm32-wasi
   Compiling mC v0.1.0 (multi-module/mC)
error[E0432]: unresolved import `mA`
 --> mC/src/main.rs:1:5
  |
1 | use mA;
  |     ^^ no external crate `mA`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `mC` (bin "mC") due to previous error

Has anyone done that before? Not very familiar with Rust. Thanks!

Contribute to eloparco/multi-module development by creating an account on GitHub.

view this post on Zulip Enrico Loparco (Dec 03 2023 at 21:36):

Now I'm able to compile (I've updated https://github.com/eloparco/multi-module) but in linking1.wasm there's no reference to module linking2 and the functions in it.

Contribute to eloparco/multi-module development by creating an account on GitHub.

view this post on Zulip Enrico Loparco (Dec 04 2023 at 01:17):

Managed to get it done and updated the repository. It produces the wasm files I was expecting and runs fine on WAMR


Last updated: Oct 23 2024 at 20:03 UTC