mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 13:55:33 +00:00
Add golang ABI to binary and add addittional imports
This commit is contained in:
parent
f146cf1479
commit
24fbe6ae9d
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -921,6 +921,11 @@ name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.52"
|
||||
source = "git+https://github.com/rust-lang/libc#fa186bb2b42d32debbc661cf644961fb994e725c"
|
||||
|
||||
[[package]]
|
||||
name = "libflate"
|
||||
version = "0.1.21"
|
||||
@ -2232,6 +2237,7 @@ dependencies = [
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.3.0",
|
||||
"wasmer-emscripten 0.3.0",
|
||||
"wasmer-golang 0.3.0",
|
||||
"wasmer-llvm-backend 0.3.0",
|
||||
"wasmer-runtime 0.3.0",
|
||||
"wasmer-runtime-abi 0.3.0",
|
||||
@ -2281,6 +2287,21 @@ dependencies = [
|
||||
"wasmer-singlepass-backend 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-golang"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.52 (git+https://github.com/rust-lang/libc)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.3.0",
|
||||
"wasmer-runtime-core 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-llvm-backend"
|
||||
version = "0.3.0"
|
||||
@ -2676,6 +2697,7 @@ dependencies = [
|
||||
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
|
||||
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum libc 0.2.52 (git+https://github.com/rust-lang/libc)" = "<none>"
|
||||
"checksum libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "7346a83e8a2c3958d44d24225d905385dc31fc16e89dffb356c457b278914d20"
|
||||
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
|
||||
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
|
||||
|
@ -29,11 +29,12 @@ wasmer-runtime = { path = "lib/runtime" }
|
||||
wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true }
|
||||
wasmer-runtime-core = { path = "lib/runtime-core" }
|
||||
wasmer-emscripten = { path = "lib/emscripten" }
|
||||
wasmer-golang = { path = "lib/golang" }
|
||||
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
|
||||
wasmer-wasi = { path = "lib/wasi", optional = true }
|
||||
|
||||
[workspace]
|
||||
members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi"]
|
||||
members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/golang"]
|
||||
|
||||
[build-dependencies]
|
||||
wabt = "0.7.2"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-golang"
|
||||
version = "0.1.0"
|
||||
version = "0.3.0"
|
||||
description = "Wasmer runtime golang implementation library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.0" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.3.0" }
|
||||
lazy_static = "1.2.0"
|
||||
libc = { git = "https://github.com/rust-lang/libc" }
|
||||
byteorder = "1"
|
||||
@ -19,7 +19,7 @@ rand = "0.6"
|
||||
rand = "0.6"
|
||||
|
||||
[dev-dependencies]
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.0" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.3.0" }
|
||||
wabt = "0.7.2"
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -149,6 +149,22 @@ fn syscallJsValueLoadString(_ctx: &mut Ctx, val: i32) {
|
||||
panic!("syscallJsValueLoadString not yet implemented");
|
||||
}
|
||||
|
||||
fn runtime_schedule_timeout_event(_ctx: &mut Ctx, val: i32) {
|
||||
panic!("runtime_schedule_timeout_event not yet implemented");
|
||||
}
|
||||
|
||||
fn runtime_clear_timeout_event(_ctx: &mut Ctx, val: i32) {
|
||||
panic!("runtime_clear_timeout_event not yet implemented");
|
||||
}
|
||||
|
||||
fn syscall_js_value_index(_ctx: &mut Ctx, val: i32) {
|
||||
panic!("syscall_js_value_index not yet implemented");
|
||||
}
|
||||
|
||||
fn syscall_js_value_length(_ctx: &mut Ctx, val: i32){
|
||||
panic!("syscall_js_value_length not yet implemented");
|
||||
}
|
||||
|
||||
pub fn generate_golang_env() -> ImportObject {
|
||||
imports! {
|
||||
"go" => {
|
||||
@ -160,11 +176,15 @@ pub fn generate_golang_env() -> ImportObject {
|
||||
"runtime.scheduleCallback" => func!(crate::runtimeScheduleCallback),
|
||||
"runtime.clearScheduledCallback" => func!(crate::runtimeClearScheduledCallback),
|
||||
"runtime.getRandomData" => func!(crate::runtimeGetRandomData),
|
||||
"runtime.clearTimeoutEvent" => func!(crate::runtime_clear_timeout_event),
|
||||
"runtime.scheduleTimeoutEvent" => func!(crate::runtime_schedule_timeout_event),
|
||||
"syscall/js.stringVal" => func!(crate::syscallJsStringVal),
|
||||
"syscall/js.valueGet" => func!(crate::syscallJsValueGet),
|
||||
"syscall/js.valueSet" => func!(crate::syscallJsValueSet),
|
||||
"syscall/js.valueSetIndex" => func!(crate::syscallJsValueSetIndex),
|
||||
"syscall/js.valueCall" => func!(crate::syscallJsValueCall),
|
||||
"syscall/js.valueIndex" => func!(crate::syscall_js_value_index),
|
||||
"syscall/js.valueLength" => func!(crate::syscall_js_value_length),
|
||||
"syscall/js.valueNew" => func!(crate::syscallJsValueNew),
|
||||
"syscall/js.valuePrepareString" => func!(crate::syscallJsValuePrepareString),
|
||||
"syscall/js.valueLoadString" => func!(crate::syscallJsValueLoadString),
|
||||
|
@ -324,6 +324,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
),
|
||||
None,
|
||||
)
|
||||
} else if wasmer_golang::is_golang_module(&module) {
|
||||
(InstanceABI::Go, wasmer_golang::generate_golang_env(), None)
|
||||
} else {
|
||||
(
|
||||
InstanceABI::None,
|
||||
|
@ -8,6 +8,7 @@ use wasmer_runtime::{
|
||||
use wasmer_runtime_core::types::Value;
|
||||
|
||||
use wasmer_emscripten::run_emscripten_instance;
|
||||
use wasmer_golang::run_golang_instance;
|
||||
|
||||
pub struct ResultObject {
|
||||
/// A webassembly::Module object representing the compiled WebAssembly module.
|
||||
@ -22,6 +23,7 @@ pub struct ResultObject {
|
||||
pub enum InstanceABI {
|
||||
Emscripten,
|
||||
WASI,
|
||||
Go,
|
||||
None,
|
||||
}
|
||||
|
||||
@ -101,6 +103,9 @@ pub fn run_instance(
|
||||
InstanceABI::Emscripten => {
|
||||
run_emscripten_instance(module, instance, path, args)?;
|
||||
}
|
||||
InstanceABI::Go => {
|
||||
run_golang_instance(module, instance, path, args)?;
|
||||
}
|
||||
InstanceABI::WASI => {
|
||||
instance.call("_start", &[])?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user