From ab111443be09ed7824833c14958e2efcb8c005f1 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Mon, 2 Dec 2019 15:34:40 -0800 Subject: [PATCH 1/4] Improve default compiler story for wasmer cli This commit reenables the clif compiler as the default for wasmer cli, updates an error message, and adds a compile_error if no backends are enabled. --- Cargo.toml | 2 +- src/bin/wasmer.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 557fade49e3..3d1a6b847d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,7 +74,7 @@ serde = { version = "1", features = ["derive"] } # used by the plugin example typetag = "0.1" # used by the plugin example [features] -default = ["fast-tests", "wasi"] +default = ["fast-tests", "wasi", "backend-cranelift"] "loader-kernel" = ["wasmer-kernel-loader"] debug = ["wasmer-runtime-core/debug"] trace = ["wasmer-runtime-core/trace"] diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 457b6f51060..595c135022e 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -40,6 +40,13 @@ use wasmer_runtime_core::{ #[cfg(feature = "wasi")] use wasmer_wasi; +#[cfg(all( + not(feature = "backend-cranelift"), + not(feature = "backend-llvm"), + not(feature = "backend-singlepass") +))] +compile_error!("Please enable at least one of the compiler backends"); + #[derive(Debug, StructOpt)] #[structopt(name = "wasmer", about = "Wasm execution runtime.", author)] /// The options for the wasmer Command Line Interface @@ -560,7 +567,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> { let compiler: Box = match get_compiler_by_backend(options.backend, options) { Some(x) => x, - None => return Err("the requested backend is not enabled".into()), + None => { + return Err(format!( + "the requested backend, \"{}\", is not enabled", + options.backend.to_string() + )) + } }; #[cfg(feature = "backend-llvm")] From e32a1a637843be1be7d0693999ccf81d2ca3e074 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 6 Dec 2019 10:24:43 -0800 Subject: [PATCH 2/4] Update from feedback; add changelog entry --- CHANGELOG.md | 1 + src/bin/wasmer.rs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 658742c4bdb..1301a1565f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#1033](https://github.com/wasmerio/wasmer/pull/1033) Set cranelift backend as default compiler backend again, require at least one backend to be enabled for Wasmer CLI - [#1006](https://github.com/wasmerio/wasmer/pull/1006) Fix minor panic issue when `wasmer::compile_with` called with llvm backend - [#1009](https://github.com/wasmerio/wasmer/pull/1009) Enable LLVM verifier for all tests, add new llvm-backend-tests crate. - [#1022](https://github.com/wasmerio/wasmer/pull/1022) Add caching support for Singlepass backend. diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 595c135022e..910b2859bfb 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -40,11 +40,11 @@ use wasmer_runtime_core::{ #[cfg(feature = "wasi")] use wasmer_wasi; -#[cfg(all( - not(feature = "backend-cranelift"), - not(feature = "backend-llvm"), - not(feature = "backend-singlepass") -))] +#[cfg(not(any( + feature = "backend-cranelift", + feature = "backend-llvm", + feature = "backend-singlepass" +)))] compile_error!("Please enable at least one of the compiler backends"); #[derive(Debug, StructOpt)] From 448faafd0dea1be47462bb75675e71b546089f5b Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 6 Dec 2019 10:28:20 -0800 Subject: [PATCH 3/4] Apply cargo fmt after GitHub merge --- src/bin/wasmer.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index d333f028e9b..9b09e679879 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -599,7 +599,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> { } let compiler: Box = get_compiler_by_backend(options.backend, options) - .ok_or_else(|| format!("the requested backend, \"{}\", is not enabled", options.backend.to_string()))?; + .ok_or_else(|| { + format!( + "the requested backend, \"{}\", is not enabled", + options.backend.to_string() + ) + })?; #[allow(unused_mut)] let mut backend_specific_config = None; From 0580a117da7527fdfd68a14ede9c98e6e1228a22 Mon Sep 17 00:00:00 2001 From: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com> Date: Fri, 6 Dec 2019 11:54:33 -0800 Subject: [PATCH 4/4] Improve compile error message when no backends set --- src/bin/wasmer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 9b09e679879..222a58ab1c0 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -52,7 +52,7 @@ use wasmer_runtime_core::backend::BackendCompilerConfig; feature = "backend-llvm", feature = "backend-singlepass" )))] -compile_error!("Please enable at least one of the compiler backends"); +compile_error!("Please enable one or more of the compiler backends"); #[derive(Debug, StructOpt)] #[structopt(name = "wasmer", about = "Wasm execution runtime.", author)]