-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove "interface imports" from binary syntax, expand accepted strings #1262
Remove "interface imports" from binary syntax, expand accepted strings #1262
Conversation
TODO items:
|
Ok I've updated with parsing of what I believe is the format of |
This commit removes the `wasmparser::ComponentExternName` type and updates wasmparser to handle WebAssembly/component-model#263. Names are now always stored as a strings and are not discriminated in the binary format. This additionally refactors the internals of `wasmparser` to handle parsed names differently and updates tools like `wit-component` to handle the new API changes. Test aren't passing yet but things are compiling at least.
Also update `wasm-encoder`'s API for the new AST.
In wasm-encoder produce the "old" encoding by default rather than the new encoding. This can get removed once enough tooling supports the "new" encoding.
4f866f9
to
b0f0f0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I'm really happy with where we landed with the strings and relaxing the restriction on conflicting names for all externs.
Just a few feedback comments.
Primarily releasing bytecodealliance#1262 to get that into the ecosystem ASAP.
Primarily releasing #1262 to get that into the ecosystem ASAP.
This commit updates the wasm-tools family of crate for a number of notable updates: * bytecodealliance/wasm-tools#1257 - wasmparser's ID-based infrastructure has been refactored to have more precise types for each ID rather than one all-purpose `TypeId`. * bytecodealliance/wasm-tools#1262 - the implementation of "implementation imports" for the component model which both updates the binary format in addition to adding more syntactic forms of imports. * bytecodealliance/wasm-tools#1260 - a new encoding scheme for component information for `wit-component` in objects (not used by Wasmtime but used by bindings generators). Translation for components needed to be updated to account for the first change, but otherwise this was a straightforward update.
* Update wasm-tools crates This commit updates the wasm-tools family of crate for a number of notable updates: * bytecodealliance/wasm-tools#1257 - wasmparser's ID-based infrastructure has been refactored to have more precise types for each ID rather than one all-purpose `TypeId`. * bytecodealliance/wasm-tools#1262 - the implementation of "implementation imports" for the component model which both updates the binary format in addition to adding more syntactic forms of imports. * bytecodealliance/wasm-tools#1260 - a new encoding scheme for component information for `wit-component` in objects (not used by Wasmtime but used by bindings generators). Translation for components needed to be updated to account for the first change, but otherwise this was a straightforward update. * Remove a TODO
Starting in WebAssembly/component-model#263 the component model binary specification was updated in a technically breaking way to encode binaries differently. This was intended to be rolled out in a manner that minimized breakage however so bytecodealliance#1262 implemented validation where the prefix byte which changed was actually ignored if it was 0 or 1. The encoder at the time still emitted 1 as the prefix byte, however. The intention was that once the validator had percolated enough the encoder would switch to using 0. Unfortunately this change was basically forgotten about until now with WebAssembly/component-model#391, but now's probably "enough time passed" so the encoder is updated to emit a 0x00 leading byte in this situation instead of the historical 0x01 byte. This will start the transition period to eventually removing the validator's acceptance of the 0x01 byte.
Starting in WebAssembly/component-model#263 the component model binary specification was updated in a technically breaking way to encode binaries differently. This was intended to be rolled out in a manner that minimized breakage however so bytecodealliance#1262 implemented validation where the prefix byte which changed was actually ignored if it was 0 or 1. The encoder at the time still emitted 1 as the prefix byte, however. The intention was that once the validator had percolated enough the encoder would switch to using 0. Unfortunately this change was basically forgotten about until now with WebAssembly/component-model#391, but now's probably "enough time passed" so the encoder is updated to emit a 0x00 leading byte in this situation instead of the historical 0x01 byte. This will start the transition period to eventually removing the validator's acceptance of the 0x01 byte.
* Proceed to the next step in the "remove `interface`" transition Starting in WebAssembly/component-model#263 the component model binary specification was updated in a technically breaking way to encode binaries differently. This was intended to be rolled out in a manner that minimized breakage however so #1262 implemented validation where the prefix byte which changed was actually ignored if it was 0 or 1. The encoder at the time still emitted 1 as the prefix byte, however. The intention was that once the validator had percolated enough the encoder would switch to using 0. Unfortunately this change was basically forgotten about until now with WebAssembly/component-model#391, but now's probably "enough time passed" so the encoder is updated to emit a 0x00 leading byte in this situation instead of the historical 0x01 byte. This will start the transition period to eventually removing the validator's acceptance of the 0x01 byte. * Update test expectation
This PR is the spiritual successor of #1146 and is an implementation of these PRs together for this repository:
This is technically a breaking change to the binary format, but the breaking change is so minor that a gradual rollout is implemented here. Previously import/export names had a discriminator byte of 0x00 or 0x01 depending on if they were a "plain name" or an "interface name". They no longer have a discriminator byte and instead always use 0x00. This means that old binaries are easily read by discarding the 0x00 or 0x01 byte. New binaries are, for now, temporarily created with the 0x01 byte still to ensure that binaries produced with this tooling is still compatible with older tooling. Once this tooling has permeated enough I plan to change the default emission to be 0x00 instead of 0x01.
The text syntax was changed in this PR as well. Previously where
(interface "a:b/c")
was printed only"a:b/c"
is printed now. Like the binary format the text format still parses the old form with the intention of being deleted eventually.Finally this PR additionally expands the set of accepted syntax within import and export strings. This now includes imports of implementations (locked/unlocked deps), imports of URLs (relative and not), and integrity-based imports.