Skip to content

Conversation

@alexcrichton
Copy link
Member

This PR integrates bytecodealliance/wasm-tools#1027 into Wasmtime. The main changes here are:

This PR disables wasi-http tests and the on-by-default feature because the WIT syntax has been updated but the submodule containing the WITs has not been updated yet so there's no way to get that building temporarily. Once that's updated then this can be reenabled.

@alexcrichton
Copy link
Member Author

I'll note that I'm opening this as a draft as I'm working my way up the stack. My goal is to prove out bytecodealliance/wasm-tools#1027 and once everything is ready have a day I spend landing the various changes.

This PR integrates bytecodealliance/wasm-tools#1027 into Wasmtime. The
main changes here are:

* WIT syntax is updated with WebAssembly/component-model#193
* Generated bindings in the `bindgen!` macro have been updated to
  reflect the new structure of WIT.
* The accepted component model binary format has been updated to account
  for changes.

This PR disables wasi-http tests and the on-by-default feature because
the WIT syntax has been updated but the submodule containing the WITs
has not been updated yet so there's no way to get that building
temporarily. Once that's updated then this can be reenabled.
Don't store duplicates with the rest of the WASI WIT files we have.
@alexcrichton alexcrichton marked this pull request as ready for review May 25, 2023 21:07
@alexcrichton alexcrichton requested review from a team as code owners May 25, 2023 21:07
@alexcrichton alexcrichton requested review from elliottt and jameysharp and removed request for a team May 25, 2023 21:07
@alexcrichton
Copy link
Member Author

Ok I've now updated this for the final set of merged changes to wasm-tools, which aren't yet published. The major changes in this PR are now:

  • All wasm-tools deps are updated (currently sitting at git deps to my "bump" branch)
  • WIT syntax is changing, as well as the binary format of components
  • All WIT files vendored in this repository are updated to the new syntax. Notably the wasi-http WITs are not updated because they're a submodule. This means that all wasi-http-related tests and support are disabled.
  • There is now only one copy of WIT for WASI, and all other duplicate copies are deleted.
  • All of the preview2 implementation has been updated for the new hierarchy of modules created by wasmtime::component::bindgen!

One interesting aspect of this is that there's a temporary git dependency on wit-bindgen. I'm not actually sure how to get rid of that because the adapter requires wit-bindgen and it's not easy to remove that. This is somewhat ok though since we don't publish anything with wit-bindgen so I'm hoping it's ok to have a temporary state of affairs with a git dep here before I can go use this PR to update wit-bindgen to make a release there.

@alexcrichton alexcrichton removed request for a team and elliottt May 25, 2023 21:10
Make it a more "official" location which is also less likely to be
accidentally deleted in the future.
@alexcrichton alexcrichton enabled auto-merge May 26, 2023 14:21
@alexcrichton alexcrichton added this pull request to the merge queue May 26, 2023
@alexcrichton alexcrichton removed this pull request from the merge queue due to a manual request May 26, 2023
@alexcrichton alexcrichton enabled auto-merge May 26, 2023 15:01
@alexcrichton alexcrichton added this pull request to the merge queue May 26, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch May 26, 2023
@alexcrichton alexcrichton enabled auto-merge May 26, 2023 16:07
@alexcrichton alexcrichton added this pull request to the merge queue May 26, 2023
Merged via the queue into bytecodealliance:main with commit 41417d9 May 26, 2023
@alexcrichton alexcrichton deleted the wit-changes branch May 26, 2023 17:13
@rvolosatovs
Copy link
Member

rvolosatovs commented May 31, 2023

Seems like a component using latest WIT interfaces generated with wit-component 0.11.0 fails to compile with:

    0: failed to parse WebAssembly module
    1: unsupported component version: 0xc (at offset 0x0)

Originating somewhere in

