clarify canonopt requirements for async lifts by dicej · Pull Request #575 · WebAssembly/component-model

@dicej

I had _thought_ that the spec allowed an async lift to omit the memory canonopt
if only the result type (and not the paarameter types) required it, leaving the
core function free to call any `task.return` at runtime as long as the type and
string encoding matched.  Indeed, that's what we implemented in `wasm-tools` and
Wasmtime.

However, it looks like I misremembered, since the spec uses an exact comparison
in `LiftOptions.equal`.  That's good news, because allowing the core function to
call any of several `task.return` functions, each with a different memory, makes
it hard for the runtime to optimize compositions.

So no actual change needed here -- just a clarification.  We'll update
`wasm-tools` and `Wasmtime` to match.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

dicej added a commit to dicej/wasm-tools that referenced this pull request

Nov 17, 2025
Per WebAssembly/component-model#575, both `wasm-tools`
and Wasmtime have been too permissive, allowing async lifts to optionally omit a
memory canonopt if only the return type (and not the parameter types) would need
one.  This fixes validation to require the option in such cases.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

@dicej dicej mentioned this pull request

Nov 17, 2025

alexcrichton

github-merge-queue bot pushed a commit to bytecodealliance/wasm-tools that referenced this pull request

Nov 17, 2025
* require memory for async lifts as needed

Per WebAssembly/component-model#575, both `wasm-tools`
and Wasmtime have been too permissive, allowing async lifts to optionally omit a
memory canonopt if only the return type (and not the parameter types) would need
one.  This fixes validation to require the option in such cases.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

* Fix streams-and-futures test

Fixing a mistake from #2376

* add memory option to lifts when needed in wit-component

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>

lukewagner