Stream: wasmtime

Topic: Determine what world a component targets to in the host


view this post on Zulip Mossaka (Joe) (Nov 29 2023 at 22:47):

Hey there,

I am thinking about a host feature where it automatically determines if a wasm component targets a wasi:cli/command world or a wasi:http/proxy world, which I believe will be the most popular worlds that most components target to. Has anyone done similar work in wasmtime before?

I know wasm-tools component wit will output the WIT from a wasm component and it makes it really easy to compare if its wasi-http or wasi-cli or neither. But this approach does not extend to a component that targets wasi-http + some other imports (e.g. wasi-keyvalue), because it's not a match to wasi-http. Perhaps we should only check the exports of the components?

view this post on Zulip Alex Crichton (Nov 29 2023 at 22:51):

You might be interested to explore wasm-tools component targets

view this post on Zulip Mossaka (Joe) (Nov 29 2023 at 22:57):

Oh cool didn't know this exists!

view this post on Zulip Mossaka (Joe) (Nov 29 2023 at 23:10):

I conjecture that in order for the host to execute a component , the following should satisify

  1. The component WIT world INTERSECTS a known world (cli / http) is equal to that known world
  2. The component WIT world UNIONS the host world is equal to that host world

The first rule makes sure the component at least targets a known world to the host. It allows the host to select an export function (e.g. run for wasi-cli and handler for wasi-http) to execute.

The second rule allows the host to satisify all the imports of the component so it can instantiate the component and execute.


Last updated: Oct 23 2024 at 20:03 UTC