Skip to content

Commit

Permalink
Update Wasmtime for upcoming WIT changes (#6390)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
alexcrichton authored May 26, 2023
1 parent c8e8097 commit f8a89f2
Show file tree
Hide file tree
Showing 117 changed files with 1,303 additions and 2,269 deletions.
188 changes: 67 additions & 121 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,18 @@ io-lifetimes = { version = "1.0.0", default-features = false }
rustix = "0.37.13"

# wit-bindgen:
wit-bindgen = "0.6.0"
wit-bindgen = { version = "0.7.0", default-features = false }

# wasm-tools family:
wasmparser = "0.105.0"
wat = "1.0.64"
wast = "58.0.0"
wasmprinter = "0.2.57"
wasm-encoder = "0.27.0"
wasm-smith = "0.12.8"
wasm-mutate = "0.2.25"
wit-parser = "0.7.1"
wit-component = "0.9.0"
wasmparser = "0.107.0"
wat = "1.0.66"
wast = "60.0.0"
wasmprinter = "0.2.59"
wasm-encoder = "0.29.0"
wasm-smith = "0.12.10"
wasm-mutate = "0.2.27"
wit-parser = "0.8.0"
wit-component = "0.11.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down Expand Up @@ -248,7 +248,8 @@ default = [
"vtune",
"wasi-nn",
"wasi-threads",
"wasi-http",
# TODO: the WIT needs to be updated
#"wasi-http",
"pooling-allocator",
]
jitdump = ["wasmtime/jitdump"]
Expand Down Expand Up @@ -311,3 +312,5 @@ debug-assertions = false
# string initializers.
overflow-checks = false

[patch.crates-io]
wit-bindgen = { git = 'https://github.com/bytecodealliance/wit-bindgen', branch = 'wasmtime-2023-05-26-wit-changes' }
3 changes: 3 additions & 0 deletions cranelift/wasm/src/sections_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ pub fn parse_type_section<'a>(
Type::Func(wasm_func_ty) => {
environ.declare_type_func(wasm_func_ty.clone().try_into()?)?;
}
Type::Array(_) => {
unimplemented!("gc proposal");
}
}
}
Ok(())
Expand Down
26 changes: 13 additions & 13 deletions crates/component-macro/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,24 @@ impl Parse for Config {
if inline.is_some() {
return Err(Error::new(s.span(), "cannot specify a second source"));
}
inline = Some(format!("default world interfaces {{ {} }}", s.value()));
inline = Some(format!(
"
package wasmtime:component-macro-synthesized
world interfaces {{
{}
}}
",
s.value()
));

if world.is_some() {
return Err(Error::new(
s.span(),
"cannot specify a world with `interfaces`",
));
}
world = Some("macro-input.interfaces".to_string());
world = Some("interfaces".to_string());

opts.only_interfaces = true;
}
Expand Down Expand Up @@ -130,7 +139,7 @@ fn parse_source(
} else {
let pkg = UnresolvedPackage::parse_file(path)?;
files.extend(pkg.source_files().map(|s| s.to_owned()));
resolve.push(pkg, &Default::default())
resolve.push(pkg)
}
};

Expand All @@ -141,16 +150,7 @@ fn parse_source(
};

