Simplify compiler test options

This commit is contained in:
Syrus
2019-11-21 13:36:44 -08:00
parent 5e728ae893
commit aeb66ee48e
13 changed files with 105 additions and 257 deletions

5
Cargo.lock generated
View File

@ -1436,7 +1436,7 @@ dependencies = [
"wasmer-dev-utils 0.10.2",
"wasmer-emscripten 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-singlepass-backend 0.10.2",
]
@ -1574,7 +1574,7 @@ dependencies = [
"wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-singlepass-backend 0.10.2",
]
@ -1604,7 +1604,6 @@ dependencies = [
"wasmer-dev-utils 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-singlepass-backend 0.10.2",
"wasmer-wasi 0.10.2",
]

View File

@ -10,8 +10,8 @@ build = "build/mod.rs"
[dependencies]
wasmer-emscripten = { path = "../emscripten", version = "0.10.2" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
@ -23,6 +23,6 @@ wasmer-dev-utils = { path = "../dev-utils", version = "0.10.2"}
glob = "0.3"
[features]
clif = []
llvm = ["wasmer-llvm-backend"]
singlepass = ["wasmer-singlepass-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -3,40 +3,14 @@ mod tests {
use std::sync::Arc;
use wabt::wat2wasm;
use wasmer_emscripten::is_emscripten_module;
use wasmer_runtime_core::backend::Compiler;
use wasmer_runtime_core::compile_with;
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[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;
CraneliftCompiler::new()
}
use wasmer_runtime::compile;
#[test]
fn should_detect_emscripten_files() {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
compile(&wasm_binary[..]).expect("WASM can't be compiled");
let module = Arc::new(module);
assert!(is_emscripten_module(&module));
}
@ -46,7 +20,7 @@ mod tests {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
compile(&wasm_binary[..]).expect("WASM can't be compiled");
let module = Arc::new(module);
assert!(!is_emscripten_module(&module));
}

View File

@ -5,39 +5,12 @@ macro_rules! assert_emscripten_output {
EmscriptenGlobals,
generate_emscripten_env,
};
use wasmer_runtime_core::{
backend::Compiler,
};
use wasmer_runtime::compile;
use wasmer_dev_utils::stdio::StdioCapturer;
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[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;
CraneliftCompiler::new()
}
let wasm_bytes = include_bytes!($file);
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &get_compiler())
let module = compile(&wasm_bytes[..])
.expect("WASM can't be compiled");
// let module = compile(&wasm_bytes[..])

View File

@ -87,11 +87,11 @@
//! [`wasmer-clif-backend`]: https://crates.io/crates/wasmer-clif-backend
//! [`compile_with`]: fn.compile_with.html
pub use wasmer_runtime_core::backend::Backend;
pub use wasmer_runtime_core::backend::{Backend, Features};
pub use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
pub use wasmer_runtime_core::export::Export;
pub use wasmer_runtime_core::global::Global;
pub use wasmer_runtime_core::import::ImportObject;
pub use wasmer_runtime_core::import::{ImportObject, LikeNamespace};
pub use wasmer_runtime_core::instance::{DynFunc, Instance};
pub use wasmer_runtime_core::memory::ptr::{Array, Item, WasmPtr};
pub use wasmer_runtime_core::memory::Memory;
@ -131,9 +131,14 @@ pub mod units {
pub use wasmer_runtime_core::units::{Bytes, Pages};
}
pub mod types {
//! Various types.
pub use wasmer_runtime_core::types::*;
}
pub mod cache;
use wasmer_runtime_core::backend::{Compiler, CompilerConfig};
pub use wasmer_runtime_core::backend::{Compiler, CompilerConfig};
/// Compile WebAssembly binary code into a [`Module`].
/// This function is useful if it is necessary to

View File

@ -9,8 +9,8 @@ edition = "2018"
[dependencies]
glob = "0.3"
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false}
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
@ -23,6 +23,6 @@ wabt = "0.9.1"
[features]
default = ["fast-tests"]
fast-tests = []
clif = []
llvm = ["wasmer-llvm-backend"]
singlepass = ["wasmer-singlepass-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -1,46 +1,23 @@
use wabt::wat2wasm;
use wasmer_runtime_core::{
backend::Compiler,
use wasmer_runtime::{
error,
global::Global,
memory::Memory,
prelude::*,
table::Table,
func,
Global,
Memory,
imports,
compile,
Table,
Ctx,
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
units::Pages,
};
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[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;
CraneliftCompiler::new()
}
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
fn main() -> error::Result<()> {
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
let inner_module = wasmer_runtime_core::compile_with(&wasm_binary, &get_compiler())?;
let inner_module = compile(&wasm_binary)?;
let memory_desc = MemoryDescriptor::new(Pages(1), Some(Pages(1)), false).unwrap();
let memory = Memory::new(memory_desc).unwrap();
@ -71,7 +48,7 @@ fn main() -> error::Result<()> {
"env" => inner_instance,
};
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &get_compiler())?;
let outer_module = compile(EXAMPLE_WASM)?;
let outer_instance = outer_module.instantiate(&outer_imports)?;
let ret = outer_instance.call("main", &[Value::I32(42)])?;
println!("ret: {:?}", ret);
@ -79,7 +56,7 @@ fn main() -> error::Result<()> {
Ok(())
}
fn print_num(ctx: &mut vm::Ctx, n: i32) -> Result<i32, ()> {
fn print_num(ctx: &mut Ctx, n: i32) -> Result<i32, ()> {
println!("print_num({})", n);
let memory: &Memory = ctx.memory(0);

View File

@ -1,5 +1,5 @@
use wabt::wat2wasm;
use wasmer_runtime_core::{backend::Compiler, import::ImportObject, Instance};
use wasmer_runtime::{ImportObject, Instance, compile};
fn main() {
let instance = create_module_1();
@ -23,38 +23,13 @@ fn create_module_1() -> Instance {
(elem (;1;) (i32.const 9) 1))
"#;
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &get_compiler())
let module = compile(&wasm_binary[..])
.expect("WASM can't be compiled");
module
.instantiate(&generate_imports())
.expect("WASM can't be instantiated")
}
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[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;
CraneliftCompiler::new()
}
static IMPORT_MODULE: &str = r#"
(module
(type $t0 (func (param i32)))
@ -68,7 +43,7 @@ static IMPORT_MODULE: &str = r#"
pub fn generate_imports() -> ImportObject {
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &get_compiler())
let module = compile(&wasm_binary[..])
.expect("WASM can't be compiled");
let instance = module
.instantiate(&ImportObject::new())

View File

@ -1,10 +1,9 @@
#[cfg(test)]
mod tests {
use wabt::wat2wasm;
use wasmer_clif_backend::CraneliftCompiler;
use wasmer_runtime_core::{
use wasmer_runtime::{
error::{CallError, RuntimeError},
import::ImportObject,
ImportObject,
};
// The semantics of stack overflow are documented at:
@ -22,7 +21,7 @@ mod tests {
(elem (;0;) (i32.const 0) 0))
"#;
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
let module = wasmer_runtime::compile(&wasm_binary[..])
.expect("WASM can't be compiled");
let instance = module
.instantiate(&ImportObject::new())

View File

@ -63,31 +63,6 @@ mod tests {
}
}
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[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;
CraneliftCompiler::new()
}
#[cfg(feature = "clif")]
fn get_compiler_name() -> &'static str {
"clif"
@ -241,20 +216,23 @@ mod tests {
use std::panic::AssertUnwindSafe;
use std::path::PathBuf;
use wabt::script::{Action, Command, CommandKind, ScriptParser, Value};
use wasmer_runtime_core::backend::{Compiler, CompilerConfig, Features};
use wasmer_runtime_core::error::CompileError;
use wasmer_runtime_core::import::ImportObject;
use wasmer_runtime_core::Instance;
use wasmer_runtime_core::{
export::Export,
global::Global,
import::LikeNamespace,
memory::Memory,
table::Table,
use wasmer_runtime::{
CompilerConfig,
ImportObject,
LikeNamespace,
Instance,
error::{CompileError},
Export,
Global,
Memory,
Table,
types::{ElementType, MemoryDescriptor, TableDescriptor},
units::Pages,
Features,
func, imports, Ctx,
compile_with_config,
};
use wasmer_runtime_core::{func, imports, vm::Ctx};
fn parse_and_run(
path: &PathBuf,
@ -328,9 +306,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
let module = compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
@ -375,7 +352,7 @@ mod tests {
&named_modules,
&module,
|instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
},
@ -507,7 +484,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -578,7 +555,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -649,7 +626,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -667,7 +644,7 @@ mod tests {
);
} else {
let call_result = maybe_call_result.unwrap();
use wasmer_runtime_core::error::{CallError, RuntimeError};
use wasmer_runtime::error::{CallError, RuntimeError};
match call_result {
Err(e) => {
match e {
@ -738,9 +715,8 @@ mod tests {
},
..Default::default()
};
wasmer_runtime_core::compile_with_config(
compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
});
@ -794,9 +770,8 @@ mod tests {
},
..Default::default()
};
wasmer_runtime_core::compile_with_config(
compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
});
@ -849,9 +824,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
let module = compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
@ -891,7 +865,7 @@ mod tests {
&named_modules,
&module,
|instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
},
@ -948,9 +922,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
let module = compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
@ -987,7 +960,7 @@ mod tests {
);
}
Err(e) => match e {
wasmer_runtime_core::error::Error::LinkError(_) => {
wasmer_runtime::error::Error::LinkError(_) => {
test_report.count_passed();
}
_ => {
@ -1046,7 +1019,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -1094,29 +1067,29 @@ mod tests {
Ok(test_report)
}
fn is_canonical_nan(val: wasmer_runtime_core::types::Value) -> bool {
fn is_canonical_nan(val: wasmer_runtime::types::Value) -> bool {
match val {
wasmer_runtime_core::types::Value::F32(x) => x.is_canonical_nan(),
wasmer_runtime_core::types::Value::F64(x) => x.is_canonical_nan(),
wasmer_runtime::types::Value::F32(x) => x.is_canonical_nan(),
wasmer_runtime::types::Value::F64(x) => x.is_canonical_nan(),
_ => panic!("value is not a float {:?}", val),
}
}
fn is_arithmetic_nan(val: wasmer_runtime_core::types::Value) -> bool {
fn is_arithmetic_nan(val: wasmer_runtime::types::Value) -> bool {
match val {
wasmer_runtime_core::types::Value::F32(x) => x.is_quiet_nan(),
wasmer_runtime_core::types::Value::F64(x) => x.is_quiet_nan(),
wasmer_runtime::types::Value::F32(x) => x.is_quiet_nan(),
wasmer_runtime::types::Value::F64(x) => x.is_quiet_nan(),
_ => panic!("value is not a float {:?}", val),
}
}
fn value_to_hex(val: wasmer_runtime_core::types::Value) -> String {
fn value_to_hex(val: wasmer_runtime::types::Value) -> String {
match val {
wasmer_runtime_core::types::Value::I32(x) => format!("{:#x}", x),
wasmer_runtime_core::types::Value::I64(x) => format!("{:#x}", x),
wasmer_runtime_core::types::Value::F32(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime_core::types::Value::F64(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime_core::types::Value::V128(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::I32(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::I64(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::F32(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime::types::Value::F64(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime::types::Value::V128(x) => format!("{:#x}", x),
}
}
@ -1129,13 +1102,13 @@ mod tests {
V128(u128),
}
fn convert_wasmer_value(other: wasmer_runtime_core::types::Value) -> SpectestValue {
fn convert_wasmer_value(other: wasmer_runtime::types::Value) -> SpectestValue {
match other {
wasmer_runtime_core::types::Value::I32(v) => SpectestValue::I32(v),
wasmer_runtime_core::types::Value::I64(v) => SpectestValue::I64(v),
wasmer_runtime_core::types::Value::F32(v) => SpectestValue::F32(v.to_bits()),
wasmer_runtime_core::types::Value::F64(v) => SpectestValue::F64(v.to_bits()),
wasmer_runtime_core::types::Value::V128(v) => SpectestValue::V128(v),
wasmer_runtime::types::Value::I32(v) => SpectestValue::I32(v),
wasmer_runtime::types::Value::I64(v) => SpectestValue::I64(v),
wasmer_runtime::types::Value::F32(v) => SpectestValue::F32(v.to_bits()),
wasmer_runtime::types::Value::F64(v) => SpectestValue::F64(v.to_bits()),
wasmer_runtime::types::Value::V128(v) => SpectestValue::V128(v),
}
}
@ -1149,13 +1122,13 @@ mod tests {
}
}
fn convert_value(other: Value<f32, f64>) -> wasmer_runtime_core::types::Value {
fn convert_value(other: Value<f32, f64>) -> wasmer_runtime::types::Value {
match other {
Value::I32(v) => wasmer_runtime_core::types::Value::I32(v),
Value::I64(v) => wasmer_runtime_core::types::Value::I64(v),
Value::F32(v) => wasmer_runtime_core::types::Value::F32(v),
Value::F64(v) => wasmer_runtime_core::types::Value::F64(v),
Value::V128(v) => wasmer_runtime_core::types::Value::V128(v),
Value::I32(v) => wasmer_runtime::types::Value::I32(v),
Value::I64(v) => wasmer_runtime::types::Value::I64(v),
Value::F32(v) => wasmer_runtime::types::Value::F32(v),
Value::F64(v) => wasmer_runtime::types::Value::F64(v),
Value::V128(v) => wasmer_runtime::types::Value::V128(v),
}
}
@ -1199,9 +1172,9 @@ mod tests {
let memory_desc = MemoryDescriptor::new(Pages(1), Some(Pages(2)), false).unwrap();
let memory = Memory::new(memory_desc).unwrap();
let global_i32 = Global::new(wasmer_runtime_core::types::Value::I32(666));
let global_f32 = Global::new(wasmer_runtime_core::types::Value::F32(666.0));
let global_f64 = Global::new(wasmer_runtime_core::types::Value::F64(666.0));
let global_i32 = Global::new(wasmer_runtime::types::Value::I32(666));
let global_f32 = Global::new(wasmer_runtime::types::Value::F32(666.0));
let global_f64 = Global::new(wasmer_runtime::types::Value::F64(666.0));
let table = Table::new(TableDescriptor {
element: ElementType::Anyfunc,

View File

@ -9,22 +9,21 @@ publish = false
build = "build/mod.rs"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2" }
# We set default features to false to be able to use the singlepass backend properly
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false }
wasmer-wasi = { path = "../wasi", version = "0.10.2" }
# hack to get tests to work
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
[build-dependencies]
glob = "0.3"
[dev-dependencies]
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-dev-utils = { path = "../dev-utils", version = "0.10.2"}
[features]
clif = []
singlepass = ["wasmer-singlepass-backend"]
llvm = ["wasmer-llvm-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -1,6 +1,5 @@
#![cfg(test)]
use wasmer_runtime::{compile, Func};
use wasmer_runtime_core::vm::Ctx;
use wasmer_runtime::{compile, Func, Ctx};
use wasmer_wasi::{state::*, *};
use std::ffi::c_void;

View File

@ -1,36 +1,11 @@
macro_rules! assert_wasi_output {
($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
use wasmer_dev_utils::stdio::StdioCapturer;
use wasmer_runtime_core::{backend::Compiler, Func};
use wasmer_runtime::Func;
use wasmer_wasi::generate_import_object;
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
compile_error!("compiler not specified, activate a compiler via features");
unreachable!();
}
let wasm_bytes = include_bytes!($file);
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &get_compiler())
let module = wasmer_runtime::compile(&wasm_bytes[..])
.expect("WASM can't be compiled");
let import_object = generate_import_object(vec![], vec![], $po_dir_args, $mapdir_args);