Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ wasmtime-unwinder = { workspace = true }
wasmtime-wizer = { workspace = true, optional = true, features = ['clap', 'wasmtime'] }
clap = { workspace = true }
clap_complete = { workspace = true, optional = true }
anyhow = { workspace = true, features = ['std'] }
target-lexicon = { workspace = true }
listenfd = { version = "1.0.0", optional = true }
wat = { workspace = true, optional = true }
Expand Down Expand Up @@ -139,9 +138,6 @@ windows-sys = { workspace = true, features = ["Win32_System_Memory"] }
[target.'cfg(unix)'.dev-dependencies]
rustix = { workspace = true, features = ["param"] }

[build-dependencies]
anyhow = { workspace = true, features = ['std'] }

[profile.release.build-override]
opt-level = 0

Expand Down
1 change: 0 additions & 1 deletion benches/instantiation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow::Result;
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use std::cell::LazyCell;
use std::path::Path;
Expand Down
1 change: 0 additions & 1 deletion benches/trap.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow::Result;
use criterion::*;
use wasmtime::*;

Expand Down
3 changes: 1 addition & 2 deletions examples/component/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use anyhow::Context;
use std::{fs, path::Path};

use wasmtime::{
Config, Engine, Result, Store,
component::{Component, HasSelf, Linker, bindgen},
error::Context as _,
};

// Generate bindings of the guest and host components.
Expand Down
2 changes: 1 addition & 1 deletion examples/epochs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! an example of setup for asynchronous usage, see
//! `tests/all/epoch_interruption.rs`

use anyhow::Error;
use std::sync::Arc;
use wasmtime::Error;
use wasmtime::{Config, Engine, Instance, Module, Store};

