diff --git a/Cargo.lock b/Cargo.lock index 39c5b0a9a2..d63fb09e39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,7 +226,7 @@ dependencies = [ "unsafe-io 0.2.0", "winapi", "winapi-util", - "winx 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winx", ] [[package]] @@ -257,7 +257,7 @@ dependencies = [ "cap-primitives", "once_cell", "posish", - "winx 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winx", ] [[package]] @@ -396,16 +396,6 @@ dependencies = [ "glob", ] -[[package]] -name = "cpu-time" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "cpuid-bool" version = "0.1.2" @@ -2221,7 +2211,7 @@ dependencies = [ "rustc_version 0.3.3", "unsafe-io 0.3.0", "winapi", - "winx 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winx", ] [[package]] @@ -2284,10 +2274,10 @@ dependencies = [ "pretty_env_logger", "target-lexicon", "tempfile", - "wasi-c2", - "wasi-c2-cap-std-sync", - "wasi-c2-wasmtime", + "wasi-cap-std-sync", + "wasi-common", "wasmtime", + "wasmtime-wasi", "wat", ] @@ -2542,23 +2532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] -name = "wasi-c2" -version = "0.22.0" -dependencies = [ - "anyhow", - "bitflags", - "cap-rand", - "cap-std", - "libc", - "system-interface", - "thiserror", - "tracing", - "wiggle", - "winapi", -] - -[[package]] -name = "wasi-c2-cap-std-sync" +name = "wasi-cap-std-sync" version = "0.22.0" dependencies = [ "anyhow", @@ -2573,38 +2547,24 @@ dependencies = [ "system-interface", "tracing", "unsafe-io 0.3.0", - "wasi-c2", + "wasi-common", "winapi", ] -[[package]] -name = "wasi-c2-wasmtime" -version = "0.22.0" -dependencies = [ - "anyhow", - "wasi-c2", - "wasmtime", - "wasmtime-wiggle", - "wiggle", -] - [[package]] name = "wasi-common" version = "0.22.0" dependencies = [ "anyhow", - "cfg-if 1.0.0", - "cpu-time", - "filetime", - "getrandom 0.2.0", - "lazy_static", + "bitflags", + "cap-rand", + "cap-std", "libc", + "system-interface", "thiserror", "tracing", "wiggle", "winapi", - "winx 0.22.0", - "yanix", ] [[package]] @@ -2982,10 +2942,8 @@ name = "wasmtime-wasi" version = "0.22.0" dependencies = [ "anyhow", - "tracing", "wasi-common", "wasmtime", - "wasmtime-runtime", "wasmtime-wiggle", "wiggle", ] @@ -3170,15 +3128,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winx" -version = "0.22.0" -dependencies = [ - "bitflags", - "cvt", - "winapi", -] - [[package]] name = "winx" version = "0.22.0" @@ -3203,17 +3152,6 @@ dependencies = [ "wast 22.0.0", ] -[[package]] -name = "yanix" -version = "0.22.0" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "filetime", - "libc", - "tracing", -] - [[package]] name = "z3" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 7f948dff40..7799977b7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,9 +71,8 @@ members = [ "crates/misc/rust", "crates/wiggle", "crates/wiggle/wasmtime", - "crates/wasi-c2", - "crates/wasi-c2/wasmtime", - "crates/wasi-c2/cap-std-sync", + "crates/wasi-common", + "crates/wasi-common/cap-std-sync", "examples/fib-debug/wasm", "examples/wasi/wasm", "examples/wasi-fs/wasm", diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index 2244b79d65..20a6efc653 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -11,10 +11,10 @@ license = "Apache-2.0 WITH LLVM-exception" cfg-if = "1.0" [dev-dependencies] -wasi-c2 = { path = "../wasi-c2", version = "0.22.0" } -wasi-c2-wasmtime = { path = "../wasi-c2/wasmtime", version = "0.22.0" } -wasi-c2-cap-std-sync = { path = "../wasi-c2/cap-std-sync", version = "0.22.0" } +wasi-common = { path = "../wasi-common", version = "0.22.0" } +wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync", version = "0.22.0" } wasmtime = { path = "../wasmtime", version = "0.22.0" } +wasmtime-wasi = { path = "../wasi", version = "0.22.0" } target-lexicon = "0.11.0" pretty_env_logger = "0.4.0" tempfile = "3.1.0" diff --git a/crates/test-programs/tests/wasm_tests/runtime.rs b/crates/test-programs/tests/wasm_tests/runtime.rs index 8308363d4c..e57e14006c 100644 --- a/crates/test-programs/tests/wasm_tests/runtime.rs +++ b/crates/test-programs/tests/wasm_tests/runtime.rs @@ -1,7 +1,7 @@ use anyhow::Context; use std::path::Path; -use wasi_c2::pipe::{ReadPipe, WritePipe}; -use wasi_c2_cap_std_sync::WasiCtxBuilder; +use wasi_cap_std_sync::WasiCtxBuilder; +use wasi_common::pipe::{ReadPipe, WritePipe}; use wasmtime::{Linker, Module, Store}; pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> { @@ -42,7 +42,7 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any builder = builder.env("ERRNO_MODE_UNIX", "1")?; } - let snapshot1 = wasi_c2_wasmtime::Wasi::new(&store, builder.build()?); + let snapshot1 = wasi_wasmtime::Wasi::new(&store, builder.build()?); let mut linker = Linker::new(&store); @@ -97,7 +97,7 @@ pub fn instantiate_inherit_stdio( builder = builder.preopened_dir(preopen_dir, ".")?; } - let snapshot1 = wasi_c2_wasmtime::Wasi::new(&store, builder.build()?); + let snapshot1 = wasi_wasmtime::Wasi::new(&store, builder.build()?); let mut linker = Linker::new(&store); diff --git a/crates/wasi-common/Cargo.toml b/crates/wasi-common/Cargo.toml index 376af872f0..f815cb7568 100644 --- a/crates/wasi-common/Cargo.toml +++ b/crates/wasi-common/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasi-c2" +name = "wasi-common" version = "0.22.0" authors = ["The Wasmtime Project Developers"] description = "WASI implementation in Rust" @@ -14,9 +14,9 @@ build = "build.rs" publish = false # This doesn't actually link to a native library, but it allows us to set env -# vars like `DEP_WASI_C2_19_*` for crates that have build scripts and depend +# vars like `DEP_WASI_COMMON_19_*` for crates that have build scripts and depend # on this crate, allowing other crates to use the same witx files. -links = "wasi-c2-19" +links = "wasi-common-19" [dependencies] anyhow = "1.0" diff --git a/crates/wasi-common/build.rs b/crates/wasi-common/build.rs index a83d4831ad..2092df38ee 100644 --- a/crates/wasi-common/build.rs +++ b/crates/wasi-common/build.rs @@ -3,7 +3,7 @@ fn main() { let cwd = std::env::current_dir().unwrap(); let wasi = cwd.join("..").join("wasi-common").join("WASI"); - // this will be available to dependent crates via the DEP_WASI_C2_19_WASI env var: + // this will be available to dependent crates via the DEP_WASI_COMMON_19_WASI env var: println!("cargo:wasi={}", wasi.display()); // and available to our own crate as WASI_ROOT: println!("cargo:rustc-env=WASI_ROOT={}", wasi.display()); diff --git a/crates/wasi-common/cap-std-sync/Cargo.toml b/crates/wasi-common/cap-std-sync/Cargo.toml index 0bfed20196..65c060f818 100644 --- a/crates/wasi-common/cap-std-sync/Cargo.toml +++ b/crates/wasi-common/cap-std-sync/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasi-c2-cap-std-sync" +name = "wasi-cap-std-sync" version = "0.22.0" authors = ["The Wasmtime Project Developers"] description = "WASI implementation in Rust" @@ -13,7 +13,7 @@ include = ["src/**/*", "LICENSE" ] publish = false [dependencies] -wasi-c2 = { path = "../" } +wasi-common = { path = "../", version = "0.22.0" } anyhow = "1.0" cap-std = "0.11" cap-fs-ext = "0.11" diff --git a/crates/wasi-common/cap-std-sync/src/clocks.rs b/crates/wasi-common/cap-std-sync/src/clocks.rs index 3d81929534..2f677ec0d1 100644 --- a/crates/wasi-common/cap-std-sync/src/clocks.rs +++ b/crates/wasi-common/cap-std-sync/src/clocks.rs @@ -1,6 +1,6 @@ use cap_std::time::{Duration, Instant, SystemTime}; use cap_time_ext::{MonotonicClockExt, SystemClockExt}; -use wasi_c2::clocks::{WasiClocks, WasiMonotonicClock, WasiSystemClock}; +use wasi_common::clocks::{WasiClocks, WasiMonotonicClock, WasiSystemClock}; pub struct SystemClock(cap_std::time::SystemClock); diff --git a/crates/wasi-common/cap-std-sync/src/dir.rs b/crates/wasi-common/cap-std-sync/src/dir.rs index d672940ea5..728a65be6b 100644 --- a/crates/wasi-common/cap-std-sync/src/dir.rs +++ b/crates/wasi-common/cap-std-sync/src/dir.rs @@ -3,7 +3,7 @@ use cap_fs_ext::{DirExt, MetadataExt, SystemTimeSpec}; use std::any::Any; use std::convert::TryInto; use std::path::{Path, PathBuf}; -use wasi_c2::{ +use wasi_common::{ dir::{ReaddirCursor, ReaddirEntity, WasiDir}, file::{FdFlags, FileCaps, FileType, Filestat, OFlags, WasiFile}, Error, ErrorExt, @@ -219,8 +219,8 @@ impl WasiDir for Dir { fn set_times( &self, path: &str, - atime: Option, - mtime: Option, + atime: Option, + mtime: Option, follow_symlinks: bool, ) -> Result<(), Error> { if follow_symlinks { @@ -240,10 +240,10 @@ impl WasiDir for Dir { } } -fn convert_systimespec(t: Option) -> Option { +fn convert_systimespec(t: Option) -> Option { match t { - Some(wasi_c2::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t)), - Some(wasi_c2::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow), + Some(wasi_common::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t)), + Some(wasi_common::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow), None => None, } } diff --git a/crates/wasi-common/cap-std-sync/src/file.rs b/crates/wasi-common/cap-std-sync/src/file.rs index 66d55c2043..697d034712 100644 --- a/crates/wasi-common/cap-std-sync/src/file.rs +++ b/crates/wasi-common/cap-std-sync/src/file.rs @@ -7,7 +7,7 @@ use system_interface::{ fs::{Advice, FileIoExt, GetSetFdFlags}, io::ReadReady, }; -use wasi_c2::{ +use wasi_common::{ file::{FdFlags, FileType, Filestat, WasiFile}, Error, }; @@ -70,8 +70,8 @@ impl WasiFile for File { } fn set_times( &self, - atime: Option, - mtime: Option, + atime: Option, + mtime: Option, ) -> Result<(), Error> { self.0 .set_times(convert_systimespec(atime), convert_systimespec(mtime))?; @@ -145,49 +145,51 @@ impl AsRawFd for File { self.0.as_raw_fd() } } -pub fn convert_systimespec(t: Option) -> Option { +pub fn convert_systimespec(t: Option) -> Option { match t { - Some(wasi_c2::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t.into_std())), - Some(wasi_c2::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow), + Some(wasi_common::SystemTimeSpec::Absolute(t)) => { + Some(SystemTimeSpec::Absolute(t.into_std())) + } + Some(wasi_common::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow), None => None, } } -pub fn to_sysif_fdflags(f: wasi_c2::file::FdFlags) -> system_interface::fs::FdFlags { +pub fn to_sysif_fdflags(f: wasi_common::file::FdFlags) -> system_interface::fs::FdFlags { let mut out = system_interface::fs::FdFlags::empty(); - if f.contains(wasi_c2::file::FdFlags::APPEND) { + if f.contains(wasi_common::file::FdFlags::APPEND) { out |= system_interface::fs::FdFlags::APPEND; } - if f.contains(wasi_c2::file::FdFlags::DSYNC) { + if f.contains(wasi_common::file::FdFlags::DSYNC) { out |= system_interface::fs::FdFlags::DSYNC; } - if f.contains(wasi_c2::file::FdFlags::NONBLOCK) { + if f.contains(wasi_common::file::FdFlags::NONBLOCK) { out |= system_interface::fs::FdFlags::NONBLOCK; } - if f.contains(wasi_c2::file::FdFlags::RSYNC) { + if f.contains(wasi_common::file::FdFlags::RSYNC) { out |= system_interface::fs::FdFlags::RSYNC; } - if f.contains(wasi_c2::file::FdFlags::SYNC) { + if f.contains(wasi_common::file::FdFlags::SYNC) { out |= system_interface::fs::FdFlags::SYNC; } out } -pub fn from_sysif_fdflags(f: system_interface::fs::FdFlags) -> wasi_c2::file::FdFlags { - let mut out = wasi_c2::file::FdFlags::empty(); +pub fn from_sysif_fdflags(f: system_interface::fs::FdFlags) -> wasi_common::file::FdFlags { + let mut out = wasi_common::file::FdFlags::empty(); if f.contains(system_interface::fs::FdFlags::APPEND) { - out |= wasi_c2::file::FdFlags::APPEND; + out |= wasi_common::file::FdFlags::APPEND; } if f.contains(system_interface::fs::FdFlags::DSYNC) { - out |= wasi_c2::file::FdFlags::DSYNC; + out |= wasi_common::file::FdFlags::DSYNC; } if f.contains(system_interface::fs::FdFlags::NONBLOCK) { - out |= wasi_c2::file::FdFlags::NONBLOCK; + out |= wasi_common::file::FdFlags::NONBLOCK; } if f.contains(system_interface::fs::FdFlags::RSYNC) { - out |= wasi_c2::file::FdFlags::RSYNC; + out |= wasi_common::file::FdFlags::RSYNC; } if f.contains(system_interface::fs::FdFlags::SYNC) { - out |= wasi_c2::file::FdFlags::SYNC; + out |= wasi_common::file::FdFlags::SYNC; } out } diff --git a/crates/wasi-common/cap-std-sync/src/lib.rs b/crates/wasi-common/cap-std-sync/src/lib.rs index 33642fcae0..d1fad6bd46 100644 --- a/crates/wasi-common/cap-std-sync/src/lib.rs +++ b/crates/wasi-common/cap-std-sync/src/lib.rs @@ -8,9 +8,9 @@ use cap_rand::RngCore; use std::cell::RefCell; use std::path::Path; use std::rc::Rc; -use wasi_c2::{table::Table, Error, WasiCtx, WasiFile}; +use wasi_common::{table::Table, Error, WasiCtx, WasiFile}; -pub struct WasiCtxBuilder(wasi_c2::WasiCtxBuilder); +pub struct WasiCtxBuilder(wasi_common::WasiCtxBuilder); impl WasiCtxBuilder { pub fn new() -> Self { @@ -21,11 +21,18 @@ impl WasiCtxBuilder { Rc::new(RefCell::new(Table::new())), )) } - pub fn env(self, var: &str, value: &str) -> Result { + pub fn env(self, var: &str, value: &str) -> Result { let s = self.0.env(var, value)?; Ok(WasiCtxBuilder(s)) } - pub fn arg(self, arg: &str) -> Result { + pub fn inherit_env(self) -> Result { + let mut s = self.0; + for (key, value) in std::env::vars() { + s = s.env(&key, &value)?; + } + Ok(WasiCtxBuilder(s)) + } + pub fn arg(self, arg: &str) -> Result { let s = self.0.arg(arg)?; Ok(WasiCtxBuilder(s)) } diff --git a/crates/wasi-common/cap-std-sync/src/sched/unix.rs b/crates/wasi-common/cap-std-sync/src/sched/unix.rs index ad169f0408..15bbb29138 100644 --- a/crates/wasi-common/cap-std-sync/src/sched/unix.rs +++ b/crates/wasi-common/cap-std-sync/src/sched/unix.rs @@ -2,7 +2,7 @@ use cap_std::time::Duration; use std::convert::TryInto; use std::ops::Deref; use std::os::unix::io::{AsRawFd, RawFd}; -use wasi_c2::{ +use wasi_common::{ file::WasiFile, sched::{ subscription::{RwEventFlags, Subscription}, diff --git a/crates/wasi-common/cap-std-sync/src/sched/windows.rs b/crates/wasi-common/cap-std-sync/src/sched/windows.rs index 0cdee8c886..03eb41514c 100644 --- a/crates/wasi-common/cap-std-sync/src/sched/windows.rs +++ b/crates/wasi-common/cap-std-sync/src/sched/windows.rs @@ -5,7 +5,7 @@ use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError}; use std::sync::Mutex; use std::thread; use std::time::Duration; -use wasi_c2::{ +use wasi_common::{ file::WasiFile, sched::{ subscription::{RwEventFlags, Subscription}, diff --git a/crates/wasi-common/cap-std-sync/src/stdio.rs b/crates/wasi-common/cap-std-sync/src/stdio.rs index 9cc1badf76..17ca72f7b2 100644 --- a/crates/wasi-common/cap-std-sync/src/stdio.rs +++ b/crates/wasi-common/cap-std-sync/src/stdio.rs @@ -11,7 +11,7 @@ use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawHandle, RawHandle}; use unsafe_io::AsUnsafeFile; -use wasi_c2::{ +use wasi_common::{ file::{FdFlags, FileType, Filestat, WasiFile}, Error, ErrorExt, }; @@ -84,8 +84,8 @@ impl WasiFile for Stdin { } fn set_times( &self, - atime: Option, - mtime: Option, + atime: Option, + mtime: Option, ) -> Result<(), Error> { self.0 .set_times(convert_systimespec(atime), convert_systimespec(mtime))?; @@ -176,8 +176,8 @@ macro_rules! wasi_file_write_impl { } fn set_times( &self, - atime: Option, - mtime: Option, + atime: Option, + mtime: Option, ) -> Result<(), Error> { self.0 .set_times(convert_systimespec(atime), convert_systimespec(mtime))?; diff --git a/crates/wasi-common/wasmtime/Cargo.toml b/crates/wasi-common/wasmtime/Cargo.toml deleted file mode 100644 index 4b3df5391b..0000000000 --- a/crates/wasi-common/wasmtime/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "wasi-c2-wasmtime" -version = "0.22.0" -authors = ["The Wasmtime Project Developers"] -description = "WASI implementation in Rust" -license = "Apache-2.0 WITH LLVM-exception" -categories = ["wasm"] -keywords = ["webassembly", "wasm"] -repository = "https://github.com/bytecodealliance/wasmtime" -readme = "README.md" -edition = "2018" -include = ["src/**/*", "LICENSE", "build.rs"] -build = "build.rs" -publish = false - -[dependencies] -wasi-c2 = { path = "../" } -wiggle = { path = "../../wiggle", default-features = false, version = "0.22.0" } -wasmtime-wiggle = { path = "../../wiggle/wasmtime", default-features = false, version = "0.22.0" } -wasmtime = { path = "../../wasmtime" } -anyhow = "1.0" diff --git a/crates/wasi-common/wasmtime/build.rs b/crates/wasi-common/wasmtime/build.rs deleted file mode 100644 index 726bbddd30..0000000000 --- a/crates/wasi-common/wasmtime/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - // wasi-c2's links & build.rs ensure this variable points to the wasi root: - let wasi_root = std::env::var("DEP_WASI_C2_19_WASI").unwrap(); - // Make it available as WASI_ROOT: - println!("cargo:rustc-env=WASI_ROOT={}", wasi_root); -} diff --git a/crates/wasi-common/wasmtime/src/lib.rs b/crates/wasi-common/wasmtime/src/lib.rs deleted file mode 100644 index d9df5e48ae..0000000000 --- a/crates/wasi-common/wasmtime/src/lib.rs +++ /dev/null @@ -1,29 +0,0 @@ -pub use wasi_c2::{ - Error, FdFlags, FileCaps, Filestat, OFlags, ReaddirCursor, ReaddirEntity, SystemTimeSpec, - WasiCtx, WasiCtxBuilder, WasiDir, WasiFile, -}; - -// Defines a `struct Wasi` with member fields and appropriate APIs for dealing -// with all the various WASI exports. -wasmtime_wiggle::wasmtime_integration!({ - // The wiggle code to integrate with lives here: - target: wasi_c2::snapshots::preview_1, - // This must be the same witx document as used above. This should be ensured by - // the `WASI_ROOT` env variable, which is set in wasi-common's `build.rs`. - witx: ["$WASI_ROOT/phases/snapshot/witx/wasi_snapshot_preview1.witx"], - // This must be the same ctx type as used for the target: - ctx: WasiCtx, - // This macro will emit a struct to represent the instance, - // with this name and docs: - modules: { wasi_snapshot_preview1 => - { name: Wasi, - docs: "An instantiated instance of the wasi exports. - -This represents a wasi module which can be used to instantiate other wasm -modules. This structure exports all that various fields of the wasi instance -as fields which can be used to implement your own instantiation logic, if -necessary. Additionally [`Wasi::get_export`] can be used to do name-based -resolution.", - }, - }, -}); diff --git a/crates/wasi/Cargo.toml b/crates/wasi/Cargo.toml index f1e4b56e98..c28a712acf 100644 --- a/crates/wasi/Cargo.toml +++ b/crates/wasi/Cargo.toml @@ -1,24 +1,21 @@ [package] name = "wasmtime-wasi" version = "0.22.0" -authors = ["The Cranelift Project Developers"] -description = "WASI API support for Wasmtime" -documentation = "https://docs.rs/wasmtime-wasi" +authors = ["The Wasmtime Project Developers"] +description = "WASI implementation in Rust" license = "Apache-2.0 WITH LLVM-exception" categories = ["wasm"] keywords = ["webassembly", "wasm"] repository = "https://github.com/bytecodealliance/wasmtime" readme = "README.md" edition = "2018" +include = ["src/**/*", "LICENSE", "build.rs"] +build = "build.rs" +publish = false [dependencies] -anyhow = "1.0" -tracing = "0.1.15" wasi-common = { path = "../wasi-common", version = "0.22.0" } -wasmtime = { path = "../wasmtime", version = "0.22.0", default-features = false } -wasmtime-runtime = { path = "../runtime", version = "0.22.0" } -wiggle = { path = "../wiggle", version = "0.22.0" } -wasmtime-wiggle = { path = "../wiggle/wasmtime", version = "0.22.0" } - -[badges] -maintenance = { status = "actively-developed" } +wiggle = { path = "../wiggle", default-features = false, version = "0.22.0" } +wasmtime-wiggle = { path = "../wiggle/wasmtime", default-features = false, version = "0.22.0" } +wasmtime = { path = "../wasmtime", version = "0.22.0" } +anyhow = "1.0" diff --git a/crates/wasi/LICENSE b/crates/wasi/LICENSE deleted file mode 100644 index f9d81955f4..0000000000 --- a/crates/wasi/LICENSE +++ /dev/null @@ -1,220 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ---- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - diff --git a/crates/wasi/README.md b/crates/wasi/README.md deleted file mode 100644 index 7f2eaad27f..0000000000 --- a/crates/wasi/README.md +++ /dev/null @@ -1,8 +0,0 @@ -This is the `wasmtime-wasi` crate, which implements the -WebAssembly System Interface (WASI) API in Rust. - -WASI is greatly inspired by and directly derived from [CloudABI]. -It differs in that it has aspirations to expand to a greater -scope, and to better support the needs of WebAssembly engines. - -[CloudABI]: https://cloudabi.org/ diff --git a/crates/wasi/build.rs b/crates/wasi/build.rs index 587437090c..12ace81f5b 100644 --- a/crates/wasi/build.rs +++ b/crates/wasi/build.rs @@ -1,4 +1,6 @@ fn main() { + // wasi-common's links & build.rs ensure this variable points to the wasi root: let wasi_root = std::env::var("DEP_WASI_COMMON_19_WASI").unwrap(); + // Make it available as WASI_ROOT: println!("cargo:rustc-env=WASI_ROOT={}", wasi_root); } diff --git a/crates/wasi/src/lib.rs b/crates/wasi/src/lib.rs index 2276c1db2e..2eaae44404 100644 --- a/crates/wasi/src/lib.rs +++ b/crates/wasi/src/lib.rs @@ -1,13 +1,13 @@ -pub mod old; - -pub use wasi_common::virtfs; -pub use wasi_common::{WasiCtx, WasiCtxBuilder}; +pub use wasi_common::{ + Error, FdFlags, FileCaps, Filestat, OFlags, ReaddirCursor, ReaddirEntity, SystemTimeSpec, + WasiCtx, WasiCtxBuilder, WasiDir, WasiFile, +}; // Defines a `struct Wasi` with member fields and appropriate APIs for dealing // with all the various WASI exports. wasmtime_wiggle::wasmtime_integration!({ // The wiggle code to integrate with lives here: - target: wasi_common::wasi, + target: wasi_common::snapshots::preview_1, // This must be the same witx document as used above. This should be ensured by // the `WASI_ROOT` env variable, which is set in wasi-common's `build.rs`. witx: ["$WASI_ROOT/phases/snapshot/witx/wasi_snapshot_preview1.witx"], @@ -24,13 +24,6 @@ modules. This structure exports all that various fields of the wasi instance as fields which can be used to implement your own instantiation logic, if necessary. Additionally [`Wasi::get_export`] can be used to do name-based resolution.", - } + }, }, }); - -pub fn is_wasi_module(name: &str) -> bool { - // FIXME: this should be more conservative, but while WASI is in flux and - // we're figuring out how to support multiple revisions, this should do the - // trick. - name.starts_with("wasi") -} diff --git a/crates/wasi/src/old/mod.rs b/crates/wasi/src/old/mod.rs deleted file mode 100644 index 5d4d33030a..0000000000 --- a/crates/wasi/src/old/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod snapshot_0; diff --git a/crates/wasi/src/old/snapshot_0.rs b/crates/wasi/src/old/snapshot_0.rs deleted file mode 100644 index f71dee7cdd..0000000000 --- a/crates/wasi/src/old/snapshot_0.rs +++ /dev/null @@ -1,32 +0,0 @@ -pub use wasi_common::virtfs; -pub use wasi_common::{WasiCtx, WasiCtxBuilder}; - -// Defines a `struct Wasi` with member fields and appropriate APIs for dealing -// with all the various WASI exports. -wasmtime_wiggle::wasmtime_integration!({ - // The wiggle code to integrate with lives here: - target: wasi_common::snapshots::wasi_unstable, - // This must be the same witx document as used above. This should be - // ensured by the `WASI_ROOT` env variable, which is set in wasi-common's - // `build.rs`. - witx: ["$WASI_ROOT/phases/old/snapshot_0/witx/wasi_unstable.witx"], - // This must be the same ctx type as used for the target: - ctx: WasiCtx, - // This macro will emit a struct to represent the instance, - // with this name and docs: - modules: { wasi_unstable => - { name: Wasi, - docs: "An instantiated instance of the wasi exports. - -This represents a wasi module which can be used to instantiate other wasm -modules. This structure exports all that various fields of the wasi instance -as fields which can be used to implement your own instantiation logic, if -necessary. Additionally [`Wasi::get_export`] can be used to do name-based -resolution.", - } - }, -}); - -pub fn is_wasi_module(name: &str) -> bool { - crate::is_wasi_module(name) -}