pub fn translate(
mut self,
component: &'data [u8],
) -> Result<(
Component,
PrimaryMap<StaticModuleIndex, ModuleTranslation<'data>>,
)> {
// First up wasmparser is used to actually perform the translation and
// validation of this component. This will produce a list of core wasm
// modules in addition to components which are found during the
// translation process. When doing this only a `Translation` is created
// which is a simple representation of a component.
let mut remaining = component;
loop {
let payload = match self.parser.parse(remaining, true)? {
Chunk::Parsed { payload, consumed } => {
remaining = &remaining[consumed..];
payload
}
Chunk::NeedMoreData(_) => unreachable!(),
};
match self.translate_payload(payload, component)? {
Action::KeepGoing => {}
Action::Skip(n) => remaining = &remaining[n..],
Action::Done => break,
}
}
assert!(remaining.is_empty());
assert!(self.lexical_scopes.is_empty());
// ... after translation initially finishes the next pass is performed
// which we're calling "inlining". This will "instantiate" the root
// component, following nested component instantiations, creating a
// global list of initializers along the way. This phase uses the simple
// initializers in each component to track dataflow of host imports and
// internal references to items throughout a component at compile-time.
// The produce initializers in the final `Component` are intended to be
// much simpler than the original component and more efficient for
// Wasmtime to process at runtime as well (e.g. no string lookups as
// most everything is done through indices instead).
let mut component = inline::run(
&self.types,
&self.result,
&self.static_modules,
&self.static_components,
)?;
self.partition_adapter_modules(&mut component);
Ok((component.finish(), self.static_modules))
}

Refs wasmCloud/wasmCloud#347

@alexcrichton
Copy link
Member Author

Can you confirm that wit-component 0.11.0 was used? The version 0xc is the "old" version of components and the upgraded versions should be 0xd, so it may be the case that wit-component 0.11.0 wasn't used by accident?

@rvolosatovs
Copy link
Member

Can you confirm that wit-component 0.11.0 was used? The version 0xc is the "old" version of components and the upgraded versions should be 0xd, so it may be the case that wit-component 0.11.0 wasn't used by accident?

I'll try to minimize this later today

@rvolosatovs
Copy link
Member

Can you confirm that wit-component 0.11.0 was used? The version 0xc is the "old" version of components and the upgraded versions should be 0xd, so it may be the case that wit-component 0.11.0 wasn't used by accident?

false alarm, it was an outdated transitive dependency. Can confirm that everything works as expected. Thanks for prompt response!

salewski pushed a commit to salewski/wasmtime that referenced this pull request Jun 30, 2023
* Update Wasmtime for upcoming WIT changes

This PR integrates bytecodealliance/wasm-tools#1027 into Wasmtime. The
main changes here are:

* WIT syntax is updated with WebAssembly/component-model#193
* Generated bindings in the `bindgen!` macro have been updated to
  reflect the new structure of WIT.
* The accepted component model binary format has been updated to account
  for changes.

This PR disables wasi-http tests and the on-by-default feature because
the WIT syntax has been updated but the submodule containing the WITs
has not been updated yet so there's no way to get that building
temporarily. Once that's updated then this can be reenabled.

* Update wasmtime-wasi crate with new WIT

* Add wit-bindgen override for the updated version

* Officially disable wasi-http tests/building

* Move test-reactor WIT into the main WIT files

Don't store duplicates with the rest of the WASI WIT files we have.

* Remove adapter's copy of WIT files

* Disable default features for wit-bindgen

* Plumb disabling wasi-http tests a bit more

* Fix reactor tests and adapter build

* Remove no-longer-needed feature

* Update adapter verification script

* Back out some wasi-http hacks

* Update vet and some dependency sources

* Move where wit-bindgen comes from

Make it a more "official" location which is also less likely to be
accidentally deleted in the future.
salewski pushed a commit to salewski/wasmtime that referenced this pull request Jun 30, 2023
* Update Wasmtime for upcoming WIT changes

This PR integrates bytecodealliance/wasm-tools#1027 into Wasmtime. The
main changes here are:

* WIT syntax is updated with WebAssembly/component-model#193
* Generated bindings in the `bindgen!` macro have been updated to
  reflect the new structure of WIT.
* The accepted component model binary format has been updated to account
  for changes.

This PR disables wasi-http tests and the on-by-default feature because
the WIT syntax has been updated but the submodule containing the WITs
has not been updated yet so there's no way to get that building
temporarily. Once that's updated then this can be reenabled.

* Update wasmtime-wasi crate with new WIT

* Add wit-bindgen override for the updated version

* Officially disable wasi-http tests/building

* Move test-reactor WIT into the main WIT files

Don't store duplicates with the rest of the WASI WIT files we have.

