Welcome to the Linux Foundation Forum!

Wasmtime CLI not displaying function return values by default

kokalovich
kokalovich Posts: 2
edited May 18 in LFD134 Class Forum

I'm working through the WebAssembly course (LFD134) and have encountered an issue with displaying return values when using wasmtime.

I have a simple WebAssembly module in add.wat:

wat
(module
  (func $add (param $lhs i32) (param $rhs i32) (result i32)
     (i32.add
       (local.get $lhs)
       (local.get $rhs)
     )
  )
  (export "add" (func $add))
)

After compiling with wat2wasm add.wat, I can verify with wasm2wat and wasm-objdump that the module is correct. However, when I try to execute the function with:

wasmtime add.wasm --invoke add 1 2

No output is displayed, even though the function should return the value 3.
I eventually found that using:

wasmtime --invoke=add add.wasm 1 2

with an equals sign) does display the return value (3), along with warnings about it being an experimental feature.

My questions:

Is this the expected behavior of wasmtime (v32.0.0)?
Is there a more standard/stable way to display function return values?
Is this behavior documented somewhere that I missed?

Please note this is proposed by documentation of course to run command in this way

https://trainingportal.linuxfoundation.org/learn/course/webassembly-components-from-cloud-to-edge-lfd134/webassembly-from-scratch/exploring-webassembly?page=7

Answers

Categories

Upcoming Training