jrandolf opened PR #14873 from jrandolf:named-imports-lookup-api to bytecodealliance:main:
This builds on #14867, so only the last two commits are new here.
It reworks the
named_importslookup thatbindgen!generates:
- The lookup gets the import's
ComponentExternnext to its name, so it can useexternal-id, which the spec intends for telling the host how to supply an import. Before, it only got the name.- The lookup returns
Result<Option<Id>>.Ok(None)skips the import, leaving it to be defined some other way, e.g. withadd_to_linker_instanceordefine_unknown_imports_as_traps. Before, the only way to not bind an import was to fail linking.- Tracing records the label. The named
add_to_linker_instancenow also takes the import's name, which traced functions record aslabelin their spans. Before,a.getandb.getlogged identical spans.- Clear errors for label keys. A
with,imports,named_importsortrappable_error_typekey that names a labelled import (e.g."a"or"a.get") used to give a misleading "not referenced" or "unused rules" error. It now explains that labelled imports share their interface's bindings and are configured through the interface's name. The docs now describe how keys work for labelled imports vs labelled exports.wasmtime-wasi's and wasmtime-wasi-http's
add_named_to_linkerfunctions take the same lookup, with theInterfaceas an extra first argument. This is a breaking change, but these APIs only matter withimplements, which is unstable and off by default.Tracing for labelled imports without
named_importsstill looks the same for every label. Those all go through the one sharedadd_to_linker_instance, which doesn't know the name, and changing that would touch every generated interface.#14872 changes the same generated
add_to_linkerloop, so whichever lands second will need a rebase.Closes #14860
Last updated: Oct 31 2026 at 23:03 UTC