From f639dd91f24569246c02f01698a879eec4953060 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 16 Aug 2021 15:48:26 +0200 Subject: [PATCH 1/4] fix(vfs) Make `host_fs` the default file system. --- lib/vfs/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vfs/Cargo.toml b/lib/vfs/Cargo.toml index 7a3dd8e6df4..02e1e43b6f7 100644 --- a/lib/vfs/Cargo.toml +++ b/lib/vfs/Cargo.toml @@ -14,6 +14,7 @@ typetag = { version = "0.1", optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } [features] +default = ["host_fs"] host_fs = ["libc"] mem_fs = [] enable-serde = [ From 52be548680ce8d4d19b53360bf4a462b97f53e3d Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 16 Aug 2021 15:48:48 +0200 Subject: [PATCH 2/4] feat(vfs) Make `host_fs` and `mem_fs` mutually exclusives. This patch generates a compiler error if `host_fs` and `mem_fs` are both enabled at compile-time. It also generates a compiler error if none of them have been enabled. --- lib/vfs/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vfs/src/lib.rs b/lib/vfs/src/lib.rs index 601a8d7915c..77eb095cf75 100644 --- a/lib/vfs/src/lib.rs +++ b/lib/vfs/src/lib.rs @@ -6,6 +6,12 @@ use std::path::{Path, PathBuf}; use thiserror::Error; use tracing::debug; +#[cfg(all(not(feature = "host_fs"), not(feature = "mem_fs")))] +compile_error!("At least the `host_fs` or the `mem_fs` feature must be enabled. Please, pick one."); + +#[cfg(all(feature = "host_fs", feature = "mem_fs"))] +compile_error!("The `host_fs` and `mem_fs` features are mutually exclusive."); + #[cfg(feature = "host_fs")] pub mod host_fs; //pub mod vfs_fs; From 5b53c5497a57483450a85fd3e116e5658d1611db Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 16 Aug 2021 15:54:19 +0200 Subject: [PATCH 3/4] fix(c-api,cli) Use the default features from `wasmer-wasi`. `wasmer-wasi`'s default features don't change, except that it adds `host_fs` in the default features, which maps to `wasmer-vfs/host_fs`. It then ensures that the same behavior is guaranteed. We don't need to change how `wasmer-cli` and `wasmer-c-api` fetch `wasmer-wasi` in this case. --- lib/c-api/Cargo.toml | 2 +- lib/cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index 9b9fca8ff61..5335789a708 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -32,7 +32,7 @@ wasmer-engine-universal = { version = "2.0.0", path = "../engine-universal", opt wasmer-engine-dylib = { version = "2.0.0", path = "../engine-dylib", optional = true } wasmer-engine-staticlib = { version = "2.0.0", path = "../engine-staticlib", optional = true } wasmer-middlewares = { version = "2.0.0", path = "../middlewares", optional = true } -wasmer-wasi = { version = "2.0.0", path = "../wasi", default-features = false, features = ["host_fs"], optional = true } +wasmer-wasi = { version = "2.0.0", path = "../wasi", optional = true } wasmer-types = { version = "2.0.0", path = "../types" } enumset = "1.0" cfg-if = "1.0" diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 98f248b48e7..887623da1b7 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -35,7 +35,7 @@ wasmer-engine-universal = { version = "2.0.0", path = "../engine-universal", opt wasmer-engine-dylib = { version = "2.0.0", path = "../engine-dylib", optional = true } wasmer-engine-staticlib = { version = "2.0.0", path = "../engine-staticlib", optional = true } wasmer-vm = { version = "2.0.0", path = "../vm" } -wasmer-wasi = { version = "2.0.0", path = "../wasi", default-features = false, features = ["host_fs"], optional = true } +wasmer-wasi = { version = "2.0.0", path = "../wasi", optional = true } wasmer-wasi-experimental-io-devices = { version = "2.0.0", path = "../wasi-experimental-io-devices", optional = true } wasmer-wast = { version = "2.0.0", path = "../../tests/lib/wast", optional = true } wasmer-cache = { version = "2.0.0", path = "../cache", optional = true } From 01724637ae0a5be6e2d09a3b68c34f575c923573 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 17 Aug 2021 09:25:33 +0200 Subject: [PATCH 4/4] feat(vfs) `host_fs` and `mem_fs` are not mutually exclusive. --- lib/vfs/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/vfs/src/lib.rs b/lib/vfs/src/lib.rs index e4f4db6b985..790f03781b3 100644 --- a/lib/vfs/src/lib.rs +++ b/lib/vfs/src/lib.rs @@ -9,9 +9,6 @@ use tracing::debug; #[cfg(all(not(feature = "host_fs"), not(feature = "mem_fs")))] compile_error!("At least the `host_fs` or the `mem_fs` feature must be enabled. Please, pick one."); -#[cfg(all(feature = "host_fs", feature = "mem_fs"))] -compile_error!("The `host_fs` and `mem_fs` features are mutually exclusive."); - #[cfg(feature = "host_fs")] pub mod host_fs; #[cfg(feature = "mem_fs")]