Stream: wit-bindgen

Topic: [async] dropped from wasm names?


view this post on Zulip Scott Waye (Dec 06 2025 at 19:40):

HI, has [async] been dropped from the wasm function names, if so, does that mean a new version of wasmtime is needed?

view this post on Zulip Joel Dice (Dec 07 2025 at 01:04):

Correct; it's due to https://github.com/WebAssembly/component-model/pull/578. If you're using the latest wasm-tools and wit-bindgen, you'll need to use Wasmtime's main branch until v40.0.0 is released.

This PR moves async from being a hint that is textually mangled into function names to an optional effect type that is part of a function type. WIT is not changed; just how it's encoded as a c...

view this post on Zulip Scott Waye (Dec 08 2025 at 13:22):

Thanks! Looking at this wit https://github.com/bytecodealliance/wit-bindgen/blob/4284ea88f0b98e2e20e366298e95c9aa2ca4b488/tests/runtime-async/async/simple-import-params-results/test.wit#L18
It generates this c code

__attribute__((__export_name__("run")))
void __wasm_export_exports_runner_run(void) {
  exports_runner_run();
}

and nothing to indicate it is async. Is that right?

A language binding generator for WebAssembly interface types - bytecodealliance/wit-bindgen

view this post on Zulip Scott Waye (Dec 08 2025 at 13:35):

I suppose more specifically why isn't [async-lift] required here any more?

view this post on Zulip Lann Martin (Dec 08 2025 at 13:54):

async-ness is now (Wasmtime main / the above PR) part of the function signature so the flag doesn't need to be part of the name any more.

view this post on Zulip Scott Waye (Dec 08 2025 at 13:56):

How is asyncness expressed in c in the signature? I'm wondering how that would be expressed in LLVM and c would give me a clue.

view this post on Zulip Lann Martin (Dec 08 2025 at 13:59):

I'm not sure if async support has even been added to the C bindings generator yet.

view this post on Zulip Scott Waye (Dec 08 2025 at 14:00):

ah ok, that might explain my confusion

view this post on Zulip Lann Martin (Dec 08 2025 at 14:00):

Semantically, async now means "may block before returning".

view this post on Zulip Alex Crichton (Dec 08 2025 at 14:22):

Oh the C generator does have async support yeah. That specific test is this one which specifies that the run function does a sync lift into an async type, hence the lack of [async-lift]

A language binding generator for WebAssembly interface types - bytecodealliance/wit-bindgen

view this post on Zulip Joel Dice (Dec 08 2025 at 14:26):

The C bindings generator definitely supports async, and yes, the export should include [async-lift] by default for async-typed functions. This is what I see when I run wit-bindgen on main:

 $ cargo run -- c -w runner tests/runtime-async/async/simple-import-params-results/test.wit
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/wit-bindgen c -w runner tests/runtime-async/async/simple-import-params-results/test.wit`
Generating "runner.c"
Generating "runner.h"
Generating "runner_component_type.o"
 $ grep -B 5 -A 5 '\[async-lift\]run' runner.c
  return ret;
}

// Helper Functions

__attribute__((__export_name__("[callback][async-lift]run")))
uint32_t __wasm_export_exports_runner_run_callback(uint32_t event_raw, uint32_t waitable, uint32_t code) {
  runner_event_t event;
  event.event = (runner_event_code_t) event_raw;
  event.waitable = waitable;
  event.code = code;
--

runner_subtask_status_t a_b_i_two_arguments_and_result(uint32_t x, uint32_t y, uint32_t *result) {
  return __wasm_import_a_b_i_two_arguments_and_result((int32_t) (x), (int32_t) (y), (uint8_t*) result);
}

__attribute__((__export_name__("[async-lift]run")))
int32_t __wasm_export_exports_runner_run(void) {
  runner_callback_code_t ret = exports_runner_run();
  return ret;
}

view this post on Zulip Scott Waye (Dec 08 2025 at 14:27):

with main wit-bindgen ?

view this post on Zulip Joel Dice (Dec 08 2025 at 14:27):

correct

view this post on Zulip Alex Crichton (Dec 08 2025 at 14:31):

0.48/0.49 should work the same way too

view this post on Zulip Scott Waye (Dec 08 2025 at 14:32):

Interesting, when I run target\debug\wit-bindgen.exe test --languages rust,c tests/runtime-async/async --artifacts target/artifacts --rust-wit-bindgen-path ./crates/guest-rust --runner "wasmtime -W component-model-async" I don't get that c generated. Let me debug to see where I've gone wrong

view this post on Zulip Joel Dice (Dec 08 2025 at 14:34):

Ah; I'll bet it's this directive in runner.c: //@ args = '--rename a:b/i=test --async=-run'

view this post on Zulip Joel Dice (Dec 08 2025 at 14:35):

That tells the test crate to disable async lift for the run function. When I run wit-bindgen-cli, it ignores that directive, hence the difference between my results and yours.

view this post on Zulip Joel Dice (Dec 08 2025 at 14:35):

The upshot is that [async-lift] is indeed the default, but can be overridden via --async=-run


Last updated: Jan 09 2026 at 13:15 UTC