diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f10837c3428..847de4fd8cc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,7 +8,6 @@ lib/llvm-backend @nlewycky @losfair # Runtime lib/runtime-core @Hywan @bjfish -lib/runtime-abi @MarkMcCaskey lib/runtime @MarkMcCaskey @Hywan @bjfish lib/runtime-c-api @bjfish @Hywan lib/win-exception-handler @bjfish @losfair diff --git a/CHANGELOG.md b/CHANGELOG.md index 37b74d52deb..94677f085e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#832](https://github.com/wasmerio/wasmer/pull/832) Delete unused runtime ABI - [#809](https://github.com/wasmerio/wasmer/pull/809) Fix bugs leading to panics in `LocalBacking`. - [#822](https://github.com/wasmerio/wasmer/pull/822) Update Cranelift fork version to `0.43.1` - [#829](https://github.com/wasmerio/wasmer/pull/829) Fix deps on `make bench-*` commands; benchmarks don't compile other backends now diff --git a/Cargo.toml b/Cargo.toml index d433ad45630..e9916b3ca5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,6 @@ wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } wasmer-middleware-common = { path = "lib/middleware-common" } wasmer-runtime = { path = "lib/runtime" } -# wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true } wasmer-runtime-core = { path = "lib/runtime-core" } wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } @@ -43,7 +42,6 @@ members = [ "lib/clif-backend", "lib/singlepass-backend", "lib/runtime", - # "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", @@ -100,7 +98,6 @@ backend-singlepass = [ ] wasi = ["wasmer-wasi"] managed = ["backend-singlepass", "wasmer-runtime-core/managed"] -# vfs = ["wasmer-runtime-abi"] [[example]] name = "plugin" diff --git a/lib/runtime-abi/Cargo.toml b/lib/runtime-abi/Cargo.toml deleted file mode 100644 index 9779adbd080..00000000000 --- a/lib/runtime-abi/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "wasmer-runtime-abi" -version = "0.7.0" -description = "Wasmer runtime core library" -license = "MIT" -authors = ["The Wasmer Engineering Team "] -repository = "https://github.com/wasmerio/wasmer" -edition = "2018" - -[dependencies] -libc = "0.2.60" -wasmer-runtime-core = { path = "../runtime-core" } -failure = "0.1" -tar = "0.4" -wasmparser = "0.37.0" -zstd = "0.4" - -# [target.'cfg(unix)'.dependencies.zbox] -# git = "https://github.com/wasmerio/zbox" -# branch = "bundle-libsodium" -# features = ["libsodium-bundled"] - -[dev-dependencies] -tempdir = "0.3" - -[features] -debug = [] diff --git a/lib/runtime-abi/README.md b/lib/runtime-abi/README.md deleted file mode 100644 index fe906c2dd74..00000000000 --- a/lib/runtime-abi/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# runtime-abi - -This crate has ABI functions (like syscalls) and extensions to the runtime for enabling ABIs (e.g. virtual filesystem). - -## Virtual Filesystem (experimental) - -The virtual filesystem allows the runtime to read bundled wasm data as if they were files. Data that is stored in a -custom section compressed with [zstd][1] compression and archived with [tar][2] will be exposed as files and mounted -in the `/` root. - -The only current supported operation is the `read` syscall. - -The virtual filesystem is not enabled by default. Build with `--features vfs` to use it. - -[Zbox][3] is a virtual filesystem that depends on [libsodium][4]. See [installation instructions][5] for libsodium here. One can -statically link libsodium with the [instructions][6] on Zbox's readme. - -[1]: https://facebook.github.io/zstd/ -[2]: https://www.gnu.org/software/tar/ -[3]: https://zbox.io/ -[4]: https://download.libsodium.org/doc/ -[5]: https://download.libsodium.org/doc/installation -[6]: https://github.com/zboxfs/zbox#static-linking-with-libsodium diff --git a/lib/runtime-abi/src/lib.rs b/lib/runtime-abi/src/lib.rs deleted file mode 100644 index 84923b43782..00000000000 --- a/lib/runtime-abi/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![deny(dead_code, unused_imports, unused_variables, unused_unsafe, unreachable_patterns)] - -#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")] -#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")] - -#[cfg(not(target_os = "windows"))] -#[macro_use] -extern crate failure; - -#[cfg(not(target_os = "windows"))] -pub mod vfs; diff --git a/lib/runtime-abi/src/vfs/device_file.rs b/lib/runtime-abi/src/vfs/device_file.rs deleted file mode 100644 index 3013d32b25c..00000000000 --- a/lib/runtime-abi/src/vfs/device_file.rs +++ /dev/null @@ -1,111 +0,0 @@ -use crate::vfs::file_like::{FileLike, Metadata}; -use failure::Error; -use std::io; - -pub struct Stdin; -pub struct Stdout; -pub struct Stderr; - -impl FileLike for Stdin { - fn metadata(&self) -> Result { - unimplemented!() - } - - fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> { - panic!("Cannot set length of stdin"); - } -} - -impl io::Read for Stdin { - fn read(&mut self, _buf: &mut [u8]) -> Result { - unimplemented!() - } -} - -impl io::Write for Stdin { - fn write(&mut self, _buf: &[u8]) -> Result { - unimplemented!() - } - - fn flush(&mut self) -> Result<(), io::Error> { - unimplemented!() - } -} - -impl io::Seek for Stdin { - fn seek(&mut self, _pos: io::SeekFrom) -> Result { - unimplemented!() - } -} - -impl FileLike for Stdout { - fn metadata(&self) -> Result { - unimplemented!() - } - - fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> { - panic!("Cannot set length of stdout"); - } -} - -impl io::Read for Stdout { - fn read(&mut self, _buf: &mut [u8]) -> Result { - unimplemented!() - } -} - -impl io::Write for Stdout { - fn write(&mut self, buf: &[u8]) -> Result { - let stdout = io::stdout(); - let mut handle = stdout.lock(); - handle.write(buf) - } - - fn flush(&mut self) -> Result<(), io::Error> { - let stdout = io::stdout(); - let mut handle = stdout.lock(); - handle.flush() - } -} - -impl io::Seek for Stdout { - fn seek(&mut self, _pos: io::SeekFrom) -> Result { - unimplemented!() - } -} - -impl FileLike for Stderr { - fn metadata(&self) -> Result { - unimplemented!() - } - - fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> { - panic!("Cannot set length of stderr"); - } -} - -impl io::Read for Stderr { - fn read(&mut self, _buf: &mut [u8]) -> Result { - unimplemented!() - } -} - -impl io::Write for Stderr { - fn write(&mut self, buf: &[u8]) -> Result { - let stderr = io::stderr(); - let mut handle = stderr.lock(); - handle.write(buf) - } - - fn flush(&mut self) -> Result<(), io::Error> { - let stderr = io::stderr(); - let mut handle = stderr.lock(); - handle.flush() - } -} - -impl io::Seek for Stderr { - fn seek(&mut self, _pos: io::SeekFrom) -> Result { - unimplemented!() - } -} diff --git a/lib/runtime-abi/src/vfs/file_like.rs b/lib/runtime-abi/src/vfs/file_like.rs deleted file mode 100644 index 4b9b8771c74..00000000000 --- a/lib/runtime-abi/src/vfs/file_like.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub type Fd = isize; - -#[derive(Debug)] -pub struct Metadata { - pub len: usize, - pub is_file: bool, -} - -pub trait FileLike: std::io::Write + std::io::Read + std::io::Seek { - // get metadata - fn metadata(&self) -> Result; - - // write - // fn write_file(&mut self, buf: &[u8]) -> Result; - - // read - // fn read_file(&mut self, buf: &mut [u8]) -> Result; - - // set_file_len - fn set_file_len(&mut self, len: usize) -> Result<(), failure::Error>; -} diff --git a/lib/runtime-abi/src/vfs/mod.rs b/lib/runtime-abi/src/vfs/mod.rs deleted file mode 100644 index 0a152b5b364..00000000000 --- a/lib/runtime-abi/src/vfs/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod device_file; -pub mod file_like; -pub mod vfs; -pub mod vfs_header; -pub mod virtual_file; diff --git a/lib/runtime-abi/src/vfs/vfs.rs b/lib/runtime-abi/src/vfs/vfs.rs deleted file mode 100644 index c4e01a380fb..00000000000 --- a/lib/runtime-abi/src/vfs/vfs.rs +++ /dev/null @@ -1,170 +0,0 @@ -use crate::vfs::file_like::FileLike; -use crate::vfs::vfs_header::{header_from_bytes, ArchiveType, CompressionType}; -use crate::vfs::virtual_file::VirtualFile; -use std::collections::HashMap; -use std::cell::RefCell; -use std::io; -use std::io::Read; -use std::path::{Path, PathBuf}; -use std::rc::Rc; -use tar::EntryType; -use zbox::{init_env, OpenOptions, Repo, RepoOpener}; - -pub struct Vfs { - repo: Repo, - device_files: HashMap>>, -} - -impl Vfs { - /// Like `VfsBacking::from_tar_bytes` except it also decompresses from the zstd format. - pub fn from_tar_zstd_bytes(tar_bytes: Reader) -> Result { - let result = zstd::decode_all(tar_bytes); - let decompressed_data = result.unwrap(); - Self::from_tar_bytes(&decompressed_data[..]) - } - - /// Match on the type of the compressed-archive and select the correct unpack method - pub fn from_compressed_bytes(compressed_data_slice: &[u8]) -> Result { - let data_bytes = &compressed_data_slice[4..]; - match header_from_bytes(compressed_data_slice)? { - (_, CompressionType::ZSTD, ArchiveType::TAR) => Self::from_tar_zstd_bytes(data_bytes), - (_, CompressionType::NONE, ArchiveType::TAR) => Self::from_tar_bytes(data_bytes), - } - } - - /// Create a vfs from raw bytes in tar format - pub fn from_tar_bytes(tar_bytes: Reader) -> Result { - init_env(); - let mut repo = RepoOpener::new() - .create(true) - .open("mem://wasmer_fs", "") - .unwrap(); - let _errors = tar::Archive::new(tar_bytes) - .entries()? - .map(|entry| { - let mut entry: tar::Entry = entry?; - let path = entry.path()?; - let path = convert_to_absolute_path(path); - let _result = match (entry.header().entry_type(), path.parent()) { - (EntryType::Regular, Some(parent)) => { - if let Err(e) = repo.create_dir_all(parent) { - if e == zbox::Error::AlreadyExists || e == zbox::Error::IsRoot { - } else { - return Err(VfsAggregateError::ZboxError(e)); - } - } else { - } - let mut file = repo.create_file(&path)?; - if entry.header().size().unwrap_or(0) > 0 { - io::copy(&mut entry, &mut file)?; - file.finish()?; - } - } - (EntryType::Directory, _) => { - if let Err(e) = repo.create_dir_all(path) { - if e == zbox::Error::AlreadyExists || e == zbox::Error::IsRoot { - } else { - return Err(VfsAggregateError::ZboxError(e)); - } - } else { - } - } - _ => return Err(VfsAggregateError::UnsupportedFileType), - }; - Ok(()) - }) - .collect::>>(); - - // let import_errors = errors.iter().filter_map(|e| e.err()).collect::>(); - - let vfs = Self { - repo, - device_files: HashMap::new(), - // import_errors: vec![], - }; - Ok(vfs) - } - - pub fn new() -> Result<(Self, Vec), failure::Error> { - init_env(); - let repo = RepoOpener::new() - .create(true) - .open("mem://wasmer_fs", "") - .unwrap(); - Ok(( - Vfs { - repo, - device_files: HashMap::new(), - }, - vec![], - )) - } - - pub fn open_file>(&mut self, path: P) -> Option>> { - init_env(); - let path = convert_to_absolute_path(path); - if let Ok(file) = OpenOptions::new().write(true).open(&mut self.repo, &path) { - Some(Rc::new(RefCell::new(VirtualFile::new(file)))) - } else if let Some(dev_file) = self.device_files.get(&path) { - Some(dev_file.clone()) - } else { - None - } - } - - pub fn make_dir>(&mut self, path: P) { - self.repo.create_dir_all(path).unwrap(); - } - - pub fn create_device_file>(&mut self, path: P, file: Rc>) { - self.device_files.insert(path.as_ref().to_path_buf(), file); - } -} - -fn convert_to_absolute_path>(path: P) -> PathBuf { - let path = path.as_ref(); - if path.is_relative() { - std::path::PathBuf::from("/").join(path) - } else { - path.to_path_buf() - } -} - -pub type Handle = i32; -#[derive(Debug, Fail)] -pub enum VfsError { - #[fail(display = "File with file descriptor \"{}\" does not exist.", _0)] - FileWithFileDescriptorNotExist(Handle), - #[fail(display = "File descriptor does not exist.")] - FileDescriptorNotExist(Handle), - #[fail(display = "Source file descriptor does not exist.")] - SourceFileDescriptorDoesNotExist, - #[fail(display = "Target file descriptor already exists.")] - TargetFileDescriptorAlreadyExists, - #[fail(display = "Could not get a mutable reference to the file because it is in use.")] - CouldNotGetMutableReferenceToFile, -} - -#[derive(Debug, Fail)] -pub enum VfsAggregateError { - #[fail(display = "Entry error.")] - EntryError(std::io::Error), - #[fail(display = "IO error.")] - IoError(std::io::Error), - #[fail(display = "Zbox error.")] - ZboxError(zbox::Error), - #[fail(display = "Unsupported file type.")] - UnsupportedFileType, -} - -impl std::convert::From for VfsAggregateError { - fn from(error: std::io::Error) -> VfsAggregateError { - VfsAggregateError::EntryError(error) - } -} - -impl std::convert::From for VfsAggregateError { - fn from(error: zbox::Error) -> VfsAggregateError { - VfsAggregateError::ZboxError(error) - } -} diff --git a/lib/runtime-abi/src/vfs/vfs_header.rs b/lib/runtime-abi/src/vfs/vfs_header.rs deleted file mode 100644 index c90c658b00d..00000000000 --- a/lib/runtime-abi/src/vfs/vfs_header.rs +++ /dev/null @@ -1,57 +0,0 @@ -/// Represents the version of this header schema. -#[repr(u8)] -#[derive(Debug, PartialEq)] -pub enum HeaderVersion { - Version1 = 1, -} - -/// Represents the compression type of the file data. Only Zstd or no-compression is supported. -#[repr(u8)] -#[derive(Debug, PartialEq)] -pub enum CompressionType { - NONE = 0, - ZSTD = 1, -} - -/// Represents the type of archive. The only supported archive is the Tar format. -#[repr(u8)] -#[derive(Debug, PartialEq)] -pub enum ArchiveType { - TAR = 0, -} - -// extract the header data from bytes -pub fn header_from_bytes( - bytes: &[u8], -) -> Result<(HeaderVersion, CompressionType, ArchiveType), HeaderError> { - if let Some(bytes) = bytes.get(..4) { - let version = match bytes[0] { - 1 => HeaderVersion::Version1, - x => return Err(HeaderError::UnknownHeaderVersion(x)), - }; - let compression_type = match bytes[1] { - 0 => CompressionType::NONE, - 1 => CompressionType::ZSTD, - x => return Err(HeaderError::UnknownCompressionType(x)), - }; - let archive_type = match bytes[2] { - 0 => ArchiveType::TAR, - x => return Err(HeaderError::UnknownArchiveType(x)), - }; - Ok((version, compression_type, archive_type)) - } else { - Err(HeaderError::HeaderTooSmall) - } -} - -#[derive(Debug, Fail)] -pub enum HeaderError { - #[fail(display = "The version is not supported: \"{}\"", _0)] - UnknownHeaderVersion(u8), - #[fail(display = "The compression type is unknown: \"{}\"", _0)] - UnknownCompressionType(u8), - #[fail(display = "The archive type is unknown: \"{}\"", _0)] - UnknownArchiveType(u8), - #[fail(display = "The header is too small.")] - HeaderTooSmall, -} diff --git a/lib/runtime-abi/src/vfs/virtual_file.rs b/lib/runtime-abi/src/vfs/virtual_file.rs deleted file mode 100644 index cd72231a158..00000000000 --- a/lib/runtime-abi/src/vfs/virtual_file.rs +++ /dev/null @@ -1,51 +0,0 @@ -use crate::vfs::file_like::{FileLike, Metadata}; -use failure::Error; -use std::io; - -pub struct VirtualFile(zbox::File); - -impl VirtualFile { - pub fn new(file: zbox::File) -> Self { - VirtualFile(file) - } -} - -impl FileLike for VirtualFile { - fn metadata(&self) -> Result { - self.0 - .metadata() - .map(|m| Metadata { - len: m.content_len(), - is_file: m.is_file(), - }) - .map_err(|e: zbox::Error| e.into()) - } - - fn set_file_len(&mut self, len: usize) -> Result<(), failure::Error> { - self.0.set_len(len).map_err(|e| e.into()) - } -} - -impl io::Write for VirtualFile { - fn write(&mut self, buf: &[u8]) -> Result { - let result = self.0.write(buf)?; - self.0.finish().unwrap(); - Ok(result) - } - - fn flush(&mut self) -> Result<(), io::Error> { - self.0.flush() - } -} - -impl io::Read for VirtualFile { - fn read(&mut self, buf: &mut [u8]) -> Result { - self.0.read(buf) - } -} - -impl io::Seek for VirtualFile { - fn seek(&mut self, pos: io::SeekFrom) -> Result { - self.0.seek(pos) - } -} diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index af65b65e86a..39069aaeaac 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -17,7 +17,6 @@ rand = "0.7" time = "0.1" typetag = "0.1" serde = { version = "1", features = ["derive"] } -# wasmer-runtime-abi = { path = "../runtime-abi" } wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" } [target.'cfg(windows)'.dependencies]