jrandolf opened PR #14920 from jrandolf:wasi-tls-named-imports to bytecodealliance:main:
Components importing
wasi:tlsinterfaces under a label couldn't be linked with wasmtime-wasi-tls. This addsadd_named_to_linkerto bothp2andp3, following the named-import support in wasmtime-wasi (#14275).Most of the diff is in p3:
send,receiveandconnectuseAccess/Accessor, whose getters can't close over aNamedId. So their bodies move into functions that are generic over the getter, and the named and unnamed implementations share them.Part of #14858
<details>
<summary>LLM summary of the changes</summary>API
WasiTlsNamedViewmaps aNamedIdto theWasiTlsCtxViewto use.p2::InterfacehasTlsTypes, andp3::InterfacehasTlsClientandTlsTypes.p2::add_named_to_linkerandp3::add_named_to_linkeradd every labelled import of those interfaces that the component has, askinglookupfor each one's id.Implementation
- The p2 and p3 bindings get
named_imports. Each named method looks up the context for the id and calls the existing implementation.- In p3, the
Access/Accessorgetters are plain function pointers, so they can't capture aNamedId. The bodies ofsend,receiveandconnectmove into free functions that are generic over the getter. They're unchanged except thatstore.get()becomesgetter(store.data_mut()). The unnamed implementations passstore.getter(), and the named ones pass a closure that also selects the context for the id.ResultProducerstores a generic getter instead of a function pointer, so it works with both.Interaction with #14873
#14873 changes the signature of the
add_named_to_linkerlookup. Whichever of the two lands second needs to port these functions, which is mechanical.Tests
p2_tls_named_importsandp3_tls_named_importsrun new guest programs with two labelled imports. Each label's provider fails every handshake with its own name, which shows which context a call used.- They need no network, and run once instead of once per TLS provider.
</details>
jrandolf commented on PR #14920:
Closing: nobody needs labelled
wasi:tlsimports yet, andwasi:tlsisn't part of a WASI release. Happy to revisit if someone asks.
:cross_mark: jrandolf closed without merge PR #14920.
Last updated: Oct 31 2026 at 23:03 UTC