diff --git a/.circleci/config.yml b/.circleci/config.yml index c588234dc..67309e903 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -152,7 +152,7 @@ jobs: sudo apt-get install -y cmake curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz - # Use rust nightly (for dynasm, for now) + # Use rust nightly (for singlepass, for now) - run: rustup default nightly-2019-04-11 - run: name: Tests @@ -220,7 +220,7 @@ jobs: curl https://sh.rustup.rs -sSf | sh -s -- -y export PATH="$HOME/.cargo/bin:$PATH" cargo --version - # Use rust nightly (for dynasm, for now) + # Use rust nightly (for singlepass, for now) - run: rustup default nightly-2019-04-11 - run: name: Tests @@ -242,7 +242,7 @@ jobs: ulimit -n 8000 sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680 make test-emscripten-clif - make test-emscripten-dynasm + make test-emscripten-singlepass - run: name: Release Build command: | @@ -288,9 +288,9 @@ jobs: - run: | export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/" make test - make test-dynasm + make test-singlepass make test-emscripten-clif - make test-emscripten-dynasm + make test-emscripten-singlepass - save_cache: paths: - /usr/local/cargo/registry diff --git a/Cargo.lock b/Cargo.lock index 1e81b086e..e42dd7265 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2230,12 +2230,12 @@ dependencies = [ "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.2.0", - "wasmer-dynasm-backend 0.1.0", "wasmer-emscripten 0.2.1", "wasmer-llvm-backend 0.1.0", "wasmer-runtime 0.2.1", "wasmer-runtime-abi 0.2.1", "wasmer-runtime-core 0.2.1", + "wasmer-singlepass-backend 0.1.0", "wasmer-wasi 0.2.1", ] @@ -2263,22 +2263,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "wasmer-dynasm-backend" -version = "0.1.0" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-runtime-core 0.2.1", - "wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "wasmer-emscripten" version = "0.2.1" @@ -2291,9 +2275,9 @@ dependencies = [ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.2.0", - "wasmer-dynasm-backend 0.1.0", "wasmer-llvm-backend 0.1.0", "wasmer-runtime-core 0.2.1", + "wasmer-singlepass-backend 0.1.0", ] [[package]] @@ -2327,9 +2311,9 @@ dependencies = [ "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.2.0", - "wasmer-dynasm-backend 0.1.0", "wasmer-llvm-backend 0.1.0", "wasmer-runtime-core 0.2.1", + "wasmer-singlepass-backend 0.1.0", ] [[package]] @@ -2381,15 +2365,31 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasmer-singlepass-backend" +version = "0.1.0" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-runtime-core 0.2.1", + "wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmer-spectests" version = "0.2.0" dependencies = [ "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.2.0", - "wasmer-dynasm-backend 0.1.0", "wasmer-llvm-backend 0.1.0", "wasmer-runtime-core 0.2.1", + "wasmer-singlepass-backend 0.1.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 244581f8d..5624b659a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ structopt = "0.2.11" wabt = "0.7.2" hashbrown = "0.1.8" wasmer-clif-backend = { path = "lib/clif-backend" } -wasmer-dynasm-backend = { path = "lib/dynasm-backend", optional = true } +wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } wasmer-runtime = { path = "lib/runtime" } wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true } wasmer-runtime-core = { path = "lib/runtime-core" } @@ -33,7 +33,7 @@ wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } wasmer-wasi = { path = "lib/wasi", optional = true } [workspace] -members = ["lib/clif-backend", "lib/dynasm-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"] [build-dependencies] wabt = "0.7.2" @@ -45,6 +45,6 @@ debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] # This feature will allow cargo test to run much faster fast-tests = [] llvm = ["wasmer-llvm-backend", "wasmer-runtime/llvm"] -dynasm = ["wasmer-dynasm-backend", "wasmer-runtime/dynasm"] +singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/singlepass"] wasi = ["wasmer-wasi"] vfs = ["wasmer-runtime-abi"] diff --git a/Makefile b/Makefile index 947032873..2b87dd7e7 100644 --- a/Makefile +++ b/Makefile @@ -34,15 +34,15 @@ precommit: lint test test: # We use one thread so the emscripten stdouts doesn't collide - cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-dynasm-backend -- $(runargs) + cargo test --all --exclude wasmer-runtime-c-api --exclude wasmer-emscripten --exclude wasmer-spectests --exclude wasmer-singlepass-backend -- $(runargs) # cargo test --all --exclude wasmer-emscripten -- --test-threads=1 $(runargs) cargo test --manifest-path lib/spectests/Cargo.toml --features clif cargo test --manifest-path lib/spectests/Cargo.toml --features llvm cargo build -p wasmer-runtime-c-api cargo test -p wasmer-runtime-c-api -- --nocapture -test-dynasm: - cargo test --manifest-path lib/spectests/Cargo.toml --features dynasm +test-singlepass: + cargo test --manifest-path lib/spectests/Cargo.toml --features singlepass test-emscripten-llvm: cargo test --manifest-path lib/emscripten/Cargo.toml --features llvm -- --test-threads=1 $(runargs) @@ -50,17 +50,17 @@ test-emscripten-llvm: test-emscripten-clif: cargo test --manifest-path lib/emscripten/Cargo.toml --features clif -- --test-threads=1 $(runargs) -test-emscripten-dynasm: - cargo test --manifest-path lib/emscripten/Cargo.toml --features dynasm -- --test-threads=1 $(runargs) +test-emscripten-singlepass: + cargo test --manifest-path lib/emscripten/Cargo.toml --features singlepass -- --test-threads=1 $(runargs) -dynasm-debug-release: - cargo +nightly build --features "dynasm debug" --release +singlepass-debug-release: + cargo +nightly build --features "singlepass debug" --release -dynasm-release: - cargo +nightly build --features "dynasm" --release +singlepass-release: + cargo +nightly build --features "singlepass" --release -dynasm-build: - cargo +nightly build --features "dynasm debug" +singlepass-build: + cargo +nightly build --features "singlepass debug" release: # If you are in OS-X, you will need mingw-w64 for cross compiling to windows diff --git a/lib/README.md b/lib/README.md index b8a99dd6d..83a335588 100644 --- a/lib/README.md +++ b/lib/README.md @@ -34,6 +34,6 @@ to tune the codegen properties (compile speed, performance, etc) to best fit the Currently, we support multiple backends for compiling WebAssembly to machine code: -- [dynasm-backend](./dynasm-backend/): Dynasm backend - super fast compilation, slower runtime speed +- [singlepass-backend](./singlepass-backend/): Single pass backend - super fast compilation, slower runtime speed - [clif-backend](./clif-backend/): Cranelift backend - slower compilation, normal runtime speed - [llvm-backend](./llvm-backend/): LLVM backend - slow compilation, native runtime speed diff --git a/lib/emscripten/Cargo.toml b/lib/emscripten/Cargo.toml index 5c59db350..8b19340b0 100644 --- a/lib/emscripten/Cargo.toml +++ b/lib/emscripten/Cargo.toml @@ -15,7 +15,7 @@ libc = "0.2.49" byteorder = "1" time = "0.1.41" wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" } -wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true } +wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true } wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true } [target.'cfg(windows)'.dependencies] @@ -30,5 +30,5 @@ glob = "0.2.11" [features] clif = [] llvm = ["wasmer-llvm-backend"] -dynasm = ["wasmer-dynasm-backend"] +singlepass = ["wasmer-singlepass-backend"] debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] diff --git a/lib/emscripten/src/utils.rs b/lib/emscripten/src/utils.rs index 725f0ba94..e1cf13ef5 100644 --- a/lib/emscripten/src/utils.rs +++ b/lib/emscripten/src/utils.rs @@ -186,13 +186,13 @@ mod tests { LLVMCompiler::new() } - #[cfg(feature = "dynasm")] + #[cfg(feature = "singlepass")] fn get_compiler() -> impl Compiler { - use wasmer_dynasm_backend::SinglePassCompiler; + use wasmer_singlepass_backend::SinglePassCompiler; SinglePassCompiler::new() } - #[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))] + #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] fn get_compiler() -> impl Compiler { panic!("compiler not specified, activate a compiler via features"); use wasmer_clif_backend::CraneliftCompiler; diff --git a/lib/emscripten/tests/emtests/_common.rs b/lib/emscripten/tests/emtests/_common.rs index ca5f60282..18664e4ea 100644 --- a/lib/emscripten/tests/emtests/_common.rs +++ b/lib/emscripten/tests/emtests/_common.rs @@ -20,13 +20,13 @@ macro_rules! assert_emscripten_output { LLVMCompiler::new() } - #[cfg(feature = "dynasm")] + #[cfg(feature = "singlepass")] fn get_compiler() -> impl Compiler { - use wasmer_dynasm_backend::SinglePassCompiler; + use wasmer_singlepass_backend::SinglePassCompiler; SinglePassCompiler::new() } - #[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))] + #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] fn get_compiler() -> impl Compiler { panic!("compiler not specified, activate a compiler via features"); use wasmer_clif_backend::CraneliftCompiler; diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index 1e528651d..1044a7ee5 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -25,7 +25,7 @@ pub use crate::sig_registry::SigRegistry; #[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] pub enum Backend { Cranelift, - Dynasm, + Singlepass, LLVM, } diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index c137922f0..f34798bf5 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" readme = "README.md" [dependencies] -wasmer-dynasm-backend = { path = "../dynasm-backend", optional = true } +wasmer-singlepass-backend = { path = "../singlepass-backend", optional = true } lazy_static = "1.2.0" memmap = "0.7.0" @@ -37,7 +37,7 @@ default-compiler = ["wasmer-clif-backend"] cache = ["default-compiler"] debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] llvm = ["wasmer-llvm-backend"] -dynasm = ["wasmer-dynasm-backend"] +singlepass = ["wasmer-singlepass-backend"] [[bench]] name = "nginx" diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index a45faddc1..f9a9ce819 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -171,10 +171,10 @@ pub fn default_compiler() -> &'static dyn Compiler { #[cfg(feature = "llvm")] use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler; - #[cfg(feature = "dynasm")] - use wasmer_dynasm_backend::SinglePassCompiler as DefaultCompiler; + #[cfg(feature = "singlepass")] + use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler; - #[cfg(not(any(feature = "llvm", feature = "dynasm")))] + #[cfg(not(any(feature = "llvm", feature = "singlepass")))] use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler; lazy_static! { diff --git a/lib/dynasm-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml similarity index 81% rename from lib/dynasm-backend/Cargo.toml rename to lib/singlepass-backend/Cargo.toml index 3f6ef8667..977a3eac6 100644 --- a/lib/dynasm-backend/Cargo.toml +++ b/lib/singlepass-backend/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "wasmer-dynasm-backend" +name = "wasmer-singlepass-backend" version = "0.1.0" repository = "https://github.com/wasmerio/wasmer" -description = "Wasmer runtime Dynasm compiler backend" +description = "Wasmer runtime single pass compiler backend" license = "MIT" authors = ["The Wasmer Engineering Team "] edition = "2018" diff --git a/lib/dynasm-backend/README.md b/lib/singlepass-backend/README.md similarity index 68% rename from lib/dynasm-backend/README.md rename to lib/singlepass-backend/README.md index a525cbfac..3d8c63615 100644 --- a/lib/dynasm-backend/README.md +++ b/lib/singlepass-backend/README.md @@ -14,18 +14,18 @@ Join the Wasmer Community - - Number of downloads from crates.io + + Number of downloads from crates.io - - Read our API documentation + + Read our API documentation

