Welcome to the Linux Foundation Forum!

Wasmtime CLI not displaying function return values by default

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:

  1. wat
  2. (module
  3. (func $add (param $lhs i32) (param $rhs i32) (result i32)
  4. (i32.add
  5. (local.get $lhs)
  6. (local.get $rhs)
  7. )
  8. )
  9. (export "add" (func $add))
  10. )

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:

  1. 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:

  1. 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

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training