forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit is aimed at addressing bytecodealliance/wasmtime#7266 as well as a preexisting wart in wit-component. Guest bindings generators use `wit-component::metadata` to embed type information in compiled wasm modules. Currently this creates a custom section with a custom binary format. The binary format has a few prefix bytes/strings and then has a wasm-encoded WIT package with the world that was bound. The problem with this, as shown in the previous issue, is that the WIT package is possibly much larger than the world that was bound meaning that it has a lot more type information than necessary. This means that incompatibilities in interfaces that weren't actually used cause errors which is annoying to keep in sync and technically not necessary to warn/error about. This commit aims to solve two separate problems at the same time: * Type information will now be minimized storing only exactly what's needed for the bound world. * The custom section format will become an actual component without any extra headers to make extraction/debugging easier. Bindings generators currently all operate on worlds as the unit of generation, meaning that the metadata to include in this custom section is effectively a WIT world. Conveniently a WIT world can be exactly represented as a WebAssembly component types, and doubly conveniently there's already an `encode_world` function. This means that the custom section format for bindings generators is now a component which exports a single component type. The component type represents the world that was bound as part of the bindings generation process. Other minor details such as version information and string encoding selection is now stored in a custom section of the component created instead of in the header. Various guards are still in place against future versions but this should help make the format more easily debuggable and more understandable by being "simply a component" with some extra metadata. The decoding process back into a WIT world needed a few minor updates for various reasons, but otherwise this integrated well into the existing structure of `wit-component`. As with other breaking changes coming into components at this point all this new support is disabled behind an environment variable by default. The hope is to release this to get support for the new format in a number of places and then switch over to the new format by default. Eventually down the road the old format will be deleted.
- Loading branch information
1 parent
dc5c0c5
commit 7f3b472
Showing
9 changed files
with
361 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.