diff --git a/Cargo.lock b/Cargo.lock index 8ed2b91e2..fc1d28d05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2920,6 +2920,7 @@ dependencies = [ "tempfile", "unix_mode", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-engine-universal-artifact", "wasmer-types", @@ -2943,7 +2944,6 @@ dependencies = [ "tracing", "wasmer-compiler", "wasmer-types", - "wasmer-vm", ] [[package]] diff --git a/Makefile b/Makefile index 8af9d5387..f75a947f1 100644 --- a/Makefile +++ b/Makefile @@ -382,7 +382,7 @@ bench: $(CARGO_BINARY) bench $(CARGO_TARGET) $(compiler_features) build-wasmer-wasm: - cargo build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,universal --bin wasmer-compiler + cargo build --release --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift,universal --bin wasmer-compiler # For best results ensure the release profile looks like the following # in Cargo.toml: diff --git a/lib/cli-compiler/Cargo.toml b/lib/cli-compiler/Cargo.toml index fcc01acd6..2d2f94745 100644 --- a/lib/cli-compiler/Cargo.toml +++ b/lib/cli-compiler/Cargo.toml @@ -37,9 +37,11 @@ tempfile = "3" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] wasmer-compiler-singlepass = { version = "=2.2.1", path = "../compiler-singlepass", optional = true } +wasmer-compiler-cranelift = { version = "=2.2.1", path = "../compiler-cranelift", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] wasmer-compiler-singlepass = { version = "=2.2.1", path = "../compiler-singlepass", optional = true, default-features = false, features = ["wasm"] } +wasmer-compiler-cranelift = { version = "=2.2.1", path = "../compiler-cranelift", optional = true, default-features = false, features = ["wasm"] } [target.'cfg(target_os = "linux")'.dependencies] unix_mode = "0.1.3" @@ -59,6 +61,10 @@ singlepass = [ "wasmer-compiler-singlepass", "compiler", ] +cranelift = [ + "wasmer-compiler-cranelift", + "compiler", +] debug = ["fern", "log"] disable-all-logging = [] jit = ["universal"] diff --git a/lib/compiler-cranelift/Cargo.toml b/lib/compiler-cranelift/Cargo.toml index eeaf202d9..e392f6446 100644 --- a/lib/compiler-cranelift/Cargo.toml +++ b/lib/compiler-cranelift/Cargo.toml @@ -13,7 +13,6 @@ edition = "2018" [dependencies] wasmer-compiler = { path = "../compiler", version = "=2.2.1", features = ["translator"], default-features = false } -wasmer-vm = { path = "../vm", version = "=2.2.1" } wasmer-types = { path = "../types", version = "=2.2.1", default-features = false, features = ["std"] } cranelift-entity = { version = "0.82", default-features = false } cranelift-codegen = { version = "0.82", default-features = false, features = ["x86", "arm64"] } @@ -36,6 +35,7 @@ maintenance = { status = "actively-developed" } [features] default = ["std", "unwind", "rayon"] +wasm = ["std", "unwind"] unwind = ["cranelift-codegen/unwind", "gimli"] std = ["cranelift-codegen/std", "cranelift-frontend/std", "wasmer-compiler/std", "wasmer-types/std"] core = ["hashbrown", "cranelift-codegen/core", "cranelift-frontend/core"] diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index c09b264f7..63dd7822d 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -33,8 +33,8 @@ use wasmer_compiler::{ }; use wasmer_compiler::{CompileError, Relocation}; use wasmer_types::entity::{EntityRef, PrimaryMap}; +use wasmer_types::TrapCode; use wasmer_types::{FunctionIndex, LocalFunctionIndex, ModuleInfo, SignatureIndex}; -use wasmer_vm::TrapCode; /// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR, /// optimizing it and then translating to assembly. @@ -360,7 +360,7 @@ impl Compiler for CraneliftCompiler { .into_iter() .collect::>(); - use wasmer_vm::VMOffsets; + use wasmer_types::VMOffsets; let offsets = VMOffsets::new_for_trampolines(frontend_config.pointer_bytes()); // dynamic function trampolines (only for imported functions) #[cfg(not(feature = "rayon"))] diff --git a/lib/compiler-cranelift/src/func_environ.rs b/lib/compiler-cranelift/src/func_environ.rs index 95a39b133..891522cc2 100644 --- a/lib/compiler-cranelift/src/func_environ.rs +++ b/lib/compiler-cranelift/src/func_environ.rs @@ -17,13 +17,13 @@ use wasmer_compiler::wasmparser::Type; use wasmer_compiler::{WasmError, WasmResult}; use wasmer_types::entity::EntityRef; use wasmer_types::entity::PrimaryMap; +use wasmer_types::VMBuiltinFunctionIndex; +use wasmer_types::VMOffsets; use wasmer_types::{ FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo, SignatureIndex, TableIndex, Type as WasmerType, }; -use wasmer_vm::VMBuiltinFunctionIndex; -use wasmer_vm::VMOffsets; -use wasmer_vm::{MemoryStyle, TableStyle}; +use wasmer_types::{MemoryStyle, TableStyle}; /// Compute an `ir::ExternalName` for a given wasm function index. pub fn get_function_name(func_index: FunctionIndex) -> ir::ExternalName { diff --git a/lib/compiler-cranelift/src/trampoline/dynamic_function.rs b/lib/compiler-cranelift/src/trampoline/dynamic_function.rs index 49b7b695c..9ebaad894 100644 --- a/lib/compiler-cranelift/src/trampoline/dynamic_function.rs +++ b/lib/compiler-cranelift/src/trampoline/dynamic_function.rs @@ -17,7 +17,7 @@ use std::mem; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use wasmer_compiler::{CompileError, FunctionBody}; use wasmer_types::FunctionType; -use wasmer_vm::VMOffsets; +use wasmer_types::VMOffsets; /// Create a trampoline for invoking a WebAssembly function. pub fn make_trampoline_dynamic_function(