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

@@ -126,14 +126,14 @@ use syn::parse_macro_input;
///
/// impl types::UserErrorConversion for YourCtxType {
/// fn errno_from_your_rich_error(&mut self, e: YourRichError)
/// -> Result<types::Errno, wiggle::Trap>
/// -> Result<types::Errno, wiggle::wasmtime_crate::Trap>
/// {
/// println!("Rich error: {:?}", e);
/// match e {
/// YourRichError::InvalidArg{..} => Ok(types::Errno::InvalidArg),
/// YourRichError::Io{..} => Ok(types::Errno::Io),
/// YourRichError::Overflow => Ok(types::Errno::Overflow),
/// YourRichError::Trap(s) => Err(wiggle::Trap::String(s)),
/// YourRichError::Trap(s) => Err(wiggle::wasmtime_crate::Trap::new(s)),
/// }
/// }
/// }
@@ -152,7 +152,7 @@ pub fn from_witx(args: TokenStream) -> TokenStream {
&config.errors,
&config.async_,
&doc,
cfg!(feature = "wasmtime") && config.wasmtime,
config.wasmtime,
)
.expect("validating codegen settings");
@@ -176,7 +176,6 @@ pub fn async_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
})
}
#[cfg(feature = "wasmtime")]
/// Define the structs required to integrate a Wiggle implementation with Wasmtime.
///
/// ## Arguments
@@ -190,13 +189,9 @@ pub fn wasmtime_integration(args: TokenStream) -> TokenStream {
let doc = config.c.load_document();
let names = wiggle_generate::Names::new(quote!(wiggle));
let settings = wiggle_generate::CodegenSettings::new(
&config.c.errors,
&config.c.async_,
&doc,
cfg!(feature = "wasmtime"),
)
.expect("validating codegen settings");
let settings =
wiggle_generate::CodegenSettings::new(&config.c.errors, &config.c.async_, &doc, true)
.expect("validating codegen settings");
let modules = doc.modules().map(|module| {
wiggle_generate::wasmtime::link_module(&module, &names, Some(&config.target), &settings)