-# Wasmer dynasm backend +# Wasmer singlepass backend Wasmer is a standalone JIT WebAssembly runtime, aiming to be fully compatible with Emscripten, Rust and Go. [Learn more](https://github.com/wasmerio/wasmer). -This crate represents the dynasm backend. +This crate represents the singlepass backend. diff --git a/lib/dynasm-backend/src/codegen.rs b/lib/singlepass-backend/src/codegen.rs similarity index 100% rename from lib/dynasm-backend/src/codegen.rs rename to lib/singlepass-backend/src/codegen.rs diff --git a/lib/dynasm-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs similarity index 100% rename from lib/dynasm-backend/src/codegen_x64.rs rename to lib/singlepass-backend/src/codegen_x64.rs diff --git a/lib/dynasm-backend/src/emitter_x64.rs b/lib/singlepass-backend/src/emitter_x64.rs similarity index 100% rename from lib/dynasm-backend/src/emitter_x64.rs rename to lib/singlepass-backend/src/emitter_x64.rs diff --git a/lib/dynasm-backend/src/lib.rs b/lib/singlepass-backend/src/lib.rs similarity index 90% rename from lib/dynasm-backend/src/lib.rs rename to lib/singlepass-backend/src/lib.rs index 0092b7302..cdb275cd3 100644 --- a/lib/dynasm-backend/src/lib.rs +++ b/lib/singlepass-backend/src/lib.rs @@ -41,7 +41,7 @@ impl CacheGen for Placeholder { _module: &ModuleInner, ) -> Result<(Box, Box<[u8]>, Memory), CacheError> { Err(CacheError::Unknown( - "the dynasm backend doesn't support caching yet".to_string(), + "the singlepass backend doesn't support caching yet".to_string(), )) } } @@ -61,7 +61,7 @@ impl Compiler for SinglePassCompiler { _: Token, ) -> CompileResult { let mut mcg = codegen_x64::X64ModuleCodeGenerator::new(); - let info = parse::read_module(wasm, Backend::Dynasm, &mut mcg, &compiler_config)?; + let info = parse::read_module(wasm, Backend::Singlepass, &mut mcg, &compiler_config)?; let (ec, resolver) = mcg.finalize(&info)?; Ok(ModuleInner { cache_gen: Box::new(Placeholder), @@ -73,7 +73,7 @@ impl Compiler for SinglePassCompiler { unsafe fn from_cache(&self, _artifact: Artifact, _: Token) -> Result { Err(CacheError::Unknown( - "the dynasm backend doesn't support caching yet".to_string(), + "the singlepass backend doesn't support caching yet".to_string(), )) } } diff --git a/lib/dynasm-backend/src/machine.rs b/lib/singlepass-backend/src/machine.rs similarity index 100% rename from lib/dynasm-backend/src/machine.rs rename to lib/singlepass-backend/src/machine.rs diff --git a/lib/dynasm-backend/src/parse.rs b/lib/singlepass-backend/src/parse.rs similarity index 100% rename from lib/dynasm-backend/src/parse.rs rename to lib/singlepass-backend/src/parse.rs diff --git a/lib/dynasm-backend/src/protect_unix.rs b/lib/singlepass-backend/src/protect_unix.rs similarity index 100% rename from lib/dynasm-backend/src/protect_unix.rs rename to lib/singlepass-backend/src/protect_unix.rs diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index 8dd8f83f4..d19fdab6d 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -12,7 +12,7 @@ build = "build/mod.rs" wasmer-runtime-core = { path = "../runtime-core", version = "0.2.0" } wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" } wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true } -wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0", optional = true } +wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.1.0", optional = true } [build-dependencies] wabt = "0.7.2" @@ -25,4 +25,4 @@ default = ["fast-tests"] fast-tests = [] clif = [] llvm = ["wasmer-llvm-backend"] -dynasm = ["wasmer-dynasm-backend"] \ No newline at end of file +singlepass = ["wasmer-singlepass-backend"] diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index a13faefd1..10fb45678 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -107,13 +107,13 @@ fn get_compiler() -> impl Compiler { LLVMCompiler::new() } -#[cfg(feature = "dynasm")] +#[cfg(feature = "singlepass")] fn get_compiler() -> impl Compiler { - use wasmer_dynasm_backend::SinglePassCompiler; + use wasmer_singlepass_backend::SinglePassCompiler; SinglePassCompiler::new() } -#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))] +#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] fn get_compiler() -> impl Compiler { panic!("compiler not specified, activate a compiler via features"); use wasmer_clif_backend::CraneliftCompiler; diff --git a/lib/spectests/examples/simple/main.rs b/lib/spectests/examples/simple/main.rs index c61cdb18f..357adb5f7 100644 --- a/lib/spectests/examples/simple/main.rs +++ b/lib/spectests/examples/simple/main.rs @@ -22,13 +22,13 @@ fn get_compiler() -> impl Compiler { LLVMCompiler::new() } -#[cfg(feature = "dynasm")] +#[cfg(feature = "singlepass")] fn get_compiler() -> impl Compiler { - use wasmer_dynasm_backend::SinglePassCompiler; + use wasmer_singlepass_backend::SinglePassCompiler; SinglePassCompiler::new() } -#[cfg(not(any(feature = "llvm", feature = "clif", feature = "dynasm")))] +#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] fn get_compiler() -> impl Compiler { panic!("compiler not specified, activate a compiler via features"); use wasmer_clif_backend::CraneliftCompiler; diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 345503558..b6211a801 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -6,6 +6,7 @@ use std::io; use std::io::Read; use std::path::PathBuf; use std::process::exit; +use std::str::FromStr; use hashbrown::HashMap; use structopt::StructOpt; @@ -62,13 +63,36 @@ struct Run { #[structopt(parse(from_os_str))] path: PathBuf, - /// Application arguments - #[structopt(name = "--", raw(multiple = "true"))] - args: Vec, + // Disable the cache + #[structopt(long = "backend", default_value="cranelift")] + backend: Backend, /// Emscripten symbol map #[structopt(long = "em-symbol-map", parse(from_os_str))] em_symbol_map: Option, + + /// Application arguments + #[structopt(name = "--", raw(multiple = "true"))] + args: Vec, +} + +#[derive(Debug)] +enum Backend { + Cranelift, + Singlepass, + LLVM, +} + +impl FromStr for Backend { + type Err = String; + fn from_str(s: &str) -> Result { + match s { + "singlepass" => Ok(Backend::Singlepass), + "cranelift" => Ok(Backend::Cranelift), + "llvm" => Ok(Backend::LLVM), + _ => Err(format!("The backend {} doesn't exist", s)) + } + } } #[derive(Debug, StructOpt)]