Added cranelift to build-wasmer-wasm

This commit is contained in:
ptitSeb
2022-05-24 14:49:13 +02:00
parent 1607a02535
commit 3d5415dcb9
7 changed files with 15 additions and 9 deletions

2
Cargo.lock generated
View File

@@ -2920,6 +2920,7 @@ dependencies = [
"tempfile", "tempfile",
"unix_mode", "unix_mode",
"wasmer-compiler", "wasmer-compiler",
"wasmer-compiler-cranelift",
"wasmer-compiler-singlepass", "wasmer-compiler-singlepass",
"wasmer-engine-universal-artifact", "wasmer-engine-universal-artifact",
"wasmer-types", "wasmer-types",
@@ -2943,7 +2944,6 @@ dependencies = [
"tracing", "tracing",
"wasmer-compiler", "wasmer-compiler",
"wasmer-types", "wasmer-types",
"wasmer-vm",
] ]
[[package]] [[package]]

View File

@@ -382,7 +382,7 @@ bench:
$(CARGO_BINARY) bench $(CARGO_TARGET) $(compiler_features) $(CARGO_BINARY) bench $(CARGO_TARGET) $(compiler_features)
build-wasmer-wasm: 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 # For best results ensure the release profile looks like the following
# in Cargo.toml: # in Cargo.toml:

View File

@@ -37,9 +37,11 @@ tempfile = "3"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
wasmer-compiler-singlepass = { version = "=2.2.1", path = "../compiler-singlepass", optional = true } 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] [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-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] [target.'cfg(target_os = "linux")'.dependencies]
unix_mode = "0.1.3" unix_mode = "0.1.3"
@@ -59,6 +61,10 @@ singlepass = [
"wasmer-compiler-singlepass", "wasmer-compiler-singlepass",
"compiler", "compiler",
] ]
cranelift = [
"wasmer-compiler-cranelift",
"compiler",
]
debug = ["fern", "log"] debug = ["fern", "log"]
disable-all-logging = [] disable-all-logging = []
jit = ["universal"] jit = ["universal"]

View File

@@ -13,7 +13,6 @@ edition = "2018"
[dependencies] [dependencies]
wasmer-compiler = { path = "../compiler", version = "=2.2.1", features = ["translator"], default-features = false } 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"] } wasmer-types = { path = "../types", version = "=2.2.1", default-features = false, features = ["std"] }
cranelift-entity = { version = "0.82", default-features = false } cranelift-entity = { version = "0.82", default-features = false }
cranelift-codegen = { version = "0.82", default-features = false, features = ["x86", "arm64"] } cranelift-codegen = { version = "0.82", default-features = false, features = ["x86", "arm64"] }
@@ -36,6 +35,7 @@ maintenance = { status = "actively-developed" }
[features] [features]
default = ["std", "unwind", "rayon"] default = ["std", "unwind", "rayon"]
wasm = ["std", "unwind"]
unwind = ["cranelift-codegen/unwind", "gimli"] unwind = ["cranelift-codegen/unwind", "gimli"]
std = ["cranelift-codegen/std", "cranelift-frontend/std", "wasmer-compiler/std", "wasmer-types/std"] std = ["cranelift-codegen/std", "cranelift-frontend/std", "wasmer-compiler/std", "wasmer-types/std"]
core = ["hashbrown", "cranelift-codegen/core", "cranelift-frontend/core"] core = ["hashbrown", "cranelift-codegen/core", "cranelift-frontend/core"]

View File

@@ -33,8 +33,8 @@ use wasmer_compiler::{
}; };
use wasmer_compiler::{CompileError, Relocation}; use wasmer_compiler::{CompileError, Relocation};
use wasmer_types::entity::{EntityRef, PrimaryMap}; use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::TrapCode;
use wasmer_types::{FunctionIndex, LocalFunctionIndex, ModuleInfo, SignatureIndex}; 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, /// A compiler that compiles a WebAssembly module with Cranelift, translating the Wasm to Cranelift IR,
/// optimizing it and then translating to assembly. /// optimizing it and then translating to assembly.
@@ -360,7 +360,7 @@ impl Compiler for CraneliftCompiler {
.into_iter() .into_iter()
.collect::<PrimaryMap<SignatureIndex, FunctionBody>>(); .collect::<PrimaryMap<SignatureIndex, FunctionBody>>();
use wasmer_vm::VMOffsets; use wasmer_types::VMOffsets;
let offsets = VMOffsets::new_for_trampolines(frontend_config.pointer_bytes()); let offsets = VMOffsets::new_for_trampolines(frontend_config.pointer_bytes());
// dynamic function trampolines (only for imported functions) // dynamic function trampolines (only for imported functions)
#[cfg(not(feature = "rayon"))] #[cfg(not(feature = "rayon"))]

View File

@@ -17,13 +17,13 @@ use wasmer_compiler::wasmparser::Type;
use wasmer_compiler::{WasmError, WasmResult}; use wasmer_compiler::{WasmError, WasmResult};
use wasmer_types::entity::EntityRef; use wasmer_types::entity::EntityRef;
use wasmer_types::entity::PrimaryMap; use wasmer_types::entity::PrimaryMap;
use wasmer_types::VMBuiltinFunctionIndex;
use wasmer_types::VMOffsets;
use wasmer_types::{ use wasmer_types::{
FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo, FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo,
SignatureIndex, TableIndex, Type as WasmerType, SignatureIndex, TableIndex, Type as WasmerType,
}; };
use wasmer_vm::VMBuiltinFunctionIndex; use wasmer_types::{MemoryStyle, TableStyle};
use wasmer_vm::VMOffsets;
use wasmer_vm::{MemoryStyle, TableStyle};
/// Compute an `ir::ExternalName` for a given wasm function index. /// Compute an `ir::ExternalName` for a given wasm function index.
pub fn get_function_name(func_index: FunctionIndex) -> ir::ExternalName { pub fn get_function_name(func_index: FunctionIndex) -> ir::ExternalName {

View File

@@ -17,7 +17,7 @@ use std::mem;
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use wasmer_compiler::{CompileError, FunctionBody}; use wasmer_compiler::{CompileError, FunctionBody};
use wasmer_types::FunctionType; use wasmer_types::FunctionType;
use wasmer_vm::VMOffsets; use wasmer_types::VMOffsets;
/// Create a trampoline for invoking a WebAssembly function. /// Create a trampoline for invoking a WebAssembly function.
pub fn make_trampoline_dynamic_function( pub fn make_trampoline_dynamic_function(