wiggle: make wasmtime a mandatory dep, get rid of own Trap enum (#5137)

* wiggle: no longer need to guard wasmtime integration behind a feature

this existed so we could use wiggle in lucet, but lucet is long EOL

* replace wiggle::Trap with wiggle::wasmtime_crate::Trap

* wiggle tests: unwrap traps because we cant assert_eq on them

* wasi-common: emit a wasmtime::Trap instead of a wiggle::Trap

formally add a dependency on wasmtime here to make it obvious, though
we do now have a transitive one via wiggle no matter what (and therefore
can get rid of the default-features=false on the wiggle dep)

* wasi-nn: use wasmtime::Trap instead of wiggle::Trap

there's no way the implementation of this func is actually
a good idea, it will panic the host process on any error,
but I'll ask @mtr to fix that

* wiggle test-helpers examples: fixes

* wasi-common cant cross compile to wasm32-unknown-emscripten anymore

this was originally for the WASI polyfill for web targets. Those days
are way behind us now.

* wasmtime wont compile for armv7-unknown-linux-gnueabihf either
This commit is contained in:
Pat Hickey
2022-10-27 09:28:10 -07:00
committed by GitHub
parent b20128a6cb
commit 0290a83502
30 changed files with 147 additions and 155 deletions

View File

@@ -118,9 +118,10 @@ impl SumOfPairExercise {
&host_memory,
self.input_loc.ptr as i32,
self.return_loc.ptr as i32,
);
)
.unwrap();
assert_eq!(sum_err, Ok(types::Errno::Ok as i32), "sum errno");
assert_eq!(sum_err, types::Errno::Ok as i32, "sum errno");
let return_val: i64 = host_memory
.ptr(self.return_loc.ptr)
@@ -216,13 +217,10 @@ impl SumPairPtrsExercise {
&host_memory,
self.input_struct_loc.ptr as i32,
self.return_loc.ptr as i32,
);
)
.unwrap();
assert_eq!(
res,
Ok(types::Errno::Ok as i32),
"sum of pair of ptrs errno"
);
assert_eq!(res, types::Errno::Ok as i32, "sum of pair of ptrs errno");
let doubled: i64 = host_memory
.ptr(self.return_loc.ptr)
@@ -299,9 +297,10 @@ impl SumIntAndPtrExercise {
&host_memory,
self.input_struct_loc.ptr as i32,
self.return_loc.ptr as i32,
);
)
.unwrap();
assert_eq!(res, Ok(types::Errno::Ok as i32), "sum of int and ptr errno");
assert_eq!(res, types::Errno::Ok as i32, "sum of int and ptr errno");
let doubled: i64 = host_memory
.ptr(self.return_loc.ptr)
@@ -338,9 +337,10 @@ impl ReturnPairInts {
let mut ctx = WasiCtx::new();
let host_memory = HostMemory::new();
let err = records::return_pair_ints(&mut ctx, &host_memory, self.return_loc.ptr as i32);
let err =
records::return_pair_ints(&mut ctx, &host_memory, self.return_loc.ptr as i32).unwrap();
assert_eq!(err, Ok(types::Errno::Ok as i32), "return struct errno");
assert_eq!(err, types::Errno::Ok as i32, "return struct errno");
let return_struct: types::PairInts = host_memory
.ptr(self.return_loc.ptr)
@@ -418,13 +418,10 @@ impl ReturnPairPtrsExercise {
self.input_first_loc.ptr as i32,
self.input_second_loc.ptr as i32,
self.return_loc.ptr as i32,
);
)
.unwrap();
assert_eq!(
res,
Ok(types::Errno::Ok as i32),
"return pair of ptrs errno"
);
assert_eq!(res, types::Errno::Ok as i32, "return pair of ptrs errno");
let ptr_pair_int_ptrs: types::PairIntPtrs<'_> = host_memory
.ptr(self.return_loc.ptr)
@@ -529,10 +526,11 @@ impl SumArrayExercise {
&host_memory,
self.input_struct_loc.ptr as i32,
self.output_loc.ptr as i32,
);
)
.unwrap();
// should be no error - if hostcall did a GuestError it should eprintln it.
assert_eq!(res, Ok(types::Errno::Ok as i32), "reduce excuses errno");
assert_eq!(res, types::Errno::Ok as i32, "reduce excuses errno");
// Sum is inputs upcasted to u16
let expected: u16 = self.inputs.iter().map(|v| *v as u16).sum();