jrandolf opened PR #14916 from jrandolf:wasi-io-named-imports to bytecodealliance:main:
This builds on #14875, so only the last commit is new here.
wasmtime_wasi::p2::add_named_to_linker_asyncdidn't handle labelled imports ofwasi:io/{error,poll,streams}, so components importing them under a label, such as composed components whose dependencies are isolated from each other, failed to link. This adds them.wasi:iohas no state besides the resource table, so each method looks up the table for the import's context and callswasmtime-wasi-io.
wasi:clocks/timezoneis still not covered, since wasmtime-wasi doesn't implement it at all.Part of #14858
<details>
<summary>LLM summary of the changes</summary>Bindings (
wasi/src/p2/bindings.rs)
wasi:io/{error,poll,streams}are added to thenamed_importsof the async bindings. They get the sameasync/trappable/tracingrules as inwasmtime-wasi-io. Without labels these interfaces are aliased towasmtime-wasi-iowithwith, so the rules only affect the named bindings. The resource types are the same as for unlabelled imports.Linking (
wasi/src/p2/mod.rs)
InterfacegetsIoError,IoPollandIoStreams, andadd_named_to_linker_with_options_asyncadds the three interfaces through a newHasIoNameddata type.Implementation (
wasi/src/p2/host/io.rs)Each method of
error,pollandstreamslooks upctx(id).tableand calls the correspondingwasmtime-wasi-iomethod, includingconvert_stream_error, which needs the id from #14875. As documented for named WASI contexts, a stream created through one label and used through another only works if their contexts share aResourceTable.Test (
wasi/tests/all/p2)A component imports
wasi:cli/stdoutand thewasi:iointerfaces it uses under labels, and checks that output goes to the labelled context's stdout. It's written in WAT because a labelledwasi:cli/stdoutusing types from labelledwasi:ioimports can't be written in WIT.</details>
jrandolf has marked PR #14916 as ready for review.
jrandolf removed the review request for wasmtime-wasi-reviewers from PR #14916.
jrandolf requested rvolosatovs for a review on PR #14916.
jrandolf requested wasmtime-wasi-reviewers for a review on PR #14916.
jrandolf requested pchickey for a review on PR #14916.
jrandolf removed the review request for wasmtime-core-reviewers from PR #14916.
jrandolf requested wasmtime-core-reviewers for a review on PR #14916.
Last updated: Oct 31 2026 at 23:03 UTC