* Remove adapter's copy of WIT files

* Disable default features for wit-bindgen

* Plumb disabling wasi-http tests a bit more

* Fix reactor tests and adapter build

* Remove no-longer-needed feature

* Update adapter verification script

* Back out some wasi-http hacks

* Update vet and some dependency sources

* Move where wit-bindgen comes from

Make it a more "official" location which is also less likely to be
accidentally deleted in the future.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jul 26, 2023
These files aren't actually read by anything currently. They were added
historically and a previous refactoring in bytecodealliance#6390 forgot to remove them.
No tests or build process reads them so this deletes them to get them
out of the way.
github-merge-queue bot pushed a commit that referenced this pull request Jul 26, 2023
#6777)

* Remove unused WIT files from Wasmtime

These files aren't actually read by anything currently. They were added
historically and a previous refactoring in #6390 forgot to remove them.
No tests or build process reads them so this deletes them to get them
out of the way.

* Update dependencies on wasm-tools crates.

This commit updates the deps on the wasm-tools family of crates to bring
in a few fixes for WIT/component-related things. Primarily though this
brings in an update to the component model where empty types are now
disallowed.

Some tests using empty types were adjusted to use non-empty types, but
many tests were also simply removed as they existed to test what would
happen with empty types which now no longer needs to be tested.

* Update `stream-error` in preview2

Add a `dummy` field to make it a non-empty structure. It's expected that
this will change to something else more "official" in the future, but
for now this is here to keep everything compiling.

* Update component fuzzing to avoid empty types

Empty types are no longer valid

* Update crates/wasi/wit/deps/io/streams.wit

Co-authored-by: Peter Huene <peter@huene.dev>

---------

Co-authored-by: Peter Huene <peter@huene.dev>
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Aug 18, 2023
bytecodealliance#6777)

* Remove unused WIT files from Wasmtime

These files aren't actually read by anything currently. They were added
historically and a previous refactoring in bytecodealliance#6390 forgot to remove them.
No tests or build process reads them so this deletes them to get them
out of the way.

* Update dependencies on wasm-tools crates.

This commit updates the deps on the wasm-tools family of crates to bring
in a few fixes for WIT/component-related things. Primarily though this
brings in an update to the component model where empty types are now
disallowed.

Some tests using empty types were adjusted to use non-empty types, but
many tests were also simply removed as they existed to test what would
happen with empty types which now no longer needs to be tested.

* Update `stream-error` in preview2

Add a `dummy` field to make it a non-empty structure. It's expected that
this will change to something else more "official" in the future, but
for now this is here to keep everything compiling.

* Update component fuzzing to avoid empty types

Empty types are no longer valid

* Update crates/wasi/wit/deps/io/streams.wit

Co-authored-by: Peter Huene <peter@huene.dev>

---------

Co-authored-by: Peter Huene <peter@huene.dev>
rvolosatovs pushed a commit to rvolosatovs/wasi-io that referenced this pull request Aug 24, 2023
)

* Update Wasmtime for upcoming WIT changes

This PR integrates bytecodealliance/wasm-tools#1027 into Wasmtime. The
main changes here are:

* WIT syntax is updated with WebAssembly/component-model#193
* Generated bindings in the `bindgen!` macro have been updated to
  reflect the new structure of WIT.
* The accepted component model binary format has been updated to account
  for changes.

This PR disables wasi-http tests and the on-by-default feature because
the WIT syntax has been updated but the submodule containing the WITs
has not been updated yet so there's no way to get that building
temporarily. Once that's updated then this can be reenabled.

* Update wasmtime-wasi crate with new WIT

* Add wit-bindgen override for the updated version

* Officially disable wasi-http tests/building

* Move test-reactor WIT into the main WIT files

Don't store duplicates with the rest of the WASI WIT files we have.

* Remove adapter's copy of WIT files

* Disable default features for wit-bindgen

* Plumb disabling wasi-http tests a bit more

* Fix reactor tests and adapter build

* Remove no-longer-needed feature

* Update adapter verification script

* Back out some wasi-http hacks

* Update vet and some dependency sources

* Move where wit-bindgen comes from

Make it a more "official" location which is also less likely to be
accidentally deleted in the future.

* Don't document wasi-http-tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:wasm cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants