Stream: git-wasmtime

Topic: wasmtime / issue #13190 bindgen: Emit component type in g...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2026 at 17:54):

lann opened issue #13190:

There are cases where it would be helpful to have access to the component type associated with bindgen!ed code, like allowing component type checking without separate WIT bookkeeping or the creation of an engine/component/linker/store to test instantiation.

Guest wit-bindgen embeds this information in the component-type custom section for use by wasm-component-ld; I'd like to do something similar for wasmtime bindgen, roughly:

let encoded = wit_component::metadata::encode(
    resolve,
    world_id,
    wit_component::StringEncoding::UTF8,
    None,
)?;
uwriteln!(self.src, "pub const COMPONENT_TYPE: &[u8] = &{encoded:?};");

If there is a compelling reason for it this could be gated by a bindgen opt but the const will disappear if it doesn't get used so I'm not sure if that is necessary.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2026 at 17:59):

lann edited issue #13190:

There are cases where it would be helpful to have access to the component type associated with bindgen!ed code, like allowing component type checking without separate WIT bookkeeping or the creation of an engine/component/linker/store to test instantiation.

Guest wit-bindgen embeds this information in the component-type custom section for use by wasm-component-ld; I'd like to do something similar for wasmtime bindgen, roughly:

let encoded = wit_component::metadata::encode(
    resolve,
    world_id,
    wit_component::StringEncoding::UTF8,
    None,
)?;
uwriteln!(self.src, "pub const COMPONENT_TYPE: &[u8] = &{encoded:?};");

which would allow the host to reconstruct the component type:

let wit_component::metadata::Bindgen {
    resolve,
    world,
    ..
} = wit_component::metadata::decode(generated::bindings::COMPONENT_TYPE)?;

If there is a compelling reason for it this could be gated by a bindgen opt but the const will disappear if it doesn't get used so I'm not sure if that is necessary.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2026 at 21:54):

pchickey commented on issue #13190:

That seems harmless enough, I guess?

Is there a straightforward way to get a wasmtime::component::types::Component out of the bindgen at the moment?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2026 at 13:12):

lann commented on issue #13190:

Is there a straightforward way to get a wasmtime::component::types::Component out of the bindgen at the moment?

I don't think so. IIRC the underlying data for that is constructed during validation.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2026 at 21:21):

alexcrichton added the wasm-proposal:component-model label to Issue #13190.


Last updated: May 03 2026 at 22:13 UTC