diff --git a/Cargo.toml b/Cargo.toml index 4d619059e..93479c415 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ wabt = "0.9.1" 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 = { path = "lib/runtime", default-features = false } wasmer-runtime-core = { path = "lib/runtime-core" } wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } @@ -101,6 +101,8 @@ backend-singlepass = [ wasi = ["wasmer-wasi"] managed = ["backend-singlepass", "wasmer-runtime-core/managed"] +deterministic = ["wasmer-runtime/deterministic"] + [[example]] name = "plugin" crate-type = ["bin"] diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index 7fd9e32e8..ee1fd19eb 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -58,3 +58,4 @@ trace = ["debug"] "backend-singlepass" = [] "backend-llvm" = [] managed = [] +deterministic = ["wasmparser/deterministic"] diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 3db1b3743..7027d6266 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -145,6 +145,9 @@ pub fn validating_parser_config(features: &Features) -> wasmparser::ValidatingPa enable_simd: features.simd, enable_bulk_memory: false, enable_multi_value: false, + + #[cfg(feature = "deterministic")] + deterministic_only: true, }, } } diff --git a/lib/runtime-core/src/lib.rs b/lib/runtime-core/src/lib.rs index 26a76f7db..d933b555f 100644 --- a/lib/runtime-core/src/lib.rs +++ b/lib/runtime-core/src/lib.rs @@ -145,6 +145,9 @@ pub fn validate_and_report_errors_with_features( enable_multi_value: false, enable_reference_types: false, enable_threads: features.threads, + + #[cfg(feature = "deterministic")] + deterministic_only: true, }, }; let mut parser = wasmparser::ValidatingParser::new(wasm, Some(config)); diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 2e42055c2..a3a59f7e5 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -41,6 +41,7 @@ singlepass = ["wasmer-singlepass-backend"] default-backend-singlepass = ["singlepass"] default-backend-llvm = ["llvm"] default-backend-cranelift = ["cranelift"] +deterministic = ["wasmer-singlepass-backend/deterministic"] [[bench]] name = "nginx" diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 2945ff3d5..3505de649 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -70,7 +70,7 @@ //! let value = add_one.call(42)?; //! //! assert_eq!(value, 43); -//! +//! //! Ok(()) //! } //! ``` @@ -199,13 +199,15 @@ pub fn default_compiler() -> impl Compiler { feature = "default-backend-llvm", any( feature = "default-backend-cranelift", - feature = "default-backend-singlepass" + feature = "default-backend-singlepass", + feature = "deterministic" ) ), all( feature = "default-backend-cranelift", - feature = "default-backend-singlepass" - ) + any(feature = "default-backend-singlepass", feature = "deterministic") + ), + all(feature = "default-backend-singlepass", feature = "deterministic") ))] compile_error!( "The `default-backend-X` features are mutually exclusive. Please choose just one" @@ -214,7 +216,7 @@ pub fn default_compiler() -> impl Compiler { #[cfg(feature = "default-backend-llvm")] use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler; - #[cfg(feature = "default-backend-singlepass")] + #[cfg(any(feature = "default-backend-singlepass", feature = "deterministic"))] use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler; #[cfg(feature = "default-backend-cranelift")] diff --git a/lib/singlepass-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml index 5243cc601..d6dc63c7a 100644 --- a/lib/singlepass-backend/Cargo.toml +++ b/lib/singlepass-backend/Cargo.toml @@ -18,3 +18,7 @@ byteorder = "1.3" nix = "0.15" libc = "0.2.60" smallvec = "0.6" + +[features] +default = [] +deterministic = ["wasmparser/deterministic", "wasmer-runtime-core/deterministic"]