Officeyutong opened issue #5834:
For example, the following program panicked when linking the first module due to
module2::testfunc2
not defined.use wasmtime::{Engine, Linker, Module, Store}; struct State {} fn main() { let engine = Engine::default(); let mut linker = Linker::new(&engine); let mut store = Store::new(&engine, State {}); let module1 = Module::new( &engine, r#" (module (import "module2" "testfunc2" (func $testfunc2 (result i32) ) ) (func $testfunc1 (result i32) i32.const 123 ) (export "testfunc1" (func $testfunc1)) ) "# .as_bytes(), ) .unwrap(); let module2 = Module::new( &engine, r#" (module (import "module1" "testfunc1" (func $testfunc1 (result i32) ) ) (func $testfunc2 (result i32) call $testfunc1 ) (export "testfunc2" (func $testfunc2)) ) "# .as_bytes(), ) .unwrap(); linker.module(&mut store, "module1", &module1).unwrap(); linker.module(&mut store, "module2", &module2).unwrap(); }
Officeyutong edited issue #5834:
For example, the following program panicked when linking the first module due to
module2::testfunc2
not defined.use wasmtime::{Engine, Linker, Module, Store}; struct State {} fn main() { let engine = Engine::default(); let mut linker = Linker::new(&engine); let mut store = Store::new(&engine, State {}); let module1 = Module::new( &engine, r#" (module (import "module2" "testfunc2" (func $testfunc2 (result i32) ) ) (func $testfunc1 (result i32) i32.const 123 ) (export "testfunc1" (func $testfunc1)) ) "# .as_bytes(), ) .unwrap(); let module2 = Module::new( &engine, r#" (module (import "module1" "testfunc1" (func $testfunc1 (result i32) ) ) (func $testfunc2 (result i32) call $testfunc1 ) (export "testfunc2" (func $testfunc2)) ) "# .as_bytes(), ) .unwrap(); linker.module(&mut store, "module1", &module1).unwrap(); linker.module(&mut store, "module2", &module2).unwrap(); }
pchickey commented on issue #5834:
Cyclic imports are not possible with the wasmtime Linker. You will need to break the cycle with some sort of trampoline. You can build one of these in pure wasm using tables, or you can use a native Func and some data in the Store to
pchickey closed issue #5834:
For example, the following program panicked when linking the first module due to
module2::testfunc2
not defined.use wasmtime::{Engine, Linker, Module, Store}; struct State {} fn main() { let engine = Engine::default(); let mut linker = Linker::new(&engine); let mut store = Store::new(&engine, State {}); let module1 = Module::new( &engine, r#" (module (import "module2" "testfunc2" (func $testfunc2 (result i32) ) ) (func $testfunc1 (result i32) i32.const 123 ) (export "testfunc1" (func $testfunc1)) ) "# .as_bytes(), ) .unwrap(); let module2 = Module::new( &engine, r#" (module (import "module1" "testfunc1" (func $testfunc1 (result i32) ) ) (func $testfunc2 (result i32) call $testfunc1 ) (export "testfunc2" (func $testfunc2)) ) "# .as_bytes(), ) .unwrap(); linker.module(&mut store, "module1", &module1).unwrap(); linker.module(&mut store, "module2", &module2).unwrap(); }
pchickey reopened issue #5834:
For example, the following program panicked when linking the first module due to
module2::testfunc2
not defined.use wasmtime::{Engine, Linker, Module, Store}; struct State {} fn main() { let engine = Engine::default(); let mut linker = Linker::new(&engine); let mut store = Store::new(&engine, State {}); let module1 = Module::new( &engine, r#" (module (import "module2" "testfunc2" (func $testfunc2 (result i32) ) ) (func $testfunc1 (result i32) i32.const 123 ) (export "testfunc1" (func $testfunc1)) ) "# .as_bytes(), ) .unwrap(); let module2 = Module::new( &engine, r#" (module (import "module1" "testfunc1" (func $testfunc1 (result i32) ) ) (func $testfunc2 (result i32) call $testfunc1 ) (export "testfunc2" (func $testfunc2)) ) "# .as_bytes(), ) .unwrap(); linker.module(&mut store, "module1", &module1).unwrap(); linker.module(&mut store, "module2", &module2).unwrap(); }
pchickey edited a comment on issue #5834:
Cyclic imports are not possible with the wasmtime Linker. You will need to break the cycle with some sort of trampoline. You can build one of these in pure wasm using tables, or you can use a native Func and some data in the Store. (Sorry to close, fat finger)
Officeyutong commented on issue #5834:
Cyclic imports are not possible with the wasmtime Linker. You will need to break the cycle with some sort of trampoline. You can build one of these in pure wasm using tables, or you can use a native Func and some data in the Store. (Sorry to close, fat finger)
I'll use a native Func and Store, thank you!
Officeyutong closed issue #5834:
For example, the following program panicked when linking the first module due to
module2::testfunc2
not defined.use wasmtime::{Engine, Linker, Module, Store}; struct State {} fn main() { let engine = Engine::default(); let mut linker = Linker::new(&engine); let mut store = Store::new(&engine, State {}); let module1 = Module::new( &engine, r#" (module (import "module2" "testfunc2" (func $testfunc2 (result i32) ) ) (func $testfunc1 (result i32) i32.const 123 ) (export "testfunc1" (func $testfunc1)) ) "# .as_bytes(), ) .unwrap(); let module2 = Module::new( &engine, r#" (module (import "module1" "testfunc1" (func $testfunc1 (result i32) ) ) (func $testfunc2 (result i32) call $testfunc1 ) (export "testfunc2" (func $testfunc2)) ) "# .as_bytes(), ) .unwrap(); linker.module(&mut store, "module1", &module1).unwrap(); linker.module(&mut store, "module2", &module2).unwrap(); }
Last updated: Dec 23 2024 at 12:05 UTC