mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-31 23:32:04 +00:00
Run spectests with both compilers, activate using features
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use wabt::wat2wasm;
|
||||
use wasmer_clif_backend::CraneliftCompiler;
|
||||
use wasmer_runtime_core::{
|
||||
backend::Compiler,
|
||||
error,
|
||||
global::Global,
|
||||
memory::Memory,
|
||||
@@ -10,12 +10,31 @@ use wasmer_runtime_core::{
|
||||
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(not(any(feature = "llvm", feature = "clif")))]
|
||||
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, &CraneliftCompiler::new())?;
|
||||
let inner_module = wasmer_runtime_core::compile_with(&wasm_binary, &get_compiler())?;
|
||||
|
||||
let memory = Memory::new(MemoryDescriptor {
|
||||
minimum: Pages(1),
|
||||
@@ -50,7 +69,7 @@ fn main() -> error::Result<()> {
|
||||
"env" => inner_instance,
|
||||
};
|
||||
|
||||
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &CraneliftCompiler::new())?;
|
||||
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &get_compiler())?;
|
||||
let outer_instance = outer_module.instantiate(&outer_imports)?;
|
||||
let ret = outer_instance.call("main", &[Value::I32(42)])?;
|
||||
println!("ret: {:?}", ret);
|
||||
|
Reference in New Issue
Block a user