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:
@@ -5,9 +5,7 @@ use std::sync::Arc;
|
||||
|
||||
pub use wiggle_macro::{async_trait, from_witx};
|
||||
|
||||
#[cfg(feature = "wasmtime")]
|
||||
pub use anyhow;
|
||||
#[cfg(feature = "wasmtime")]
|
||||
pub use wiggle_macro::wasmtime_integration;
|
||||
|
||||
pub use bitflags;
|
||||
@@ -30,10 +28,7 @@ pub mod async_trait_crate {
|
||||
pub use async_trait::*;
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasmtime")]
|
||||
pub mod wasmtime;
|
||||
|
||||
#[cfg(feature = "wasmtime")]
|
||||
pub mod wasmtime_crate {
|
||||
pub use wasmtime::*;
|
||||
}
|
||||
@@ -914,26 +909,14 @@ impl Pointee for str {
|
||||
}
|
||||
}
|
||||
|
||||
/// A runtime-independent way for Wiggle to terminate WebAssembly execution.
|
||||
/// Functions that are marked `(@witx noreturn)` will always return a Trap.
|
||||
/// Other functions that want to Trap can do so via their `UserErrorConversion`
|
||||
/// trait, which transforms the user's own error type into a `Result<abierror, Trap>`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Trap {
|
||||
/// A Trap which indicates an i32 (posix-style) exit code. Runtimes may have a
|
||||
/// special way of dealing with this for WASI embeddings and otherwise.
|
||||
I32Exit(i32),
|
||||
/// Any other Trap is just an unstructured String, for reporting and debugging.
|
||||
String(String),
|
||||
}
|
||||
|
||||
impl From<GuestError> for Trap {
|
||||
fn from(err: GuestError) -> Trap {
|
||||
Trap::String(err.to_string())
|
||||
impl From<GuestError> for wasmtime_crate::Trap {
|
||||
fn from(err: GuestError) -> wasmtime_crate::Trap {
|
||||
wasmtime_crate::Trap::from(
|
||||
Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasmtime")]
|
||||
pub fn run_in_dummy_executor<F: std::future::Future>(
|
||||
future: F,
|
||||
) -> Result<F::Output, wasmtime_crate::Trap> {
|
||||
|
||||
Reference in New Issue
Block a user