From a483d047de82c89a295d3fbf7ce813dfdea1ed32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Wed, 18 Jan 2023 10:45:12 +0100 Subject: [PATCH] Address review comments --- Cargo.toml | 8 ++++---- lib/c-api/Cargo.toml | 6 ------ lib/cli/Cargo.toml | 2 +- lib/cli/src/commands/run.rs | 3 +++ lib/wasi-experimental-io-devices/Cargo.toml | 2 +- lib/wasi/Cargo.toml | 6 ------ lib/wasi/src/runners/emscripten.rs | 18 ++---------------- lib/wasi/src/runners/wasi.rs | 17 ++--------------- tests/lib/wast/Cargo.toml | 2 +- tests/lib/wast/src/spectest.rs | 1 + 10 files changed, 15 insertions(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef50a99fad6..25dbdf20a83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,16 +100,16 @@ engine = ["universal"] universal = [] cache = ["wasmer-cache"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasi", "wasmer-wasi/emscripten_cranelift", "wasmer-wasi/wasi_cranelift"] +wasi = ["wasmer-wasi"] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] compiler = [ "wasmer/compiler", "wasmer-compiler/translator", ] -singlepass = ["wasmer-compiler-singlepass", "compiler", "wasmer-wasi/emscripten_singlepass", "wasmer-wasi/wasi_singlepass"] -cranelift = ["wasmer-compiler-cranelift", "compiler", "wasmer-wasi/emscripten_cranelift", "wasmer-wasi/wasi_cranelift"] -llvm = ["wasmer-compiler-llvm", "compiler", "wasmer-wasi/emscripten_llvm", "wasmer-wasi/wasi_llvm"] +singlepass = ["wasmer-compiler-singlepass", "compiler"] +cranelift = ["wasmer-compiler-cranelift", "compiler"] +llvm = ["wasmer-compiler-llvm", "compiler"] middlewares = ["wasmer-middlewares"] wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"] wasmer-artifact-create = ["wasmer-compiler/wasmer-artifact-create"] diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index a10090903b5..6f5190fa317 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -78,20 +78,14 @@ compiler-headless = [ ] singlepass = [ "wasmer-compiler-singlepass", - "wasmer-wasi/emscripten_singlepass", - "wasmer-wasi/wasi_singlepass", "compiler", ] cranelift = [ "wasmer-compiler-cranelift", - "wasmer-wasi/emscripten_cranelift", - "wasmer-wasi/wasi_cranelift", "compiler", ] llvm = [ "wasmer-compiler-llvm", - "wasmer-wasi/emscripten_llvm", - "wasmer-wasi/wasi_llvm", "compiler", ] wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"] diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 6be7a2f305e..a1960afa947 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -32,7 +32,7 @@ wasmer-compiler-singlepass = { version = "=3.1.0", path = "../compiler-singlepas wasmer-compiler-llvm = { version = "=3.1.0", path = "../compiler-llvm", optional = true } wasmer-emscripten = { version = "=3.1.0", path = "../emscripten", optional = true } wasmer-vm = { version = "=3.1.0", path = "../vm" } -wasmer-wasi = { version = "=3.1.0", path = "../wasi", features = ["emscripten_cranelift", "wasi_cranelift"], optional = true } +wasmer-wasi = { version = "=3.1.0", path = "../wasi", optional = true } wasmer-wasi-experimental-io-devices = { version = "=3.1.0", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } wasmer-wast = { version = "=3.1.0", path = "../../tests/lib/wast", optional = true } wasmer-cache = { version = "=3.1.0", path = "../cache", optional = true } diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index b53c5644475..337158aa344 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "cache")] use crate::common::get_cache_dir; #[cfg(feature = "debug")] use crate::logging; @@ -10,7 +11,9 @@ use clap::Parser; use std::collections::HashMap; use std::ops::Deref; use std::path::PathBuf; +#[cfg(feature = "cache")] use std::str::FromStr; +#[cfg(feature = "emscripten")] use wasmer::FunctionEnv; use wasmer::*; #[cfg(feature = "cache")] diff --git a/lib/wasi-experimental-io-devices/Cargo.toml b/lib/wasi-experimental-io-devices/Cargo.toml index 30f91dfd45f..2d867fe0f22 100644 --- a/lib/wasi-experimental-io-devices/Cargo.toml +++ b/lib/wasi-experimental-io-devices/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" maintenance = { status = "experimental" } [dependencies] -wasmer-wasi = { version = "=3.1.0", path = "../wasi", default-features=false, features = ["emscripten_cranelift", "wasi_cranelift"] } +wasmer-wasi = { version = "=3.1.0", path = "../wasi", default-features=false } tracing = "0.1" minifb = { version = "0.23", optional = true } nix = "0.25.0" diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index 2a15355d3c2..9c0f44e65cf 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -53,12 +53,6 @@ wasix = [] webc_runner = ["webc", "serde_cbor", "anyhow", "serde", "wasmer-vfs/webc-fs"] webc_runner_rt_emscripten = ["wasmer-emscripten"] webc_runner_rt_wasi = [] -emscripten_cranelift = ["wasmer/cranelift"] -wasi_cranelift = ["wasmer/cranelift"] -emscripten_singlepass = ["wasmer/singlepass"] -wasi_singlepass = ["wasmer/singlepass"] -emscripten_llvm = ["wasmer/llvm"] -wasi_llvm = ["wasmer/llvm"] sys = ["wasmer/sys", "wasix", "wasmer-wasi-types/sys"] sys-default = ["wasmer/wat", "wasmer/compiler", "sys", "logging", "host-fs", "sys-poll", "host-vnet" ] diff --git a/lib/wasi/src/runners/emscripten.rs b/lib/wasi/src/runners/emscripten.rs index 9dd6fa4af01..bcad14b0f10 100644 --- a/lib/wasi/src/runners/emscripten.rs +++ b/lib/wasi/src/runners/emscripten.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "webc_runner_rt_wasi")] +#![cfg(feature = "webc_runner_rt_emscripten")] //! WebC container support for running Emscripten modules use crate::runners::WapmContainer; @@ -44,21 +44,7 @@ impl crate::runners::Runner for EmscriptenRunner { let main_args = container.get_main_args_for_command(command_name); let atom_bytes = container.get_atom(&container.get_package_name(), &atom_name)?; - #[cfg(feature = "emscripten_cranelift")] - let mut store = Store::new(wasmer::Cranelift::default()); - #[cfg(feature = "emscripten_llvm")] - let mut store = Store::new(wasmer::Llvm::default()); - #[cfg(feature = "emscripten_singlepass")] - let mut store = Store::new(wasmer::Singlepass::default()); - #[cfg(not(any( - feature = "emscripten_cranelift", - feature = "emscripten_llvm", - feature = "emscripten_singlepass" - )))] - let mut store = { - return Err(anyhow::anyhow!("wasmer-wasi needs one of emscripten_cranelift or emscripten_llvm or emscripten_singlepass features enabled").into()); - }; - + let mut store = Store::default(); let mut module = Module::new(&store, atom_bytes)?; module.set_name(&atom_name); diff --git a/lib/wasi/src/runners/wasi.rs b/lib/wasi/src/runners/wasi.rs index 7a36179846d..4925b59864b 100644 --- a/lib/wasi/src/runners/wasi.rs +++ b/lib/wasi/src/runners/wasi.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "webc_runner_rt_emscripten")] +#![cfg(feature = "webc_runner_rt_wasi")] //! WebC container support for running WASI modules use crate::runners::WapmContainer; @@ -43,20 +43,7 @@ impl crate::runners::Runner for WasiRunner { let atom_name = container.get_atom_name_for_command("wasi", command_name)?; let atom_bytes = container.get_atom(&container.get_package_name(), &atom_name)?; - #[cfg(feature = "wasi_cranelift")] - let mut store = Store::new(wasmer::Cranelift::default()); - #[cfg(feature = "wasi_llvm")] - let mut store = Store::new(wasmer::Llvm::default()); - #[cfg(feature = "wasi_singlepass")] - let mut store = Store::new(wasmer::Singlepass::default()); - #[cfg(not(any( - feature = "wasi_cranelift", - feature = "wasi_llvm", - feature = "wasi_singlepass" - )))] - let mut store = { - return Err(anyhow::anyhow!("wasmer-wasi needs one of wasi_cranelift or wasi_llvm or wasi_singlepass features enabled").into()); - }; + let mut store = Store::default(); let mut module = Module::new(&store, atom_bytes)?; module.set_name(&atom_name); diff --git a/tests/lib/wast/Cargo.toml b/tests/lib/wast/Cargo.toml index 5ed6c8a7242..4d9507ae097 100644 --- a/tests/lib/wast/Cargo.toml +++ b/tests/lib/wast/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" [dependencies] anyhow = "1.0" wasmer = { path = "../../../lib/api", version = "=3.1.0", default-features = false } -wasmer-wasi = { path = "../../../lib/wasi", version = "=3.1.0", features = ["emscripten_cranelift", "wasi_cranelift"] } +wasmer-wasi = { path = "../../../lib/wasi", version = "=3.1.0" } wasmer-vfs = { path = "../../../lib/vfs", version = "=3.1.0" } wast = "38.0" serde = "1" diff --git a/tests/lib/wast/src/spectest.rs b/tests/lib/wast/src/spectest.rs index b4d44938491..7eda1b643b4 100644 --- a/tests/lib/wast/src/spectest.rs +++ b/tests/lib/wast/src/spectest.rs @@ -2,6 +2,7 @@ use wasmer::*; /// Return an instance implementing the "spectest" interface used in the /// spec testsuite. +#[allow(clippy::print_stdout)] pub fn spectest_importobject(store: &mut Store) -> Imports { let print = Function::new_typed(store, || {}); let print_i32 = Function::new_typed(store, |val: i32| println!("{}: i32", val));