let inline_pkg = if let Some(inline) = inline {
let deps = resolve
.packages
.iter()
.map(|(id, p)| (p.name.clone(), id))
.collect();

Some(resolve.push(
UnresolvedPackage::parse("macro-input".as_ref(), &inline)?,
&deps,
)?)
Some(resolve.push(UnresolvedPackage::parse("macro-input".as_ref(), &inline)?)?)
} else {
None
};
Expand Down
6 changes: 0 additions & 6 deletions crates/component-macro/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ macro_rules! gentest {
mod sugar {
wasmtime::component::bindgen!(in $path);
}
mod normal {
wasmtime::component::bindgen!($name in $path);
}
mod async_ {
wasmtime::component::bindgen!({
path: $path,
Expand All @@ -16,15 +13,12 @@ macro_rules! gentest {
mod tracing {
wasmtime::component::bindgen!({
path: $path,
world: $name,
tracing: true,
duplicate_if_necessary: true,
});
}
}
// ...
};

}

component_macro_test_helpers::foreach!(gentest);
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/char.wit
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package foo:foo

interface chars {
/// A function that accepts a character
take-char: func(x: char)
/// A function that returns a character
return-char: func() -> char
}

default world the-world {
import imports: self.chars
export exports: self.chars
world the-world {
import chars
export chars
}
7 changes: 4 additions & 3 deletions crates/component-macro/tests/codegen/conventions.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// hello 🐱 world
package foo:foo

interface conventions {
kebab-case: func()
Expand Down Expand Up @@ -32,7 +33,7 @@ interface conventions {
%bool: func()
}

default world the-world {
import imports: self.conventions
export exports: self.conventions
world the-world {
import conventions
export conventions
}
4 changes: 3 additions & 1 deletion crates/component-macro/tests/codegen/direct-import.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
default world foo {
package foo:foo

world foo {
import foo: func()
}
3 changes: 2 additions & 1 deletion crates/component-macro/tests/codegen/empty.wit
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
default world empty {}
package foo:foo
world empty {}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/flags.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface flegs {
flags flag1 {
b0,
Expand Down Expand Up @@ -47,7 +49,7 @@ interface flegs {
roundtrip-flag64: func(x: flag64) -> flag64
}

default world the-flags {
import import-flags: self.flegs
export export-flags: self.flegs
world the-flags {
import flegs
export flegs
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/floats.wit
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package foo:foo

interface floats {
float32-param: func(x: float32)
float64-param: func(x: float64)
float32-result: func() -> float32
float64-result: func() -> float64
}

default world the-world {
import imports: self.floats
export exports: self.floats
world the-world {
import floats
export floats
}
3 changes: 2 additions & 1 deletion crates/component-macro/tests/codegen/function-new.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
default world foo {
package foo:foo
world foo {
export new: func()
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/integers.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface integers {
a1: func(x: u8)
a2: func(x: s8)
Expand Down Expand Up @@ -32,7 +34,7 @@ interface integers {
pair-ret: func() -> tuple<s64, u8>
}

default world the-world {
import imports: self.integers
export exports: self.integers
world the-world {
import integers
export integers
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/lists.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface lists {
list-u8-param: func(x: list<u8>)
list-u16-param: func(x: list<u16>)
Expand Down Expand Up @@ -77,7 +79,7 @@ interface lists {
load-store-everything: func(a: load-store-all-sizes) -> load-store-all-sizes
}

default world the-lists {
import import-lists: self.lists
export export-lists: self.lists
world the-lists {
import lists
export lists
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/many-arguments.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface manyarg {
many-args: func(
a1: u64,
Expand Down Expand Up @@ -44,7 +46,7 @@ interface manyarg {
big-argument: func(x: big-struct)
}

default world the-world {
import imports: self.manyarg
export exports: self.manyarg
world the-world {
import manyarg
export manyarg
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/multi-return.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface multi-return {
mra: func()
mrb: func() -> ()
Expand All @@ -6,7 +8,7 @@ interface multi-return {
mre: func() -> (a: u32, b: float32)
}

default world the-world {
import imports: self.multi-return
export exports: self.multi-return
world the-world {
import multi-return
export multi-return
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/records.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface records {
tuple-arg: func(x: tuple<char, u32>)
tuple-result: func() -> tuple<char, u32>
Expand Down Expand Up @@ -53,7 +55,7 @@ interface records {
typedef-inout: func(e: tuple-typedef2) -> s32
}

default world the-world {
import imports: self.records
export exports: self.records
world the-world {
import records
export records
}
10 changes: 6 additions & 4 deletions crates/component-macro/tests/codegen/rename.wit
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package foo:foo

interface red {
use self.green.{thing}
use green.{thing}

foo: func() -> thing
}
Expand All @@ -8,7 +10,7 @@ interface green {
type thing = s32
}

default world neptune {
import blue: self.red
import orange: self.green
world neptune {
import red
import green
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/share-types.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface http-types{
record request {
method: string
Expand All @@ -7,13 +9,13 @@ interface http-types{
}
}

default world http-interface {
world http-interface {
export http-handler: interface {
use self.http-types.{request,response}
use http-types.{request,response}
handle-request: func(request: request) -> response
}
import http-fetch: interface {
use self.http-types.{request,response}
use http-types.{request,response}
fetch-request: func(request: request) -> response
}
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/simple-functions.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface simple {
f1: func()
f2: func(a: u32)
Expand All @@ -9,7 +11,7 @@ interface simple {
f6: func(a: u32, b: u32, c: u32) -> tuple<u32, u32, u32>
}

default world the-world {
import imports: self.simple
export exports: self.simple
world the-world {
import simple
export simple
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/simple-lists.wit
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package foo:foo

interface simple-lists {
simple-list1: func(l: list<u32>)
simple-list2: func() -> list<u32>
simple-list3: func(a: list<u32>, b: list<u32>) -> tuple<list<u32>, list<u32>>
simple-list4: func(l: list<list<u32>>) -> list<list<u32>>
}

default world my-world {
import imports: self.simple-lists
export exports: self.simple-lists
world my-world {
import simple-lists
export simple-lists
}
8 changes: 5 additions & 3 deletions crates/component-macro/tests/codegen/simple-wasi.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package foo:foo

interface wasi-filesystem {
record descriptor-stat {
}
Expand All @@ -15,7 +17,7 @@ interface wall-clock {
}
}

default world wasi {
import wasi-filesystem: self.wasi-filesystem
import wall-clock: self.wall-clock
world wasi {
import wasi-filesystem
import wall-clock
}
Loading

0 comments on commit f8a89f2

Please sign in to comment.