Stream: wit-bindgen

Topic: world conformance


view this post on Zulip Ryan Levick (rylev) (Apr 30 2023 at 12:45):

Is there any tooling for checking whether a component conforms to a given world definition? It would be nice if the host could check this pre-instantiation for better error messaging.

view this post on Zulip Lann Martin (May 01 2023 at 13:03):

wasmtime::component::Linker::instantiate_pre should check imports, but not exports

view this post on Zulip Lann Martin (May 01 2023 at 13:21):

I suppose you could build a dummy component that imports your world, link it to your target component, then import-check that

view this post on Zulip Alex Crichton (May 01 2023 at 15:08):

If this is specifically for the host embedding I think it'd be reasonable to add logic along these lines to the Host::instantiate_pre method that's generated for each world. In addition to the import checking of instantiate_pre it could additionally verify that all the exports are present and have the expected types.

view this post on Zulip Alex Crichton (May 01 2023 at 15:09):

I'll note though that the degree of type reflection required for that isn't currently implemented in Wasmtime, but I don't think there's any major blockers to doing so, it's largely a matter of minor design and mostly elbow grease (IIRC)

view this post on Zulip Lann Martin (May 01 2023 at 15:15):

It looks like the Host::instantiate_pre methods somewhat confusingly are for instantiating InstancePres, not creating them

view this post on Zulip Lann Martin (May 01 2023 at 15:16):

err...@rylev is that what you're looking for? An explicit type-check when instantiating or without needing to instantiate?

view this post on Zulip Lann Martin (May 01 2023 at 15:17):

I may have projected the feature I want onto your request :sweat_smile:

view this post on Zulip Alex Crichton (May 01 2023 at 15:26):

oh oops right

view this post on Zulip Alex Crichton (May 01 2023 at 15:27):

we could add a different method for doing the typecheck-without-instantiating part in any case, and I don't think that it otherwise exists today in Wasmtime

view this post on Zulip Ryan Levick (rylev) (May 01 2023 at 21:52):

Correct, this would explicitly be pre-instantiation. There is generally a large amount of time for before instantiation that runtimes and wrapper tooling has to check that the binary in question will be able to run.

view this post on Zulip Ryan Levick (rylev) (May 01 2023 at 21:54):

Do we need wasmtime to do this? Is this not something that can be checked statically and thus might be more appropriate in wasm-tools?

view this post on Zulip Jamey Sharp (May 01 2023 at 22:27):

I assume the point was that wasmtime has to do all the type-checking work anyway as part of instantiation, so exposing ways to do it separately is useful. In the non-components API we've found it's useful to allow embedders to front-load that work and do it once, then skip the type-checking during instantiation after that. So a similar API for components would make sense. But having a standalone command-line type-checker sounds to me like something useful as well.

view this post on Zulip Alex Crichton (May 01 2023 at 23:15):

Do we need wasmtime to do this? Is this not something that can be checked statically and thus might be more appropriate in wasm-tools?

Currently, yes. The idea I think is given a wasmtime::component::Component an embedder can test "does this have the signature I want". That can also be done at the wasmparser level using today's APIs but adding type-reflection to components is always something I wanted to get to at some point (e.g. along the lines of the wasmtime::Module::{imports,exports} methods which allow you to inspect, without instantiating, the types involved)

view this post on Zulip Alex Crichton (May 01 2023 at 23:15):

I do agree with Jamey though and a possible wasm-tools component implements foo.wit foo.wasm could also work

view this post on Zulip Alex Crichton (May 01 2023 at 23:16):

(or something like that)

view this post on Zulip Ralph (May 03 2023 at 00:04):

I would expect that in the fullness of time people would want to know ahead of time, meaning that although wasmtime should check, the more important systemic thing would be for people to check as part of understanding what is and is not expected to run properly.

view this post on Zulip Ryan Levick (rylev) (May 03 2023 at 13:45):

Talked to @Brian about this. We're going to create an issue and maybe see if we can work on a tool.

view this post on Zulip Ryan Levick (rylev) (May 03 2023 at 13:46):

We were thinking about possibly trying to do this at the wit level

view this post on Zulip Brian (May 03 2023 at 13:53):

Created an issue track: https://github.com/bytecodealliance/wasm-tools/issues/1011

Opening this issue to track: Context: https://bytecodealliance.zulipchat.com/#narrow/stream/327223-wit-bindgen/topic/world.20conformance/near/354678021 In the thread linked above, it was suggested ...

Last updated: Nov 22 2024 at 16:03 UTC