From f3419239a79eb19e86eb1635b4e9b9547c94a7e7 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 31 May 2021 17:18:55 +0200 Subject: [PATCH 1/2] chore(wasi) Remove the deprecated code. --- lib/wasi/src/lib.rs | 7 -- lib/wasi/src/state/builder.rs | 2 - lib/wasi/src/state/mod.rs | 125 +--------------------------------- 3 files changed, 1 insertion(+), 133 deletions(-) diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 944ab34e7f7..181f485b982 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -105,13 +105,6 @@ impl WasiEnv { self.state.lock().unwrap() } - // TODO: delete this method before 1.0.0 release - #[doc(hidden)] - #[deprecated(since = "1.0.0-beta1", note = "Please use the `state` method instead")] - pub fn state_mut(&mut self) -> MutexGuard { - self.state.lock().unwrap() - } - /// Get a reference to the memory pub fn memory(&self) -> &Memory { self.memory_ref() diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index 3422601cd0a..e950decd110 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -361,8 +361,6 @@ impl WasiStateBuilder { // self.preopens are checked in [`PreopenDirBuilder::build`] - // this deprecation warning only applies to external callers - #[allow(deprecated)] let mut wasi_fs = WasiFs::new_with_preopen(&self.preopens) .map_err(WasiStateCreationError::WasiFsCreationError)?; // set up the file system, overriding base files and calling the setup function diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index f58c7e48cb1..4766b8006ab 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -71,7 +71,7 @@ pub struct InodeVal { #[derive(Debug, Serialize, Deserialize)] pub enum Kind { File { - /// the open file, if it's open + /// The open file, if it's open handle: Option>, /// The path on the host system where the file is located /// This is deprecated and will be removed soon @@ -166,129 +166,6 @@ pub struct WasiFs { } impl WasiFs { - /// Internal function for constructing a [`WasiFs`]. Please use - /// [`WasiState::new`]. - #[deprecated( - since = "0.14.0", - note = "This method will change or be made private in the future. Please use `WasiState::new` and the builder API instead." - )] - pub fn new( - preopened_dirs: &[PathBuf], - mapped_dirs: &[(String, PathBuf)], - ) -> Result { - let (mut wasi_fs, root_inode) = Self::new_init()?; - - debug!("wasi::fs::preopen_dirs"); - for dir in preopened_dirs { - debug!("Attempting to preopen {}", &dir.to_string_lossy()); - // TODO: think about this - let default_rights = ALL_RIGHTS; - let cur_dir_metadata = dir.metadata().map_err(|e| { - format!( - "Could not get metadata for file {:?}: {}", - dir, - e.to_string() - ) - })?; - let kind = if cur_dir_metadata.is_dir() { - Kind::Dir { - parent: Some(root_inode), - path: dir.clone(), - entries: Default::default(), - } - } else { - return Err(format!( - "WASI only supports pre-opened directories right now; found \"{}\"", - &dir.to_string_lossy() - )); - }; - // TODO: handle nested pats in `file` - let inode = wasi_fs - .create_inode(kind, true, dir.to_string_lossy().into_owned()) - .map_err(|e| { - format!( - "Failed to create inode for preopened dir: WASI error code: {}", - e - ) - })?; - let fd = wasi_fs - .create_fd( - default_rights, - default_rights, - 0, - Fd::READ | Fd::WRITE, - inode, - ) - .map_err(|e| format!("Could not open fd for file {:?}: {}", dir, e))?; - if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind { - let result = entries.insert(dir.to_string_lossy().into_owned(), inode); - if result.is_some() { - return Err(format!( - "Error: found collision in preopened directory names, `{}`", - dir.to_string_lossy() - )); - } - } - wasi_fs.preopen_fds.push(fd); - } - debug!("wasi::fs::mapped_dirs"); - for (alias, real_dir) in mapped_dirs { - debug!("Attempting to open {:?} at {}", real_dir, alias); - // TODO: think about this - let default_rights = ALL_RIGHTS; - let cur_dir_metadata = real_dir.metadata().map_err(|e| { - format!( - "Could not get metadata for file {:?}: {}", - &real_dir, - e.to_string() - ) - })?; - let kind = if cur_dir_metadata.is_dir() { - Kind::Dir { - parent: Some(root_inode), - path: real_dir.clone(), - entries: Default::default(), - } - } else { - return Err(format!( - "WASI only supports pre-opened directories right now; found \"{:?}\"", - &real_dir, - )); - }; - // TODO: handle nested pats in `file` - let inode = wasi_fs - .create_inode(kind, true, alias.clone()) - .map_err(|e| { - format!( - "Failed to create inode for preopened dir: WASI error code: {}", - e - ) - })?; - let fd = wasi_fs - .create_fd( - default_rights, - default_rights, - 0, - Fd::READ | Fd::WRITE, - inode, - ) - .map_err(|e| format!("Could not open fd for file {:?}: {}", &real_dir, e))?; - if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind { - let result = entries.insert(alias.clone(), inode); - if result.is_some() { - return Err(format!( - "Error: found collision in preopened directory aliases, `{}`", - alias, - )); - } - } - wasi_fs.preopen_fds.push(fd); - } - - debug!("wasi::fs::end"); - Ok(wasi_fs) - } - /// Created for the builder API. like `new` but with more information pub(crate) fn new_with_preopen(preopens: &[PreopenedDir]) -> Result { let (mut wasi_fs, root_inode) = Self::new_init()?; From 87175ebae2b68c15f1e8c04a95f184d84d2604dd Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 31 May 2021 17:27:28 +0200 Subject: [PATCH 2/2] chore(cli) Remove the `--backend` deprecated option. --- lib/cli/src/store.rs | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/cli/src/store.rs b/lib/cli/src/store.rs index 4870e2dee72..a88e2ebd8d5 100644 --- a/lib/cli/src/store.rs +++ b/lib/cli/src/store.rs @@ -2,10 +2,9 @@ //! commands. use crate::common::WasmFeatures; -use anyhow::{Error, Result}; +use anyhow::Result; use clap::Clap; use std::path::PathBuf; -use std::str::FromStr; use std::string::ToString; #[allow(unused_imports)] use std::sync::Arc; @@ -36,15 +35,15 @@ pub struct StoreOptions { /// The compiler options pub struct CompilerOptions { /// Use Singlepass compiler. - #[clap(long, conflicts_with_all = &["cranelift", "llvm", "backend"])] + #[clap(long, conflicts_with_all = &["cranelift", "llvm"])] singlepass: bool, /// Use Cranelift compiler. - #[clap(long, conflicts_with_all = &["singlepass", "llvm", "backend"])] + #[clap(long, conflicts_with_all = &["singlepass", "llvm"])] cranelift: bool, /// Use LLVM compiler. - #[clap(long, conflicts_with_all = &["singlepass", "cranelift", "backend"])] + #[clap(long, conflicts_with_all = &["singlepass", "cranelift"])] llvm: bool, /// Enable compiler internal verification. @@ -55,10 +54,6 @@ pub struct CompilerOptions { #[clap(long, parse(from_os_str))] llvm_debug_dir: Option, - /// The deprecated backend flag - Please do not use - #[clap(long = "backend", hidden = true, conflicts_with_all = &["singlepass", "cranelift", "llvm"])] - backend: Option, - #[clap(flatten)] features: WasmFeatures, } @@ -72,12 +67,6 @@ impl CompilerOptions { Ok(CompilerType::LLVM) } else if self.singlepass { Ok(CompilerType::Singlepass) - } else if let Some(backend) = self.backend.clone() { - warning!( - "the `--backend={0}` flag is deprecated, please use `--{0}` instead", - backend - ); - CompilerType::from_str(&backend) } else { // Auto mode, we choose the best compiler for that platform cfg_if::cfg_if! { @@ -344,19 +333,6 @@ impl ToString for CompilerType { } } -impl FromStr for CompilerType { - type Err = Error; - fn from_str(s: &str) -> Result { - match s { - "singlepass" => Ok(Self::Singlepass), - "cranelift" => Ok(Self::Cranelift), - "llvm" => Ok(Self::LLVM), - "headless" => Ok(Self::Headless), - backend => bail!("The `{}` compiler does not exist.", backend), - } - } -} - /// The engine used for the store #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum EngineType {