jrandolf opened PR #14917 from jrandolf:wasi-named-imports-sync to bytecodealliance:main:
This builds on #14875 and #14916, so only the last commit is new here.
Named imports were only supported with the async bindings of wasmtime-wasi and wasmtime-wasi-http. This adds
wasmtime_wasi::p2::add_named_to_linker_syncandwasmtime_wasi_http::p2::add_named_to_linker_sync(each with a_with_optionsvariant). I didn't find a technical reason these were left out. The sync bindings alias most interfaces to the async ones, and the rest have sync implementations that the named ones can call.Part of #14858
<details>
<summary>LLM summary of the changes</summary>Bindings (
wasi/src/p2/bindings.rs)The sync bindings get
named_importsfor the interfaces they don't alias to the async bindings:wasi:io/{poll,streams},wasi:filesystem/types, andwasi:sockets/{tcp,udp,udp-create-socket,ip-name-lookup}. The generatednamed_importsmodule is re-exported frombindings::sync.Linking (
wasi/src/p2/mod.rs,wasi-http/src/p2/mod.rs)
- A new
add_named_nonblocking_to_linkeradds the interfaces that both variants share, taken from the async bindings.add_named_to_linker_with_options_asyncand the newadd_named_to_linker_with_options_synceach add the rest from the async or sync bindings. This is the same split as the unlabelledadd_to_linker_with_options_{async,sync}.- wasmtime-wasi-http gets
add_named_to_linker_syncandadd_named_to_linker_with_options_sync. None of itswasi:httpfunctions are async, which is also why its sync bindings alias the async ones, so these call the async variants.Implementation
For each interface above, the sync named implementation looks up the context for the id and calls the existing sync implementation. That covers
p2/host/io.rs,filesystem/sync.rs,tcp.rs,udp.rs,udp_create_socket.rs,ip_name_lookup.rsandpoll.rs.Interaction with #14873
#14873 changes the signature of the
add_named_to_linkerlookup. Whichever of the two lands second needs to port the new functions, which is mechanical.Tests
- The labelled
wasi:iotest from #14916 also runs with the sync bindings.- A comment in wasmtime-wasi-http's sync tests now says why they don't cover named imports: the sync function calls the async one, which
async_.rstests.</details>
jrandolf commented on PR #14917:
Closing: #14275 left named imports out of the sync bindings on purpose, and nothing needs them, so this isn't worth the extra code.
:cross_mark: jrandolf closed without merge PR #14917.
Last updated: Oct 31 2026 at 23:03 UTC