Update WIT tooling used by Wasmtime (#5565)

* Update WIT tooling used by Wasmtime

This commit updates the WIT tooling, namely the wasm-tools family of
crates, with recent updates. Notably:

* bytecodealliance/wasm-tools#867
* bytecodealliance/wasm-tools#871

This updates index spaces in components and additionally bumps the
minimum required version of the component binary format to be consumed
by Wasmtime (because of the index space changes). Additionally WIT
tooling now fully supports `use`.

Note that WIT tooling doesn't, at this time, fully support packages and
depending on remotely defined WIT packages. Currently WIT still needs to
be vendored in the project. It's hoped that future work with `cargo
component` and possible integration here could make the story about
depending on remotely-defined WIT more ergonomic and streamlined.

* Fix `bindgen!` codegen tests

* Add a test for `use` paths an implement support

* Update to crates.io versions of wasm-tools

* Uncomment codegen tests
This commit is contained in:
Alex Crichton
2023-01-18 09:37:03 -06:00
committed by GitHub
parent 9b896d2a70
commit 247851234b
35 changed files with 1192 additions and 546 deletions

View File

@@ -5,8 +5,7 @@ interface chars {
return-char: func() -> char
}
world the-world {
import imports: chars
export exports: chars
default export chars
default world the-world {
import imports: self.chars
export exports: self.chars
}

View File

@@ -32,8 +32,7 @@ interface conventions {
%bool: func()
}
world the-world {
import imports: conventions
export exports: conventions
default export conventions
default world the-world {
import imports: self.conventions
export exports: self.conventions
}

View File

@@ -1 +1 @@
world empty {}
default world empty {}

View File

@@ -47,8 +47,7 @@ interface flegs {
roundtrip-flag64: func(x: flag64) -> flag64
}
world the-flags {
import import-flags: flegs
export export-flags: flegs
default export flegs
default world the-flags {
import import-flags: self.flegs
export export-flags: self.flegs
}

View File

@@ -5,8 +5,7 @@ interface floats {
float64-result: func() -> float64
}
world the-world {
import imports: floats
export exports: floats
default export floats
default world the-world {
import imports: self.floats
export exports: self.floats
}

View File

@@ -32,8 +32,7 @@ interface integers {
pair-ret: func() -> tuple<s64, u8>
}
world the-world {
import imports: integers
export exports: integers
default export integers
default world the-world {
import imports: self.integers
export exports: self.integers
}

View File

@@ -77,8 +77,7 @@ interface lists {
load-store-everything: func(a: load-store-all-sizes) -> load-store-all-sizes
}
world the-lists {
import import-lists: lists
export export-lists: lists
default export lists
default world the-lists {
import import-lists: self.lists
export export-lists: self.lists
}

View File

@@ -44,8 +44,7 @@ interface manyarg {
big-argument: func(x: big-struct)
}
world the-world {
import imports: manyarg
export exports: manyarg
default export manyarg
default world the-world {
import imports: self.manyarg
export exports: self.manyarg
}

View File

@@ -6,8 +6,7 @@ interface multi-return {
mre: func() -> (a: u32, b: float32)
}
world the-world {
import imports: multi-return
export exports: multi-return
default export multi-return
default world the-world {
import imports: self.multi-return
export exports: self.multi-return
}

View File

@@ -53,8 +53,7 @@ interface records {
typedef-inout: func(e: tuple-typedef2) -> s32
}
world the-world {
import imports: records
export exports: records
default export records
default world the-world {
import imports: self.records
export exports: self.records
}

View File

@@ -9,8 +9,7 @@ interface simple {
f6: func(a: u32, b: u32, c: u32) -> tuple<u32, u32, u32>
}
world the-world {
import imports: simple
export exports: simple
default export simple
default world the-world {
import imports: self.simple
export exports: self.simple
}

View File

@@ -1,13 +1,11 @@
interface simple-lists {
simple-list1: func(l: list<u32>)
simple-list2: func() -> list<u32>
// TODO: reenable this when smw implements this
// simple-list3: func(a: list<u32>, b: list<u32>) -> tuple<list<u32>, 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>>
}
world my-world {
import imports: simple-lists
export exports: simple-lists
default export simple-lists
default world my-world {
import imports: self.simple-lists
export exports: self.simple-lists
}

View File

@@ -7,8 +7,7 @@ interface anon {
option-test: func() -> result<option<string>, error>
}
world the-world {
import imports: anon
export exports: anon
default export anon
default world the-world {
import imports: self.anon
export exports: self.anon
}

View File

@@ -1,5 +1,3 @@
world the-world {
default export interface {
y: func()
}
default world the-world {
export y: func()
}

View File

@@ -1,4 +1,4 @@
world the-world {
default world the-world {
export the-name: interface {
y: func()
}

View File

@@ -1,4 +1,4 @@
world the-world {
default world the-world {
import imports: interface {
y: func()
}

View File

@@ -4,8 +4,7 @@ interface strings {
c: func(a: string, b: string) -> string
}
world the-world {
import imports: strings
export exports: strings
default export strings
default world the-world {
import imports: self.strings
export exports: self.strings
}

View File

@@ -58,8 +58,7 @@ interface unions {
identify-distinguishable-num: func(num: distinguishable-num) -> u8
}
world the-unions {
import import-unions: unions
export export-unions: unions
default export unions
default world the-unions {
import import-unions: self.unions
export export-unions: self.unions
}

View File

@@ -0,0 +1,27 @@
interface a {
record foo {}
a: func() -> foo
}
interface b {
use self.a.{foo}
a: func() -> foo
}
interface c {
use self.b.{foo}
a: func() -> foo
}
default world d {
import a: self.a
import b: self.b
import d: interface {
use self.c.{foo}
b: func() -> foo
}
}

View File

@@ -139,8 +139,7 @@ interface variants {
return-named-result: func() -> (a: result<u8, my-errno>)
}
world my-world {
import imports: variants
export exports: variants
default export variants
default world my-world {
import imports: self.variants
export exports: self.variants
}