chenyan2002 opened PR #14372 from chenyan2002:canon-ver to bytecodealliance:main:
Part of https://github.com/bytecodealliance/wasmtime/issues/14346
Add
canonical_namesflag to wit-bindgen. When both guest and host enable canonical names, the linker should work by string matching.Eventually, we will enable this in
wasmtime-wasi, but that requires changes toNameMap, which will be a future PR.
chenyan2002 requested pchickey for a review on PR #14372.
chenyan2002 requested wasmtime-core-reviewers for a review on PR #14372.
:memo: Voyagerroc-Lab submitted PR review:
Review summary
The new canonical_names option is threaded through macro parsing, generated linker world names, generated interface IDs, and the runtime linker helper. The added end-to-end test exercises a canonicalized imported interface against a component whose import uses the canonical version and verifies the host call result.
One coverage gap remains: the test does not exercise an exported interface name or a world with a versioned exported interface, although interface_id_of is also changed for that path. Please consider adding that case before treating the option as fully covered. This is not a blocking issue for the imported-interface behavior covered here.
alexcrichton commented on PR #14372:
Thinking more on the original issue, personally I don't think that this is the best way to go to integrate the canonical-names feature. I alluded to this a bit in my comment on #14346 but I don't think the
bindgen!option makes sense here because embedders don't have an answer of whether to use it or not, especially during a transition period. I think it'd be best to support this entirely withinNameMapand that way bindings are always "full version" and theNameMaphandles everything else.Wasmtime should still gate loading components with canonical names based on the
Configfeature (as it already does), but after that everything in the runtime can basically assumed it's turned on soNameMapcan just change to assuming canonical-names should always work.
chenyan2002 commented on PR #14372:
I agree, during the transition period,
NameMapis the only place that needs to change. But after the transition period (probably after a long time), I expectNameMapto be just a regularHashMapwithout thealternative_look_up. And we expect that the host API to have canonical names as well. Do you expect thatcanonicalized_id_ofandid_ofwould merge at some point, so that this change can happen automatically?Another use case is when using
wasmtimeas a library, and providing our own host APIs, we can enable canonical names for both host and guest at the same time, so that linking only relies on string equality. This feels simpler than relying on the bi-directional map fromNameMap.
alexcrichton commented on PR #14372:
Maybe in the super long-term yeah, but for the medium-term we'll want today's components with non-canonical names to continue to work. That may not require the full implementation within
NameMaptoday, butalternative_look_upwill need to stick around in one form or another. Over time though I agree that this PR would be landed and happen unconditionally with no way to turn off once we're confident in the various changes toNameMapand impact on the host. For embedders, that makes sense, yeah, but we'd still have to in this repository make a decision for WASI APIs which doesn't feel great.Overall my opinion is that there shouldn't be a canonical-names option on the host side. To implement that I'd see 2 ways to do so:
- First is what I've described where
bindgen!does full versions andNameMaphandles everything internally.- Alternatively this PR would land un-gated where everything is defined with a canonical key and
NameMapwould handle queries of full versions to as-if they looked up the canonical keyI don't have a preference either way myself, and (2) is more future-facing yeah so might make sense.
:cross_mark: chenyan2002 closed without merge PR #14372.
Last updated: Oct 11 2026 at 04:10 UTC