From 3ba355dda431023c8a3e1a1be3bc9ab7a8ac04a7 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Thu, 5 Dec 2019 15:04:05 -0800 Subject: [PATCH] Remove deterministic flag setting default compiler; add auto logic --- Makefile | 6 ++++++ lib/runtime/src/lib.rs | 39 ++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 4acde792584..935a6a69218 100644 --- a/Makefile +++ b/Makefile @@ -192,6 +192,12 @@ check: check-bench # as default, and test a minimal set of features with only one backend # at a time. cargo check --manifest-path lib/runtime/Cargo.toml + # Check some of the cases where deterministic execution could matter + cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution" + cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ + --features=default-backend-singlepass,deterministic-execution + cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \ + --features=default-backend-llvm,deterministic-execution cargo check --release --manifest-path lib/runtime/Cargo.toml $(RUNTIME_CHECK) \ diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 13b3dd8d4e7..58046148290 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -211,21 +211,13 @@ pub fn default_compiler() -> impl Compiler { not(feature = "docs"), any( feature = "default-backend-cranelift", - feature = "default-backend-singlepass", - feature = "deterministic-execution" + feature = "default-backend-singlepass" ) ), all( not(feature = "docs"), feature = "default-backend-cranelift", - any( - feature = "default-backend-singlepass", - feature = "deterministic-execution" - ) - ), - all( - feature = "default-backend-singlepass", - feature = "deterministic-execution" + feature = "default-backend-singlepass" ) ))] compile_error!( @@ -235,13 +227,7 @@ pub fn default_compiler() -> impl Compiler { #[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))] use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler; - #[cfg(all( - any( - feature = "default-backend-singlepass", - all(feature = "deterministic-execution", feature = "singlepass") - ), - not(feature = "docs") - ))] + #[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))] use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler; #[cfg(any(feature = "default-backend-cranelift", feature = "docs"))] @@ -260,7 +246,7 @@ pub fn compiler_for_backend(backend: Backend) -> Option> { #[cfg(feature = "cranelift")] Backend::Cranelift => Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())), - #[cfg(any(feature = "singlepass", feature = "deterministic-execution"))] + #[cfg(any(feature = "singlepass"))] Backend::Singlepass => Some(Box::new( wasmer_singlepass_backend::SinglePassCompiler::new(), )), @@ -268,11 +254,18 @@ pub fn compiler_for_backend(backend: Backend) -> Option> { #[cfg(feature = "llvm")] Backend::LLVM => Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())), - #[cfg(not(all( - feature = "llvm", - any(feature = "singlepass", feature = "deterministic-execution"), - feature = "cranelift", - )))] + Backend::Auto => { + #[cfg(feature = "default-backend-singlepass")] + return Some(Box::new( + wasmer_singlepass_backend::SinglePassCompiler::new(), + )); + #[cfg(feature = "default-backend-cranelift")] + return Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())); + #[cfg(feature = "default-backend-llvm")] + return Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())); + } + + #[cfg(not(all(feature = "llvm", feature = "singlepass", feature = "cranelift")))] _ => None, } }