suchapalaver opened issue #5551:
I tried to run the example found here. The code copied here for convenience:
extern crate wasmtime; extern crate anyhow; use wasmtime::*; fn main() -> anyhow::Result<()> { let mut store = Store::<()>::default(); let wat = r#" (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) "#; let module = Module::new(store.engine(), wat)?; let instance = Instance::new(&mut store, &module, &[])?; let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?; println!("1 + 2 = {}", add.call(&mut store, (1, 2))?); Ok(()) }
Doing so, I get the following error:
Error: failed to parse WebAssembly module Caused by: Invalid input WebAssembly code at offset 0: magic header not detected: bad magic number
suchapalaver edited issue #5551:
I tried to run the example found here. Here's the code copied below for convenience:
extern crate wasmtime; extern crate anyhow; use wasmtime::*; fn main() -> anyhow::Result<()> { let mut store = Store::<()>::default(); let wat = r#" (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) "#; let module = Module::new(store.engine(), wat)?; let instance = Instance::new(&mut store, &module, &[])?; let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?; println!("1 + 2 = {}", add.call(&mut store, (1, 2))?); Ok(()) }
Doing so, I get the following error:
Error: failed to parse WebAssembly module Caused by: Invalid input WebAssembly code at offset 0: magic header not detected: bad magic number
alexcrichton commented on issue #5551:
The ability to parse the text format is a compile-time feature for Wasmtime. Have you perhaps disabled default features when running this example? If so then the text format will not work and you'll have to make sure the
wat
feature is enabled.
suchapalaver commented on issue #5551:
That was it, thank you! I needed to enable the
wat
feature. Works now. Thanks again!
suchapalaver closed issue #5551:
I tried to run the example found here. Here's the code copied below for convenience:
extern crate wasmtime; extern crate anyhow; use wasmtime::*; fn main() -> anyhow::Result<()> { let mut store = Store::<()>::default(); let wat = r#" (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) "#; let module = Module::new(store.engine(), wat)?; let instance = Instance::new(&mut store, &module, &[])?; let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?; println!("1 + 2 = {}", add.call(&mut store, (1, 2))?); Ok(()) }
Doing so, I get the following error:
Error: failed to parse WebAssembly module Caused by: Invalid input WebAssembly code at offset 0: magic header not detected: bad magic number
Last updated: Dec 23 2024 at 13:07 UTC