Skip to content

Develop a plugin interface for the CLI #7348

@alexcrichton

Description

@alexcrichton

Currently the wasmtime CLI comes pre-bundled with WASI functionality and optionally enabled proposals such as wasi-{http,nn,...}. Beyond this though that's it, there's no further abilty to load host funtionality into wasm modules. A question that's been asked in the past of us is if it's possible to have a plugin-style functionality for loading new host interfaces into the CLI for wasm modules to use. Historically this has been a question that hasn't really had an answer as it's not clear how best to implement this. Nowadays though with the component model this is at least more clear to me and I wanted to file an issue for this. This is a bit of a pie-in-the-sky issue where it's probably good to collect discussion on.

Another motivation I would have for functionality like this is that it makes it easier to produce a minimal Wasmtime executable. Producing a minimal executable can be helpful from the perspective of evaluating Wasmtime where CI artifacts can be reviewed to determine if Wasmtime is suitable for a particular use case or not. Currently the Wasmtime CLI "min" executable artifact contains all of WASI, but it doesn't make sense to remove it really because then you can't really do anything with the resulting executable other than look at it. With a plugin-style interface though it would be possible to use the "min" executable, provide custom host WASI implementations (or totally custom APIs), and get a working system out of it. Even if it's not the final working system that an embedding settles upon this could be an important milestone in terms of developing and proving something works.

Overall I don't at least personally have a super-well-fleshed out idea of where to take this. One rough idea is that WIT can serve as a good basis for the component model at least. For example one could imagine that given a WIT file a C header file is generated which represents the plugin API that Wasmtime expects to dynamically load. (or something like that) For core wasm it could be something similar-ish but with a direct translation from core wasm signatures to C signatures. This would still be significant chunk of work though to design further than this.

In any case I wanted to write down some thoughts on this, especially in relation to the "min build" use case. If others have thoughts or use cases I hope to collect them over time here as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions