Skip to content

Commit

Permalink
chore(vm): add llvm feature
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya committed Mar 15, 2022
1 parent 419e986 commit ccf55b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ readme = "./README.md"


[target.'cfg(not(target_family="wasm"))'.dev-dependencies]
wasmy-vm = "0.5.5"
wasmy-vm = { version ="0.5.5", features = [] }
structopt = { version = "0.3", features = ["color"] }
tokio = { version = "1.17.0", features = ["macros", "rt", "rt-multi-thread"] }
[[example]]
Expand Down
5 changes: 4 additions & 1 deletion wasmy-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ inventory = "0.2.2"
wasmer = "2.0.0"
wasmer-engine-universal = "2.0.0"
wasmer-wasi = "2.0.0"
wasmer-compiler-cranelift = { version = "2.0.0" }
wasmer-compiler-cranelift = { version = "2.0.0", optional = true }
wasmer-compiler-llvm = { version = "2.0.0", optional = true }
serde = { version = "1.0", features = ["derive"] }
anyhow = "1"
protobuf = { version = "2", features = ["with-bytes"] }
lazy_static = "1.4.0"

[features]
default = ["wasmer-compiler-cranelift"]
llvm = ["wasmer-compiler-llvm"]
16 changes: 14 additions & 2 deletions wasmy-vm/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{collections::HashMap, sync::RwLock};

use lazy_static;
use wasmer::{ImportObject, Store, Type};
use wasmer_compiler_cranelift::Cranelift;
use wasmer_engine_universal::Universal;
use wasmer_wasi::{WasiState, WasiStateBuilder};
use wasmy_abi::{CodeMsg, Result, CODE_EXPORTS};
Expand Down Expand Up @@ -42,7 +41,20 @@ where

#[cfg(debug_assertions)]
println!("compiling module, wasm_uri={}...", wasm_uri);
let store: Store = Store::new(&Universal::new(Cranelift::default()).engine());

let compiler_config;

#[cfg(not(feature = "llvm"))]
{
compiler_config = wasmer_compiler_cranelift::Cranelift::default();
}

#[cfg(feature = "llvm")]
{
compiler_config = wasmer_compiler_llvm::LLVM::default();
}

let store: Store = Store::new(&Universal::new(compiler_config).engine());
let mut module = wasmer::Module::new(&store, bytes)?;
module.set_name(wasm_uri.as_str());
if let Some(cf) = check_module {
Expand Down

0 comments on commit ccf55b2

Please sign in to comment.