fn main() -> Result<(), Error> {
Expand Down
4 changes: 2 additions & 2 deletions examples/fast_instantiation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Tuning Wasmtime for fast instantiation.

use anyhow::anyhow;
use wasmtime::format_err;
use wasmtime::{
Config, Engine, InstanceAllocationStrategy, Linker, Module, PoolingAllocationConfig, Result,
Store,
Expand Down Expand Up @@ -85,7 +85,7 @@ fn main() -> Result<()> {

// Wait for the threads to finish.
for h in handles.into_iter() {
h.join().map_err(|_| anyhow!("thread panicked!"))??;
h.join().map_err(|_| format_err!("thread panicked!"))??;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion examples/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() -> Result<()> {
// load_fn up our exports from the instance
let memory = instance
.get_memory(&mut store, "memory")
.ok_or(anyhow::format_err!("failed to find `memory` export"))?;
.ok_or(wasmtime::format_err!("failed to find `memory` export"))?;
let size = instance.get_typed_func::<(), i32>(&mut store, "size")?;
let load_fn = instance.get_typed_func::<i32, i32>(&mut store, "load")?;
let store_fn = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store")?;
Expand Down
20 changes: 10 additions & 10 deletions examples/mpk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
//! $ sysctl vm.max_map_count=$LARGER_LIMIT
//! ```

use anyhow::anyhow;
use bytesize::ByteSize;
use clap::Parser;
use log::{info, warn};
use std::str::FromStr;
use wasmtime::format_err;
use wasmtime::*;

fn main() -> Result<()> {
Expand Down Expand Up @@ -84,7 +84,7 @@ struct Args {
/// Parse a human-readable byte size--e.g., "512 MiB"--into the correct number
/// of bytes.
fn parse_byte_size(value: &str) -> Result<u64> {
let size = ByteSize::from_str(value).map_err(|e| anyhow!(e))?;
let size = ByteSize::from_str(value).map_err(|e| format_err!(e))?;
Ok(size.as_u64())
}

Expand Down Expand Up @@ -239,15 +239,15 @@ fn num_bytes_mapped() -> Result<usize> {
let range = line
.split_whitespace()
.next()
.ok_or(anyhow!("parse failure: expected whitespace"))?;
.ok_or(format_err!("parse failure: expected whitespace"))?;
let mut addresses = range.split("-");
let start = addresses
.next()
.ok_or(anyhow!("parse failure: expected dash-separated address"))?;
let start = addresses.next().ok_or(format_err!(
"parse failure: expected dash-separated address"
))?;
let start = usize::from_str_radix(start, 16)?;
let end = addresses
.next()
.ok_or(anyhow!("parse failure: expected dash-separated address"))?;
let end = addresses.next().ok_or(format_err!(
"parse failure: expected dash-separated address"
))?;
let end = usize::from_str_radix(end, 16)?;

total += end - start;
Expand All @@ -257,5 +257,5 @@ fn num_bytes_mapped() -> Result<usize> {

#[cfg(not(target_os = "linux"))]
fn num_bytes_mapped() -> Result<usize> {
anyhow::bail!("this example can only read virtual memory maps on Linux")
wasmtime::bail!("this example can only read virtual memory maps on Linux")
}
2 changes: 1 addition & 1 deletion examples/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// You can execute this example with `cargo run --example multi`

use anyhow::Result;
use wasmtime::Result;

fn main() -> Result<()> {
use wasmtime::*;
Expand Down
4 changes: 2 additions & 2 deletions examples/multimemory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ fn main() -> Result<()> {

let memory0 = instance
.get_memory(&mut store, "memory0")
.ok_or(anyhow::format_err!("failed to find `memory0` export"))?;
.ok_or(wasmtime::format_err!("failed to find `memory0` export"))?;
let size0 = instance.get_typed_func::<(), i32>(&mut store, "size0")?;
let load0 = instance.get_typed_func::<i32, i32>(&mut store, "load0")?;
let store0 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store0")?;

let memory1 = instance
.get_memory(&mut store, "memory1")
.ok_or(anyhow::format_err!("failed to find `memory1` export"))?;
.ok_or(wasmtime::format_err!("failed to find `memory1` export"))?;
let size1 = instance.get_typed_func::<(), i32>(&mut store, "size1")?;
let load1 = instance.get_typed_func::<i32, i32>(&mut store, "load1")?;
let store1 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store1")?;
Expand Down
2 changes: 1 addition & 1 deletion examples/tokio/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Error;
use std::sync::Arc;
use tokio::time::Duration;
use wasmtime::Error;
use wasmtime::{Config, Engine, Linker, Module, Store};
use wasmtime_wasi::{WasiCtx, p1::WasiP1Ctx};

Expand Down
2 changes: 1 addition & 1 deletion examples/wasip1-async/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You can execute this example with:
cargo run --example wasip1-async
*/

use anyhow::Result;
use wasmtime::Result;
use wasmtime::{Config, Engine, Linker, Module, Store};
use wasmtime_wasi::WasiCtx;
use wasmtime_wasi::p1::{self, WasiP1Ctx};
Expand Down
2 changes: 1 addition & 1 deletion examples/wasip2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ fn main() -> Result<()> {
let (result,) = typed.call(&mut store, ())?;
// Required, see documentation of TypedFunc::call
typed.post_return(&mut store)?;
result.map_err(|_| anyhow::anyhow!("error"))
result.map_err(|_| wasmtime::format_err!("error"))
}
2 changes: 1 addition & 1 deletion src/bin/wasmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! Primarily used to run WebAssembly modules.
//! See `wasmtime --help` for usage.

use anyhow::Result;
use clap::Parser;
use wasmtime::Result;

/// Wasmtime WebAssembly Runtime
#[derive(Parser)]
Expand Down
3 changes: 1 addition & 2 deletions src/commands/compile.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! The module that implements the `wasmtime compile` command.

use anyhow::{Context, Result, bail};
use clap::Parser;
use std::fs;
use std::path::PathBuf;
use wasmtime::{CodeBuilder, CodeHint, Engine};
use wasmtime::{CodeBuilder, CodeHint, Engine, Result, bail, error::Context as _};
use wasmtime_cli_flags::CommonOptions;

const AFTER_HELP: &str =
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The module that implements the `wasmtime config` command.

use anyhow::Result;
use clap::{Parser, Subcommand};
use wasmtime::Result;

const CONFIG_NEW_AFTER_HELP: &str =
"If no file path is specified, the system configuration file path will be used.";
Expand Down
3 changes: 1 addition & 2 deletions src/commands/explore.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! The module that implements the `wasmtime explore` command.

use anyhow::{Context, Result};
use clap::Parser;
use std::{borrow::Cow, path::PathBuf};
use tempfile::tempdir;
use wasmtime::Strategy;
use wasmtime::{Result, Strategy, error::Context as _};
use wasmtime_cli_flags::CommonOptions;

/// Explore the compilation of a WebAssembly module to native code.
Expand Down
3 changes: 1 addition & 2 deletions src/commands/objdump.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Implementation of the `wasmtime objdump` CLI command.

use anyhow::{Context, Result, bail};
use capstone::InsnGroupType::{CS_GRP_JUMP, CS_GRP_RET};
use clap::Parser;
use cranelift_codegen::isa::lookup_by_name;
Expand All @@ -14,7 +13,7 @@ use std::io::{IsTerminal, Read, Write};
use std::iter::{self, Peekable};
use std::path::{Path, PathBuf};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use wasmtime::Engine;
use wasmtime::{Engine, Result, bail, error::Context as _};
use wasmtime_environ::{
FilePos, FrameInstPos, FrameStackShape, FrameStateSlot, FrameTable, FrameTableDescriptorIndex,
StackMap, Trap, obj,
Expand Down
22 changes: 12 additions & 10 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
)]

use crate::common::{Profile, RunCommon, RunTarget};
use anyhow::{Context as _, Error, Result, anyhow, bail};
use clap::Parser;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::thread;
use wasi_common::sync::{Dir, TcpListener, WasiCtxBuilder, ambient_authority};
use wasmtime::{Engine, Func, Module, Store, StoreLimits, Val, ValType};
use wasmtime::{
Engine, Error, Func, Module, Result, Store, StoreLimits, Val, ValType, bail,
error::Context as _, format_err,
};
use wasmtime_wasi::{WasiCtxView, WasiView};

#[cfg(feature = "wasi-config")]
Expand Down Expand Up @@ -284,7 +286,7 @@ impl RunCommand {

// Load the main wasm module.
let instance = match result.unwrap_or_else(|elapsed| {
Err(anyhow::Error::from(wasmtime::Trap::Interrupt))
Err(wasmtime::Error::from(wasmtime::Trap::Interrupt))
.with_context(|| format!("timed out after {elapsed}"))
}) {
Ok(instance) => instance,
Expand Down Expand Up @@ -333,7 +335,7 @@ impl RunCommand {
};
result.push(
arg.to_str()
.ok_or_else(|| anyhow!("failed to convert {arg:?} to utf-8"))?
.ok_or_else(|| format_err!("failed to convert {arg:?} to utf-8"))?
.to_string(),
);
}
Expand Down Expand Up @@ -456,7 +458,7 @@ impl RunCommand {
let profiler = Arc::try_unwrap(store.data_mut().guest_profiler.take().unwrap())
.expect("profiling doesn't support threads yet");
if let Err(e) = std::fs::File::create(&path)
.map_err(anyhow::Error::new)
.map_err(wasmtime::Error::new)
.and_then(|output| profiler.finish(std::io::BufWriter::new(output)))
{
eprintln!("failed writing profile at {path}: {e:#}");
Expand Down Expand Up @@ -530,7 +532,7 @@ impl RunCommand {
Some(
instance
.get_func(&mut *store, name)
.ok_or_else(|| anyhow!("no func export named `{name}` found"))?,
.ok_or_else(|| format_err!("no func export named `{name}` found"))?,
)
} else {
instance
Expand Down Expand Up @@ -623,7 +625,7 @@ impl RunCommand {
.run_concurrent(async |store| {
let task = func.call_concurrent(store, &params, &mut results).await?;
task.block(store).await;
anyhow::Ok(())
wasmtime::error::Ok(())
})
.await??;
}
Expand Down Expand Up @@ -758,7 +760,7 @@ impl RunCommand {
};
let val = val
.to_str()
.ok_or_else(|| anyhow!("argument is not valid utf-8: {val:?}"))?;
.ok_or_else(|| format_err!("argument is not valid utf-8: {val:?}"))?;
values.push(match ty {
// Supports both decimal and hexadecimal notation (with 0x prefix)
ValType::I32 => Val::I32(if val.starts_with("0x") || val.starts_with("0X") {
Expand Down Expand Up @@ -1106,7 +1108,7 @@ impl RunCommand {
None => match std::env::var_os(key) {
Some(val) => val
.into_string()
.map_err(|_| anyhow!("environment variable `{key}` not valid utf-8"))?,
.map_err(|_| format_err!("environment variable `{key}` not valid utf-8"))?,
None => {
// leave the env var un-set in the guest
continue;
Expand Down Expand Up @@ -1311,7 +1313,7 @@ fn ctx_set_listenfd(mut num_fd: usize, builder: &mut WasiCtxBuilder) -> Result<u
#[cfg(feature = "coredump")]
fn write_core_dump(
store: &mut Store<Host>,
err: &anyhow::Error,
err: &wasmtime::Error,
name: &str,
path: &str,
) -> Result<()> {
Expand Down
Loading