mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 10:22:19 +00:00
Updates to get wasmer crate compiling
This commit is contained in:
parent
985e2b2f42
commit
3e641d9f89
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1107,6 +1107,7 @@ dependencies = [
|
|||||||
name = "wasmer-clif-backend"
|
name = "wasmer-clif-backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cranelift-codegen 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cranelift-codegen 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cranelift-entity 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cranelift-entity 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cranelift-native 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cranelift-native 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -190,3 +190,10 @@ impl ImportResolver for Imports {
|
|||||||
pub trait ImportResolver {
|
pub trait ImportResolver {
|
||||||
fn get(&self, module: &str, name: &str) -> Option<&Import>;
|
fn get(&self, module: &str, name: &str) -> Option<&Import>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Remove this later, only needed for compilation till emscripten is updated
|
||||||
|
impl Instance {
|
||||||
|
pub fn memory_offset_addr(&self, index: usize, offset: usize) -> *const usize {
|
||||||
|
unimplemented!("TODO replace this emscripten stub")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use wasmer_runtime::{Instance, Module};
|
use wasmer_runtime::{Instance, module::Module};
|
||||||
//use wasmer_runtime::Instance;
|
//use wasmer_runtime::Instance;
|
||||||
use crate::apis::emscripten::env;
|
use crate::apis::emscripten::env;
|
||||||
use libc::stat;
|
use libc::stat;
|
||||||
|
@ -74,18 +74,18 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
.map_err(|err| format!("Can't create the WebAssembly module: {}", err))?;
|
.map_err(|err| format!("Can't create the WebAssembly module: {}", err))?;
|
||||||
|
|
||||||
let abi = if apis::is_emscripten_module(&module) {
|
let abi = if apis::is_emscripten_module(&module) {
|
||||||
wasmer_runtime::InstanceABI::Emscripten
|
webassembly::InstanceABI::Emscripten
|
||||||
} else {
|
} else {
|
||||||
wasmer_runtime::InstanceABI::None
|
webassembly::InstanceABI::None
|
||||||
};
|
};
|
||||||
|
|
||||||
let import_object = if abi == wasmer_runtime::InstanceABI::Emscripten {
|
let import_object = if abi == webassembly::InstanceABI::Emscripten {
|
||||||
apis::generate_emscripten_env()
|
apis::generate_emscripten_env()
|
||||||
} else {
|
} else {
|
||||||
wasmer_runtime::Imports::new()
|
wasmer_runtime::Imports::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
let instance_options = wasmer_runtime::InstanceOptions {
|
let instance_options = webassembly::InstanceOptions {
|
||||||
mock_missing_imports: true,
|
mock_missing_imports: true,
|
||||||
mock_missing_globals: true,
|
mock_missing_globals: true,
|
||||||
mock_missing_tables: true,
|
mock_missing_tables: true,
|
||||||
|
@ -4,9 +4,9 @@ pub mod relocation;
|
|||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
use wasmer_runtime::{Compiler, Module};
|
use wasmer_runtime::{backend::Compiler, module::Module};
|
||||||
use wasmer_runtime;
|
use wasmer_runtime;
|
||||||
use wasmer_runtime::{Import, Imports, Instance, InstanceOptions};
|
use wasmer_runtime::{Import, Imports, Instance};
|
||||||
use cranelift_codegen::{
|
use cranelift_codegen::{
|
||||||
isa,
|
isa,
|
||||||
settings::{self, Configurable},
|
settings::{self, Configurable},
|
||||||
@ -31,6 +31,23 @@ pub struct ResultObject {
|
|||||||
pub instance: Box<Instance>,
|
pub instance: Box<Instance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub struct InstanceOptions {
|
||||||
|
// Shall we mock automatically the imported functions if they don't exist?
|
||||||
|
pub mock_missing_imports: bool,
|
||||||
|
pub mock_missing_globals: bool,
|
||||||
|
pub mock_missing_tables: bool,
|
||||||
|
pub abi: InstanceABI,
|
||||||
|
pub show_progressbar: bool,
|
||||||
|
// pub isa: Box<isa::TargetIsa>, TODO isa
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
|
pub enum InstanceABI {
|
||||||
|
Emscripten,
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
/// The webassembly::instantiate() function allows you to compile and
|
/// The webassembly::instantiate() function allows you to compile and
|
||||||
/// instantiate WebAssembly code
|
/// instantiate WebAssembly code
|
||||||
/// Params:
|
/// Params:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user