diff --git a/lib/api/src/sys/store.rs b/lib/api/src/sys/store.rs index 032b6c60d23..6f7cf6ac9fd 100644 --- a/lib/api/src/sys/store.rs +++ b/lib/api/src/sys/store.rs @@ -174,18 +174,17 @@ impl Default for Store { fn get_engine() -> Engine { cfg_if::cfg_if! { if #[cfg(feature = "compiler")] { - - cfg_if::cfg_if! { - if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))] - { - let config = get_config(); - EngineBuilder::new(Box::new(config) as Box) - .engine() - } else { - EngineBuilder::headless() - .engine() + cfg_if::cfg_if! { + if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))] + { + let config = get_config(); + EngineBuilder::new(Box::new(config) as Box) + .engine() + } else { + EngineBuilder::headless() + .engine() + } } - } } else { compile_error!("No default engine chosen") } diff --git a/lib/cli/src/cli.rs b/lib/cli/src/cli.rs index be137ce53a0..5b65f312951 100644 --- a/lib/cli/src/cli.rs +++ b/lib/cli/src/cli.rs @@ -6,14 +6,13 @@ use crate::commands::Binfmt; use crate::commands::Compile; #[cfg(any(feature = "static-artifact-create", feature = "wasmer-artifact-create"))] use crate::commands::CreateExe; -#[cfg(feature = "static-artifact-create")] -use crate::commands::CreateObj; #[cfg(feature = "wast")] use crate::commands::Wast; use crate::commands::{ - Add, Cache, Config, GenCHeader, Init, Inspect, List, Login, Publish, Run, SelfUpdate, Validate, - Whoami, + Add, Cache, Config, Init, Inspect, List, Login, Publish, Run, SelfUpdate, Validate, Whoami, }; +#[cfg(feature = "static-artifact-create")] +use crate::commands::{CreateObj, GenCHeader}; use crate::error::PrettyError; use clap::{CommandFactory, ErrorKind, Parser}; @@ -130,6 +129,7 @@ enum WasmerCLIOptions { CreateObj(CreateObj), /// Generate the C static_defs.h header file for the input .wasm module + #[cfg(feature = "static-artifact-create")] GenCHeader(GenCHeader), /// Get various configuration information needed @@ -181,6 +181,7 @@ impl WasmerCLIOptions { Self::List(list) => list.execute(), Self::Login(login) => login.execute(), Self::Publish(publish) => publish.execute(), + #[cfg(feature = "static-artifact-create")] Self::GenCHeader(gen_heder) => gen_heder.execute(), #[cfg(feature = "wast")] Self::Wast(wast) => wast.execute(), diff --git a/lib/cli/src/commands.rs b/lib/cli/src/commands.rs index a70d8d42db2..fa241435f1b 100644 --- a/lib/cli/src/commands.rs +++ b/lib/cli/src/commands.rs @@ -10,6 +10,7 @@ mod config; mod create_exe; #[cfg(feature = "static-artifact-create")] mod create_obj; +#[cfg(feature = "static-artifact-create")] mod gen_c_header; mod init; mod inspect; @@ -29,19 +30,18 @@ pub use binfmt::*; pub use compile::*; #[cfg(any(feature = "static-artifact-create", feature = "wasmer-artifact-create"))] pub use create_exe::*; -#[cfg(feature = "static-artifact-create")] -pub use create_obj::*; use serde::{Deserialize, Serialize}; #[cfg(feature = "wast")] pub use wast::*; pub use { - add::*, cache::*, config::*, gen_c_header::*, init::*, inspect::*, list::*, login::*, - publish::*, run::*, self_update::*, validate::*, whoami::*, + add::*, cache::*, config::*, init::*, inspect::*, list::*, login::*, publish::*, run::*, + self_update::*, validate::*, whoami::*, }; +#[cfg(feature = "static-artifact-create")] +pub use {create_obj::*, gen_c_header::*}; /// The kind of object format to emit. #[derive(Debug, Copy, Clone, PartialEq, Eq, clap::Parser, Serialize, Deserialize)] -#[cfg(any(feature = "static-artifact-create", feature = "wasmer-artifact-create"))] pub enum ObjectFormat { /// Serialize the entire module into an object file. Serialized, diff --git a/lib/cli/src/commands/create_exe.rs b/lib/cli/src/commands/create_exe.rs index c804aa86823..7eb6f0362e2 100644 --- a/lib/cli/src/commands/create_exe.rs +++ b/lib/cli/src/commands/create_exe.rs @@ -1,6 +1,7 @@ //! Create a standalone native executable for a given Wasm file. use super::ObjectFormat; +use crate::common::normalize_path; use crate::store::CompilerOptions; use anyhow::{Context, Result}; use clap::Parser; @@ -224,6 +225,7 @@ impl CreateExe { } let (_, compiler_type) = self.compiler.get_store_for_target(target.clone())?; + println!("Compiler: {}", compiler_type.to_string()); println!("Target: {}", target.triple()); println!("Format: {:?}", object_format); @@ -231,6 +233,7 @@ impl CreateExe { "Using path `{}` as libwasmer path.", cross_compilation.library.display() ); + if !cross_compilation.library.exists() { return Err(anyhow::anyhow!("library path does not exist")); } @@ -967,16 +970,16 @@ fn get_module_infos( let mut module_infos = BTreeMap::new(); for (atom_name, atom_bytes) in atoms { - let store = Store::default(); - let module = Module::from_binary(&store, atom_bytes.as_slice()) - .map_err(|e| anyhow::anyhow!("could not deserialize module {atom_name}: {e}"))?; + let module_info = Engine::get_module_info(atom_bytes.as_slice()) + .map_err(|e| anyhow::anyhow!("could not get module info for atom {atom_name}: {e}"))?; + if let Some(s) = entrypoint .atoms .iter_mut() .find(|a| a.atom.as_str() == atom_name.as_str()) { - s.module_info = Some(module.info().clone()); - module_infos.insert(atom_name.clone(), module.info().clone()); + s.module_info = Some(module_info.clone()); + module_infos.insert(atom_name.clone(), module_info.clone()); } } @@ -1279,20 +1282,16 @@ fn link_exe_from_dir( cmd.args(files_winsdk); } - println!("running cmd: {cmd:?}"); + if debug { + println!("running cmd: {cmd:?}"); + cmd.stdout(Stdio::inherit()); + cmd.stderr(Stdio::inherit()); + } let compilation = cmd - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) .output() .context(anyhow!("Could not execute `zig`: {cmd:?}"))?; - println!( - "file {} exists: {:?}", - out_path.display(), - out_path.exists() - ); - if !compilation.status.success() { return Err(anyhow::anyhow!(String::from_utf8_lossy( &compilation.stderr @@ -1302,7 +1301,6 @@ fn link_exe_from_dir( // remove file if it exists - if not done, can lead to errors on copy let output_path_normalized = normalize_path(&format!("{}", output_path.display())); - println!("removing {output_path_normalized}"); let _ = std::fs::remove_file(&output_path_normalized); std::fs::copy( &normalize_path(&format!("{}", out_path.display())), @@ -1319,10 +1317,6 @@ fn link_exe_from_dir( Ok(()) } -pub(crate) fn normalize_path(s: &str) -> String { - s.strip_prefix(r"\\?\").unwrap_or(s).to_string() -} - /// Link compiled objects using the system linker #[allow(clippy::too_many_arguments)] fn link_objects_system_linker( diff --git a/lib/cli/src/commands/create_obj.rs b/lib/cli/src/commands/create_obj.rs index b369590984d..15f5a5c041c 100644 --- a/lib/cli/src/commands/create_obj.rs +++ b/lib/cli/src/commands/create_obj.rs @@ -11,9 +11,6 @@ use std::path::PathBuf; use wasmer::*; -#[cfg(feature = "webc_runner")] -use webc::{ParseOptions, WebCMmap}; - #[derive(Debug, Parser)] /// The options for the `wasmer create-exe` subcommand pub struct CreateObj { @@ -73,7 +70,7 @@ pub struct CreateObj { impl CreateObj { /// Runs logic for the `create-obj` subcommand pub fn execute(&self) -> Result<()> { - let path = crate::commands::create_exe::normalize_path(&format!("{}", self.path.display())); + let path = crate::common::normalize_path(&format!("{}", self.path.display())); let target_triple = self.target_triple.clone().unwrap_or_else(Triple::host); let starting_cd = env::current_dir()?; let input_path = starting_cd.join(&path); @@ -98,31 +95,32 @@ impl CreateObj { println!("Target: {}", target.triple()); println!("Format: {:?}", object_format); - let atoms = - if let Ok(pirita) = WebCMmap::parse(input_path.clone(), &ParseOptions::default()) { - crate::commands::create_exe::compile_pirita_into_directory( - &pirita, - &output_directory_path, - &self.compiler, - &self.cpu_features, - &target_triple, - object_format, - &prefix, - crate::commands::AllowMultiWasm::Reject(self.atom.clone()), - self.debug_dir.is_some(), - ) - } else { - crate::commands::create_exe::prepare_directory_from_single_wasm_file( - &input_path, - &output_directory_path, - &self.compiler, - &target_triple, - &self.cpu_features, - object_format, - &prefix, - self.debug_dir.is_some(), - ) - }?; + let atoms = if let Ok(pirita) = + webc::WebCMmap::parse(input_path.clone(), &webc::ParseOptions::default()) + { + crate::commands::create_exe::compile_pirita_into_directory( + &pirita, + &output_directory_path, + &self.compiler, + &self.cpu_features, + &target_triple, + object_format, + &prefix, + crate::commands::AllowMultiWasm::Reject(self.atom.clone()), + self.debug_dir.is_some(), + ) + } else { + crate::commands::create_exe::prepare_directory_from_single_wasm_file( + &input_path, + &output_directory_path, + &self.compiler, + &target_triple, + &self.cpu_features, + object_format, + &prefix, + self.debug_dir.is_some(), + ) + }?; // Copy output files into target path, depending on whether // there are one or many files being compiled diff --git a/lib/cli/src/commands/gen_c_header.rs b/lib/cli/src/commands/gen_c_header.rs index 4ddff10d8b2..2a309af21a6 100644 --- a/lib/cli/src/commands/gen_c_header.rs +++ b/lib/cli/src/commands/gen_c_header.rs @@ -7,8 +7,6 @@ use wasmer_types::compilation::symbols::ModuleMetadataSymbolRegistry; use wasmer_types::{CpuFeature, MetadataHeader, Triple}; use webc::WebC; -use super::normalize_path; - #[derive(Debug, Parser)] /// The options for the `wasmer gen-c-header` subcommand pub struct GenCHeader { @@ -50,7 +48,7 @@ pub struct GenCHeader { impl GenCHeader { /// Runs logic for the `gen-c-header` subcommand pub fn execute(&self) -> Result<(), anyhow::Error> { - let path = crate::commands::normalize_path(&format!("{}", self.path.display())); + let path = crate::common::normalize_path(&format!("{}", self.path.display())); let mut file = std::fs::read(&path) .map_err(|e| anyhow::anyhow!("{e}")) .with_context(|| anyhow::anyhow!("{path}"))?; @@ -126,7 +124,7 @@ impl GenCHeader { metadata_length, ); - let output = normalize_path(&self.output.display().to_string()); + let output = crate::common::normalize_path(&self.output.display().to_string()); std::fs::write(&output, &header_file_src) .map_err(|e| anyhow::anyhow!("{e}")) diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index 2d925e8fa1d..16ec43d89cb 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -429,8 +429,8 @@ fn construct_manifest( .join(&format!("{package_name}.wasm")); let canonicalized_outpath = outpath.canonicalize().unwrap_or(outpath); let outpath_str = - crate::commands::normalize_path(&canonicalized_outpath.display().to_string()); - let manifest_canonicalized = crate::commands::normalize_path( + crate::common::normalize_path(&canonicalized_outpath.display().to_string()); + let manifest_canonicalized = crate::common::normalize_path( &manifest_path .parent() .and_then(|p| p.canonicalize().ok()) diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index 0d6bef5a641..aa52c43395e 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; @@ -9,7 +10,9 @@ use anyhow::{anyhow, Context, Result}; use clap::Parser; 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")] @@ -199,12 +202,13 @@ impl RunWithPathBuf { #[cfg(feature = "webc_runner")] { if let Ok(pf) = WapmContainer::new(self.path.clone()) { - return Self::run_container( - pf, - &self.command_name.clone().unwrap_or_default(), - &self.args, - ) - .map_err(|e| anyhow!("Could not run PiritaFile: {e}")); + return self + .run_container( + pf, + &self.command_name.clone().unwrap_or_default(), + &self.args, + ) + .map_err(|e| anyhow!("Could not run PiritaFile: {e}")); } } let (mut store, module) = self.get_store_module()?; @@ -344,7 +348,12 @@ impl RunWithPathBuf { } #[cfg(feature = "webc_runner")] - fn run_container(container: WapmContainer, id: &str, args: &[String]) -> Result<(), String> { + fn run_container( + &self, + container: WapmContainer, + id: &str, + args: &[String], + ) -> Result<(), anyhow::Error> { let mut result = None; #[cfg(feature = "wasi")] @@ -353,12 +362,15 @@ impl RunWithPathBuf { return r; } - let mut runner = wasmer_wasi::runners::wasi::WasiRunner::default(); + let (store, _compiler_type) = self.store.get_store()?; + let mut runner = wasmer_wasi::runners::wasi::WasiRunner::new(store); runner.set_args(args.to_vec()); result = Some(if id.is_empty() { - runner.run(&container).map_err(|e| format!("{e}")) + runner.run(&container).map_err(|e| anyhow::anyhow!("{e}")) } else { - runner.run_cmd(&container, id).map_err(|e| format!("{e}")) + runner + .run_cmd(&container, id) + .map_err(|e| anyhow::anyhow!("{e}")) }); } @@ -368,16 +380,19 @@ impl RunWithPathBuf { return r; } - let mut runner = wasmer_wasi::runners::emscripten::EmscriptenRunner::default(); + let (store, _compiler_type) = self.store.get_store()?; + let mut runner = wasmer_wasi::runners::emscripten::EmscriptenRunner::new(store); runner.set_args(args.to_vec()); result = Some(if id.is_empty() { - runner.run(&container).map_err(|e| format!("{e}")) + runner.run(&container).map_err(|e| anyhow::anyhow!("{e}")) } else { - runner.run_cmd(&container, id).map_err(|e| format!("{e}")) + runner + .run_cmd(&container, id) + .map_err(|e| anyhow::anyhow!("{e}")) }); } - result.unwrap_or_else(|| Err("neither emscripten or wasi file".to_string())) + result.unwrap_or_else(|| Err(anyhow::anyhow!("neither emscripten or wasi file"))) } fn get_store_module(&self) -> Result<(Store, Module)> { diff --git a/lib/cli/src/common.rs b/lib/cli/src/common.rs index 81af03197cd..a06ded1fd19 100644 --- a/lib/cli/src/common.rs +++ b/lib/cli/src/common.rs @@ -51,3 +51,7 @@ pub fn get_cache_dir() -> PathBuf { } } } + +pub(crate) fn normalize_path(s: &str) -> String { + s.strip_prefix(r"\\?\").unwrap_or(s).to_string() +} diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index e60a86142ed..2c917475273 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -56,8 +56,8 @@ impl Artifact { data: &[u8], tunables: &dyn Tunables, ) -> Result { - let environ = ModuleEnvironment::new(); let mut inner_engine = engine.inner_mut(); + let environ = ModuleEnvironment::new(); let translation = environ.translate(data).map_err(CompileError::Wasm)?; let module = translation.module; let memory_styles: PrimaryMap = module diff --git a/lib/compiler/src/engine/inner.rs b/lib/compiler/src/engine/inner.rs index 0347b87b729..240ef19c87d 100644 --- a/lib/compiler/src/engine/inner.rs +++ b/lib/compiler/src/engine/inner.rs @@ -22,9 +22,9 @@ use std::sync::{Arc, Mutex}; #[cfg(not(target_arch = "wasm32"))] use wasmer_types::{ entity::PrimaryMap, DeserializeError, FunctionBody, FunctionIndex, FunctionType, - LocalFunctionIndex, ModuleInfo, SignatureIndex, + LocalFunctionIndex, SignatureIndex, }; -use wasmer_types::{CompileError, Features, Target}; +use wasmer_types::{CompileError, Features, ModuleInfo, Target}; #[cfg(not(target_arch = "wasm32"))] use wasmer_types::{CustomSection, CustomSectionProtection, SectionIndex}; #[cfg(not(target_arch = "wasm32"))] @@ -74,6 +74,15 @@ impl Engine { } } + /// Returns only the `ModuleInfo` given a `wasm` byte slice + #[cfg(feature = "compiler")] + pub fn get_module_info(data: &[u8]) -> Result { + // this is from `artifact_builder.rs` + let environ = crate::ModuleEnvironment::new(); + let translation = environ.translate(data).map_err(CompileError::Wasm)?; + Ok(translation.module) + } + /// Returns the name of this engine pub fn name(&self) -> &str { self.name.as_str() @@ -267,7 +276,7 @@ impl EngineInner { pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> { match self.compiler.as_ref() { None => Err(CompileError::Codegen( - "The Engine is not compiled in.".to_string(), + "No compiler compiled into executable".to_string(), )), Some(compiler) => Ok(&**compiler), } diff --git a/lib/compiler/src/engine/unwind/systemv.rs b/lib/compiler/src/engine/unwind/systemv.rs index 38d51e219f4..11e08e4b34b 100644 --- a/lib/compiler/src/engine/unwind/systemv.rs +++ b/lib/compiler/src/engine/unwind/systemv.rs @@ -36,7 +36,7 @@ impl UnwindRegistry { ) -> Result<(), String> { match info { CompiledFunctionUnwindInfo::Dwarf => {} - _ => return Err("unsupported unwind information".to_string()), + _ => return Err(format!("unsupported unwind information {info:?}")), }; Ok(()) } diff --git a/lib/vfs/Cargo.toml b/lib/vfs/Cargo.toml index cd44f06d4f0..25ce6cc62fe 100644 --- a/lib/vfs/Cargo.toml +++ b/lib/vfs/Cargo.toml @@ -20,7 +20,7 @@ anyhow = { version = "1.0.66", optional = true } default = ["host-fs", "mem-fs", "webc-fs", "static-fs"] host-fs = ["libc"] mem-fs = ["slab"] -webc-fs = ["webc", "anyhow"] +webc-fs = ["webc", "mem-fs", "anyhow"] static-fs = ["webc", "anyhow", "mem-fs"] enable-serde = [ "serde", diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index b975d874c8b..9c0f44e65cf 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -50,7 +50,7 @@ tracing-wasm = "0.2" default = ["sys-default"] wasix = [] -webc_runner = ["webc", "serde_cbor", "anyhow", "serde", "wasmer/compiler", "wasmer/cranelift"] +webc_runner = ["webc", "serde_cbor", "anyhow", "serde", "wasmer-vfs/webc-fs"] webc_runner_rt_emscripten = ["wasmer-emscripten"] webc_runner_rt_wasi = [] diff --git a/lib/wasi/src/runners/emscripten.rs b/lib/wasi/src/runners/emscripten.rs index cbfb5ce0051..168f109c5c9 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; @@ -6,19 +6,41 @@ use anyhow::anyhow; use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::sync::Arc; -use wasmer::{Cranelift, FunctionEnv, Instance, Module, Store}; +use wasmer::{FunctionEnv, Instance, Module, Store}; use wasmer_emscripten::{ generate_emscripten_env, is_emscripten_module, run_emscripten_instance, EmEnv, EmscriptenGlobals, }; use webc::{Command, WebCMmap}; -#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EmscriptenRunner { args: Vec, + #[serde(skip, default)] + store: Store, } impl EmscriptenRunner { + /// Constructs a new `EmscriptenRunner` given an `Store` + pub fn new(store: Store) -> Self { + Self { + args: Vec::new(), + store, + } + } + + /// Returns the current arguments for this `EmscriptenRunner` + pub fn get_args(&self) -> Vec { + self.args.clone() + } + + /// Builder method to provide CLI args to the runner + pub fn with_args(mut self, args: Vec) -> Self { + self.set_args(args); + self + } + + /// Set the CLI args pub fn set_args(&mut self, args: Vec) { self.args = args; } @@ -33,6 +55,7 @@ impl crate::runners::Runner for EmscriptenRunner { .starts_with("https://webc.org/runner/emscripten")) } + #[allow(unreachable_code, unused_variables)] fn run_command( &mut self, command_name: &str, @@ -43,16 +66,14 @@ 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)?; - let compiler = Cranelift::default(); - let mut store = Store::new(compiler); - let mut module = Module::new(&store, atom_bytes)?; + let mut module = Module::new(&self.store, atom_bytes)?; module.set_name(&atom_name); let (mut globals, env) = - prepare_emscripten_env(&mut store, &module, container.webc.clone(), &atom_name)?; + prepare_emscripten_env(&mut self.store, &module, container.webc.clone(), &atom_name)?; exec_module( - &mut store, + &mut self.store, &module, &mut globals, env, diff --git a/lib/wasi/src/runners/wasi.rs b/lib/wasi/src/runners/wasi.rs index d73ee69c7e7..52b02fcbf99 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; @@ -7,16 +7,38 @@ use anyhow::Context; use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::sync::Arc; -use wasmer::{Cranelift, Instance, Module, Store}; +use wasmer::{Instance, Module, Store}; use wasmer_vfs::webc_fs::WebcFileSystem; use webc::{Command, WebCMmap}; -#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct WasiRunner { args: Vec, + #[serde(skip, default)] + store: Store, } impl WasiRunner { + /// Constructs a new `WasiRunner` given an `Store` + pub fn new(store: Store) -> Self { + Self { + args: Vec::new(), + store, + } + } + + /// Returns the current arguments for this `WasiRunner` + pub fn get_args(&self) -> Vec { + self.args.clone() + } + + /// Builder method to provide CLI args to the runner + pub fn with_args(mut self, args: Vec) -> Self { + self.set_args(args); + self + } + + /// Set the CLI args pub fn set_args(&mut self, args: Vec) { self.args = args; } @@ -33,6 +55,7 @@ impl crate::runners::Runner for WasiRunner { Ok(command.runner.starts_with("https://webc.org/runner/wasi")) } + #[allow(unreachable_code, unused_variables)] fn run_command( &mut self, command_name: &str, @@ -42,14 +65,17 @@ 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)?; - let compiler = Cranelift::default(); - let mut store = Store::new(compiler); - let mut module = Module::new(&store, atom_bytes)?; + let mut module = Module::new(&self.store, atom_bytes)?; module.set_name(&atom_name); - let env = prepare_webc_env(&mut store, container.webc.clone(), &atom_name, &self.args)?; + let env = prepare_webc_env( + &mut self.store, + container.webc.clone(), + &atom_name, + &self.args, + )?; - exec_module(&mut store, &module, env)?; + exec_module(&mut self.store, &module, env)?; Ok(()) } diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index f4aca85ab3f..d85c8dcb0bb 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -331,7 +331,7 @@ pub(crate) fn poll( .bytes_available_write()? .map(|s| s > 0) .unwrap_or(false); - let is_closed = file.is_open() == false; + let is_closed = !file.is_open(); tracing::debug!( "poll_evt can_read={} can_write={} is_closed={}", 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));