mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 02:12:13 +00:00
Make wasmer work with stable Rust
This commit is contained in:
parent
264b468a8d
commit
2dcd25bebd
@ -10,7 +10,6 @@ jobs:
|
||||
keys:
|
||||
- v4-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
- run: sudo apt-get install -y cmake
|
||||
- run: rustup default nightly-2018-10-07
|
||||
- run: make test
|
||||
- run:
|
||||
command: |
|
||||
@ -50,9 +49,9 @@ jobs:
|
||||
tar xf cmake-3.4.1-Darwin-x86_64.tar.gz
|
||||
export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH"
|
||||
- run:
|
||||
name: Install Rust Nightly
|
||||
name: Install Rust
|
||||
command: |
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2018-10-07
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
cargo --version
|
||||
- run:
|
||||
|
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -238,6 +238,11 @@ dependencies = [
|
||||
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.43"
|
||||
source = "git+https://github.com/rust-lang/libc#5cc006652a242c35b6fe5b615ccd39d9356a2346"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.43"
|
||||
@ -436,11 +441,6 @@ dependencies = [
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.7.0"
|
||||
@ -578,18 +578,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wabt"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wabt-sys"
|
||||
version = "0.4.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -606,18 +606,17 @@ dependencies = [
|
||||
"cranelift-wasm 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (git+https://github.com/rust-lang/libc)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -679,6 +678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
||||
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
|
||||
"checksum libc 0.2.43 (git+https://github.com/rust-lang/libc)" = "<none>"
|
||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||
"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
|
||||
"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9"
|
||||
@ -703,7 +703,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
|
||||
"checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
|
||||
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
|
||||
"checksum spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ceac490aa12c567115b40b7b7fceca03a6c9d53d5defea066123debc83c5dc1f"
|
||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||
"checksum structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ca85f2c9a5a1e2d5ac686fc0be48e40f8ad803f5bbe31f692ff71eb2dd8aad45"
|
||||
"checksum structopt-derive 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "1383e5db585da799a5c4acc496c5c868e18bf82e658c00c75cc91038fa26b55f"
|
||||
@ -722,8 +721,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum wabt 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0768faf932f2898c0a7545edee648fefa716906a2e143009addf4959d2335a75"
|
||||
"checksum wabt-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4aaa9a8fa0d698315da5611f3e113a1e688fbb8d6fa0dd9510dfa023f665e9dc"
|
||||
"checksum wabt 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b24b2494bd6077dff717f41523f6e3e0161d58f578198589a6a6c8b314cb763"
|
||||
"checksum wabt-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "122aefe1d22c067cce1dc5d20d89d1ca47ce0eb10120246a3e2340863f9e6ddd"
|
||||
"checksum wasmparser 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc6511bad33610d7798f80d48e10495a6eb4f1e39306b0bb340b2de0816c4ca"
|
||||
"checksum wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a75e0c3fe9a4d4fd91901348a5be05ba4791e29dda89e8596bfe87900ba7edc"
|
||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||
|
11
Cargo.toml
11
Cargo.toml
@ -2,7 +2,7 @@
|
||||
name = "wasmer"
|
||||
version = "0.1.0"
|
||||
authors = ["Syrus Akbary <me@syrusakbary.com>"]
|
||||
edition = "2018"
|
||||
# edition = "2018"
|
||||
repository = "https://github.com/wafoundation/wasmer"
|
||||
publish = true
|
||||
description = "High-Performance WebAssembly JIT interpreter"
|
||||
@ -34,18 +34,19 @@ serde_derive = "1.0.55"
|
||||
tempdir = "0.3.7"
|
||||
error-chain = "0.12.0"
|
||||
structopt = "0.2.11"
|
||||
wabt = "0.6.0"
|
||||
wabt = "0.7.1"
|
||||
wasmparser = "0.20.0"
|
||||
region = "0.3.0"
|
||||
memmap = "0.6.2"
|
||||
spin = "0.4.10"
|
||||
# spin = "0.4.10"
|
||||
log = "0.4.5"
|
||||
target-lexicon = { version = "0.0.3", default-features = false }
|
||||
libc = "0.2"
|
||||
# libc = "0.2"
|
||||
libc = { git = "https://github.com/rust-lang/libc" }
|
||||
nix = "0.11"
|
||||
|
||||
[build-dependencies]
|
||||
wabt = "0.6.0"
|
||||
wabt = "0.7.1"
|
||||
|
||||
# [dev-dependencies]
|
||||
# libffi = "0.6.4"
|
||||
|
@ -29,9 +29,6 @@ To build this project you will need Rust and Cargo.
|
||||
git clone https://github.com/wafoundation/wasmer.git
|
||||
cd wasmer
|
||||
|
||||
# Use rust nightly (we use 2018-10-07 as latest are failing)
|
||||
rustup default nightly-2018-10-07
|
||||
|
||||
# install tools
|
||||
# make sure that `python` is accessible.
|
||||
cargo install
|
||||
@ -44,7 +41,7 @@ Thanks to [spectests](https://github.com/WAFoundation/wasmer/tree/master/spectes
|
||||
Tests can be run with:
|
||||
|
||||
```sh
|
||||
cargo test
|
||||
make test
|
||||
```
|
||||
|
||||
If you need to re-generate the Rust tests from the spectests
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! This file will run at build time to autogenerate Rust tests based on
|
||||
//! WebAssembly spec tests. It will convert the files indicated in TESTS
|
||||
//! from "/spectests/{MODULE}.wast" to "/src/spectests/{MODULE}.rs".
|
||||
extern crate wabt;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
@ -215,7 +217,8 @@ fn test_module_{}() {{
|
||||
fn visit_module(&mut self, module: &ModuleBinary, _name: &Option<String>) {
|
||||
let wasm_binary: Vec<u8> = module.clone().into_vec();
|
||||
let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
|
||||
self.flush_module_calls(self.last_module);
|
||||
let last_module = self.last_module;
|
||||
self.flush_module_calls(last_module);
|
||||
self.last_module = self.last_module + 1;
|
||||
// self.module_calls.insert(self.last_module, vec![]);
|
||||
self.buffer.push_str(
|
||||
@ -255,6 +258,7 @@ fn test_module_{}() {{
|
||||
fn visit_assert_invalid(&mut self, module: &ModuleBinary) {
|
||||
let wasm_binary: Vec<u8> = module.clone().into_vec();
|
||||
// let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
|
||||
let command_name = self.command_name();
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
"#[test]
|
||||
@ -263,7 +267,7 @@ fn {}_assert_invalid() {{
|
||||
let compilation = compile(wasm_binary.to_vec());
|
||||
assert!(compilation.is_err(), \"WASM should not compile as is invalid\");
|
||||
}}\n",
|
||||
self.command_name(),
|
||||
command_name,
|
||||
wasm_binary,
|
||||
// We do this to ident four spaces back
|
||||
// String::from_utf8_lossy(&wasm_binary),
|
||||
@ -385,6 +389,7 @@ fn {}_assert_invalid() {{
|
||||
|
||||
fn visit_assert_malformed(&mut self, module: &ModuleBinary) {
|
||||
let wasm_binary: Vec<u8> = module.clone().into_vec();
|
||||
let command_name = self.command_name();
|
||||
// let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
|
||||
self.buffer.push_str(
|
||||
format!(
|
||||
@ -394,7 +399,7 @@ fn {}_assert_malformed() {{
|
||||
let compilation = compile(wasm_binary.to_vec());
|
||||
assert!(compilation.is_err(), \"WASM should not compile as is malformed\");
|
||||
}}\n",
|
||||
self.command_name(),
|
||||
command_name,
|
||||
wasm_binary,
|
||||
// We do this to ident four spaces back
|
||||
// String::from_utf8_lossy(&wasm_binary),
|
||||
|
@ -1,18 +1,18 @@
|
||||
#![feature(test, libc, core_intrinsics)]
|
||||
|
||||
extern crate test;
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate libc;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
extern crate nix;
|
||||
extern crate spin;
|
||||
|
||||
// use std::alloc::System;
|
||||
// use std::time::{Duration, Instant};
|
||||
@ -23,7 +23,6 @@ extern crate spin;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
// use libc;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
|
@ -52,7 +52,7 @@ fn get_function_addr(
|
||||
let func_pointer = if index < len {
|
||||
import_functions[index]
|
||||
} else {
|
||||
(&functions[func_index.index() - len]).as_ptr()
|
||||
(functions[index - len]).as_ptr()
|
||||
};
|
||||
func_pointer
|
||||
}
|
||||
@ -432,7 +432,7 @@ impl Instance {
|
||||
.info
|
||||
.start_func
|
||||
.or_else(|| match module.info.exports.get("main") {
|
||||
Some(Export::Function(index)) => Some(index.to_owned()),
|
||||
Some(Export::Function(index)) => Some(*index),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
@ -627,40 +627,56 @@ extern "C" fn current_memory(memory_index: u32, instance: &mut Instance) -> u32
|
||||
// Because of this bug https://github.com/rust-lang/rust/issues/34123
|
||||
// We create internal functions for it
|
||||
|
||||
use std::intrinsics::{
|
||||
ceilf32, ceilf64, floorf32, floorf64, nearbyintf32, nearbyintf64, truncf32, truncf64,
|
||||
};
|
||||
// use std::intrinsics::{
|
||||
// ceilf32, ceilf64, floorf32, floorf64, nearbyintf32, nearbyintf64, truncf32, truncf64,
|
||||
// };
|
||||
|
||||
// F32
|
||||
unsafe extern "C" fn _ceilf32(x: f32) -> f32 {
|
||||
ceilf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _ceilf32(x: f32) -> f32 {
|
||||
// ceilf32(x)
|
||||
x.ceil()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _floorf32(x: f32) -> f32 {
|
||||
floorf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _floorf32(x: f32) -> f32 {
|
||||
// floorf32(x)
|
||||
x.floor()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _truncf32(x: f32) -> f32 {
|
||||
truncf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _truncf32(x: f32) -> f32 {
|
||||
// truncf32(x)
|
||||
x.trunc()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _nearbyintf32(x: f32) -> f32 {
|
||||
nearbyintf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _nearbyintf32(x: f32) -> f32 {
|
||||
// nearbyintf32(x)
|
||||
x.round()
|
||||
}
|
||||
|
||||
// F64
|
||||
unsafe extern "C" fn _ceilf64(x: f64) -> f64 {
|
||||
ceilf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _ceilf64(x: f64) -> f64 {
|
||||
// ceilf64(x)
|
||||
x.ceil()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _floorf64(x: f64) -> f64 {
|
||||
floorf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _floorf64(x: f64) -> f64 {
|
||||
// floorf64(x)
|
||||
x.floor()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _truncf64(x: f64) -> f64 {
|
||||
truncf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _truncf64(x: f64) -> f64 {
|
||||
// truncf64(x)
|
||||
x.trunc()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _nearbyintf64(x: f64) -> f64 {
|
||||
nearbyintf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _nearbyintf64(x: f64) -> f64 {
|
||||
// nearbyintf64(x)
|
||||
x.round()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user