Skip to content

go: add --stackful-exports for async exports - #1784

Draft
dgryski wants to merge 1 commit into
bytecodealliance:mainfrom
dgryski:dgryski/tinygo-wasip3
Draft

dgryski wants to merge 1 commit into
bytecodealliance:mainfrom
dgryski:dgryski/tinygo-wasip3

Conversation

@dgryski

@dgryski dgryski commented Nov 11, 2026

Copy link
Copy Markdown

Adds --stackful-exports to the Go generator. With it, async exports use the [async-lift-stackful] ABI instead of callback-based [async-lift]:

  • the export is named [async-lift-stackful]<name> and no [callback] function is exported,
  • the wrapper runs the body in witAsync.Run(func() { ... }) and returns nothing, since the result is delivered via task.return.

This is for runtimes that can block a thread inside an export, such as TinyGo's wasip3 target with cooperative threads. The default output is unchanged.

In crates/core/src/abi.rs, AbiVariant::GuestExportAsyncStackful now lowers a result to memory like the other guest-export variants, replacing a todo!("stackful exports are not yet supported").

Dependencies

Needs the TinyGo implementation of wit/async from bytecodealliance/go-pkg#19 at runtime. This PR doesn't bump the crates/go/src/pkg submodule; that should follow once go-pkg#19 lands.

Testing

Generated bindings for a wasi:http/handler world with --stackful-exports --generate-stubs, built with TinyGo's wasip3 target, and ran the component under wasmtime (async import, streamed bodies, overlapping requests).

I haven't added a codegen test in tests/ yet. Happy to add one if you can point me at the preferred place for an option-specific Go test.

Add an option that makes async exports stackful. The generated code uses
the [async-lift-stackful] name, does not export a [callback] function and
returns nothing from the wrapper, since the result goes through
task.return. This is for runtimes that can block a thread, such as TinyGo
with cooperative threads.

In the core ABI, lower a result to memory for stackful exports the same
way as for the other export variants. This replaces a todo.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant