Merge branch 'master' into feat-interface-types-new-types-and-instructions

This commit is contained in:
Ivan Enderlin 2020-03-26 07:26:37 +01:00 committed by GitHub
commit 4a86cd16f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 608 additions and 155 deletions

View File

@ -45,6 +45,10 @@ steps:
rustup default $RUST_TOOLCHAIN
rustup target add x86_64-unknown-linux-musl
if [ -n "$ANDROID" ]; then
rustup target add x86_64-linux-android --toolchain $RUST_TOOLCHAIN
fi
rustc -Vv
cargo -V
displayName: Install Rust

4
.gitignore vendored
View File

@ -8,3 +8,7 @@ install/
capi/
api-docs/
api-docs-repo/
# Generated by tests on Android
/avd
/core

View File

@ -3,8 +3,10 @@
## **[Unreleased]**
- [#1329](https://github.com/wasmerio/wasmer/pull/1329) New numbers and strings instructions for WIT
- [#1332](https://github.com/wasmerio/wasmer/pull/1332) Add option to `CompilerConfig` to force compiler IR verification off even when `debug_assertions` are enabled. This can be used to make debug builds faster, which may be important if you're creating a library that wraps Wasmer and depend on the speed of debug builds.
- [#1320](https://github.com/wasmerio/wasmer/pull/1320) Change `custom_sections` field in `ModuleInfo` to be more standards compliant by allowing multiple custom sections with the same name. To get the old behavior with the new API, you can add `.last().unwrap()` to accesses. For example, `module_info.custom_sections["custom_section_name"].last().unwrap()`.
- [#1303](https://github.com/wasmerio/wasmer/pull/1303) NaN canonicalization for singlepass backend.
- [#1292](https://github.com/wasmerio/wasmer/pull/1292) Experimental Support for Android (x86_64 and AArch64)
- [#1305](https://github.com/wasmerio/wasmer/pull/1305) Handle panics from DynamicFunc.
- [#1301](https://github.com/wasmerio/wasmer/pull/1301) Update supported stable Rust version to 1.41.1.
- [#1300](https://github.com/wasmerio/wasmer/pull/1300) Add support for multiple versions of WASI tests: wasitests now test all versions of WASI.

261
Cargo.lock generated
View File

@ -111,6 +111,12 @@ dependencies = [
"serde",
]
[[package]]
name = "bumpalo"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742"
[[package]]
name = "byteorder"
version = "1.3.4"
@ -231,7 +237,7 @@ version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818"
dependencies = [
"cranelift-entity 0.59.0",
"cranelift-entity",
]
[[package]]
@ -244,11 +250,11 @@ dependencies = [
"cranelift-bforest",
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity 0.59.0",
"cranelift-entity",
"gimli",
"log",
"smallvec 1.2.0",
"target-lexicon 0.10.0",
"smallvec",
"target-lexicon",
"thiserror",
]
@ -259,7 +265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity 0.59.0",
"cranelift-entity",
]
[[package]]
@ -268,12 +274,6 @@ version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d"
[[package]]
name = "cranelift-entity"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "722957e05064d97a3157bf0976deed0f3e8ee4f8a4ce167a7c724ca63a4e8bd9"
[[package]]
name = "cranelift-entity"
version = "0.59.0"
@ -288,14 +288,14 @@ checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
"target-lexicon 0.10.0",
"target-lexicon",
]
[[package]]
name = "criterion"
version = "0.2.11"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394"
checksum = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1"
dependencies = [
"atty",
"cast",
@ -304,13 +304,11 @@ dependencies = [
"csv",
"itertools",
"lazy_static",
"libc",
"num-traits",
"rand_core 0.3.1",
"rand_os",
"rand_xoshiro",
"oorandom",
"plotters",
"rayon",
"rayon-core",
"regex",
"serde",
"serde_derive",
"serde_json",
@ -320,11 +318,10 @@ dependencies = [
[[package]]
name = "criterion-plot"
version = "0.3.1"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e"
checksum = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545"
dependencies = [
"byteorder",
"cast",
"itertools",
]
@ -490,17 +487,17 @@ dependencies = [
[[package]]
name = "faerie"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8"
checksum = "74b9ed6159e4a6212c61d9c6a86bee01876b192a64accecf58d5b5ae3b667b52"
dependencies = [
"anyhow",
"goblin 0.1.3",
"goblin",
"indexmap",
"log",
"scroll 0.10.1",
"scroll",
"string-interner",
"target-lexicon 0.9.0",
"target-lexicon",
"thiserror",
]
@ -584,7 +581,7 @@ dependencies = [
"byteorder",
"fallible-iterator",
"indexmap",
"smallvec 1.2.0",
"smallvec",
"stable_deref_trait",
]
@ -600,17 +597,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "goblin"
version = "0.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0"
dependencies = [
"log",
"plain",
"scroll 0.9.2",
]
[[package]]
name = "goblin"
version = "0.1.3"
@ -619,7 +605,7 @@ checksum = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da"
dependencies = [
"log",
"plain",
"scroll 0.10.1",
"scroll",
]
[[package]]
@ -717,6 +703,15 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]]
name = "js-sys"
version = "0.3.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "kernel-net"
version = "0.1.0"
@ -748,9 +743,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.67"
version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
[[package]]
name = "llvm-sys"
@ -927,6 +922,12 @@ version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
[[package]]
name = "oorandom"
version = "11.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405"
[[package]]
name = "orbclient"
version = "0.3.27"
@ -994,7 +995,7 @@ dependencies = [
"cloudabi",
"libc",
"redox_syscall",
"smallvec 1.2.0",
"smallvec",
"winapi",
]
@ -1010,6 +1011,18 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "plotters"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb"
dependencies = [
"js-sys",
"num-traits",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "plugin-for-example"
version = "0.1.0"
@ -1229,16 +1242,6 @@ dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_xoshiro"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929"
dependencies = [
"byteorder",
"rand_core 0.3.1",
]
[[package]]
name = "raw-cpuid"
version = "7.0.3"
@ -1361,34 +1364,13 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scroll"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383"
dependencies = [
"rustc_version",
"scroll_derive 0.9.5",
]
[[package]]
name = "scroll"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1"
dependencies = [
"scroll_derive 0.10.1",
]
[[package]]
name = "scroll_derive"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn 0.15.44",
"scroll_derive",
]
[[package]]
@ -1491,15 +1473,6 @@ dependencies = [
"serde",
]
[[package]]
name = "smallvec"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
dependencies = [
"maybe-uninit",
]
[[package]]
name = "smallvec"
version = "1.2.0"
@ -1596,12 +1569,6 @@ dependencies = [
"syn 1.0.16",
]
[[package]]
name = "target-lexicon"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4"
[[package]]
name = "target-lexicon"
version = "0.10.0"
@ -1776,9 +1743,9 @@ dependencies = [
[[package]]
name = "wabt-sys"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af5d153dc96aad7dc13ab90835b892c69867948112d95299e522d370c4e13a08"
checksum = "23d7043ebb3e5d96fad7a8d3ca22ee9880748ff8c3e18092cfb2a49d3b8f9084"
dependencies = [
"cc",
"cmake",
@ -1803,19 +1770,73 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasm-debug"
version = "0.1.0"
name = "wasm-bindgen"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86840eccceaf682e29be7810dcae5785b9c3b0349ce44d3eaecd9e50f893aee0"
checksum = "3557c397ab5a8e347d434782bcd31fc1483d927a6826804cec05cc792ee2519d"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0da9c9a19850d3af6df1cb9574970b566d617ecfaf36eb0b706b6f3ef9bd2f8"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2 1.0.9",
"quote 1.0.2",
"syn 1.0.16",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f6fde1d36e75a714b5fe0cffbb78978f222ea6baebb726af13c78869fdb4205"
dependencies = [
"quote 1.0.2",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25bda4168030a6412ea8a047e27238cadf56f0e53516e1e83fec0a8b7c786f6d"
dependencies = [
"proc-macro2 1.0.9",
"quote 1.0.2",
"syn 1.0.16",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8"
[[package]]
name = "wasm-debug"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de430168172db11a702b873514492de62c30cdfbf4e46cc8ad4a54c3b8a7506"
dependencies = [
"anyhow",
"cranelift-entity 0.52.0",
"cranelift-entity",
"faerie",
"gimli",
"more-asserts",
"target-lexicon 0.9.0",
"target-lexicon",
"thiserror",
"wasmparser 0.39.3",
"wasmparser",
]
[[package]]
@ -1855,7 +1876,7 @@ version = "0.16.2"
dependencies = [
"byteorder",
"cranelift-codegen",
"cranelift-entity 0.59.0",
"cranelift-entity",
"cranelift-native",
"libc",
"nix",
@ -1864,13 +1885,13 @@ dependencies = [
"serde-bench",
"serde_bytes",
"serde_derive",
"target-lexicon 0.10.0",
"target-lexicon",
"wasm-debug",
"wasmer-clif-fork-frontend",
"wasmer-clif-fork-wasm",
"wasmer-runtime-core",
"wasmer-win-exception-handler",
"wasmparser 0.51.4",
"wasmparser",
"winapi",
]
@ -1882,8 +1903,8 @@ checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a"
dependencies = [
"cranelift-codegen",
"log",
"smallvec 1.2.0",
"target-lexicon 0.10.0",
"smallvec",
"target-lexicon",
]
[[package]]
@ -1893,11 +1914,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5"
dependencies = [
"cranelift-codegen",
"cranelift-entity 0.59.0",
"cranelift-entity",
"log",
"thiserror",
"wasmer-clif-fork-frontend",
"wasmparser 0.51.4",
"wasmparser",
]
[[package]]
@ -1956,7 +1977,7 @@ version = "0.16.2"
dependencies = [
"byteorder",
"cc",
"goblin 0.0.24",
"goblin",
"inkwell",
"lazy_static",
"libc",
@ -1964,10 +1985,10 @@ dependencies = [
"regex",
"rustc_version",
"semver",
"smallvec 0.6.13",
"smallvec",
"wabt",
"wasmer-runtime-core",
"wasmparser 0.51.4",
"wasmparser",
"winapi",
]
@ -2051,10 +2072,10 @@ dependencies = [
"serde-bench",
"serde_bytes",
"serde_derive",
"smallvec 0.6.13",
"target-lexicon 0.9.0",
"smallvec",
"target-lexicon",
"wasm-debug",
"wasmparser 0.51.4",
"wasmparser",
"winapi",
]
@ -2082,7 +2103,7 @@ dependencies = [
"nix",
"serde",
"serde_derive",
"smallvec 0.6.13",
"smallvec",
"wasmer-runtime-core",
]
@ -2152,12 +2173,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "wasmparser"
version = "0.39.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c702914acda5feeeffbc29e4d953e5b9ce79d8b98da4dbf18a77086e116c5470"
[[package]]
name = "wasmparser"
version = "0.51.4"
@ -2173,6 +2188,16 @@ dependencies = [
"leb128",
]
[[package]]
name = "web-sys"
version = "0.3.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "winapi"
version = "0.3.8"

View File

@ -172,6 +172,9 @@ test-rest:
test: spectests emtests middleware wasitests test-rest examples
test-android:
ci/run-docker.sh x86_64-linux-android --manifest-path=lib/singlepass-backend/Cargo.toml
ci/run-docker.sh x86_64-linux-android --manifest-path=lib/runtime-core-tests/Cargo.toml
# Integration tests
integration-tests: release-clif examples

View File

@ -46,6 +46,10 @@ jobs:
linux:
imageName: "ubuntu-16.04"
rust_toolchain: nightly-2019-12-19
android:
imageName: "ubuntu-16.04"
rust_toolchain: nightly-2019-12-19
ANDROID: true
mac:
imageName: "macos-10.14"
rust_toolchain: nightly-2019-12-19
@ -81,10 +85,13 @@ jobs:
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
- bash: make test
displayName: Tests (*nix)
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')), not(variables['ANDROID']))
- bash: make test-android
displayName: Tests (Android)
condition: and(succeeded(), variables['ANDROID'])
- bash: make spectests-cranelift
displayName: Tests (Windows)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), not(variables['ANDROID']))
- job: Check
pool:

3
ci/README.md Normal file
View File

@ -0,0 +1,3 @@
# About this directory
This directory is originally copied from [rust-lang/libc/ci](https://github.com/rust-lang/libc/tree/master/ci).

19
ci/android-install-ndk.sh Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
NDK=android-ndk-r19c
curl --retry 20 -O https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
unzip -q -d ndk ${NDK}-linux-x86_64.zip
mv ./ndk/"$NDK"/* ./ndk/
rm -rf ./${NDK}-linux-x86_64.zip

73
ci/android-install-sdk.sh Normal file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
# Prep the SDK and emulator
#
# Note that the update process requires that we accept a bunch of licenses, and
# we can't just pipe `yes` into it for some reason, so we take the same strategy
# located in https://github.com/appunite/docker by just wrapping it in a script
# which apparently magically accepts the licenses.
SDK=4333796
mkdir sdk
curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O
unzip -q -d sdk sdk-tools-linux-${SDK}.zip
case "$1" in
arm | armv7)
api=24
image="system-images;android-${api};google_apis;armeabi-v7a"
;;
aarch64)
api=24
image="system-images;android-${api};google_apis;arm64-v8a"
;;
i686)
api=28
image="system-images;android-${api};default;x86"
;;
x86_64)
api=28
image="system-images;android-${api};default;x86_64"
;;
*)
echo "invalid arch: $1"
exit 1
;;
esac;
# Try to fix warning about missing file.
# See https://askubuntu.com/a/1078784
mkdir -p /root/.android/
echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg
echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg
# Print all available packages
# yes | ./sdk/tools/bin/sdkmanager --list --verbose
# --no_https avoids
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
#
# | grep -v = || true removes the progress bar output from the sdkmanager
# which produces an insane amount of output.
yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
yes | ./sdk/tools/bin/sdkmanager --no_https \
"emulator" \
"platform-tools" \
"platforms;android-${api}" \
"${image}" | grep -v = || true
echo "no" |
./sdk/tools/bin/avdmanager create avd \
--name "${1}" \
--package "${image}" | grep -v = || true

56
ci/android-sysimage.sh Normal file
View File

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
URL=https://dl.google.com/android/repository/sys-img/android
main() {
local arch="${1}"
local name="${2}"
local dest=/system
local td
td="$(mktemp -d)"
apt-get install --no-install-recommends e2tools
pushd "${td}"
curl --retry 5 -O "${URL}/${name}"
unzip -q "${name}"
local system
system="$(find . -name system.img)"
mkdir -p ${dest}/{bin,lib,lib64}
# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
else
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
fi
# clean up
apt-get purge --auto-remove -y e2tools
popd
rm -rf "${td}"
}
main "${@}"

View File

@ -0,0 +1,53 @@
FROM ubuntu:19.04
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
file \
curl \
ca-certificates \
python \
unzip \
expect \
openjdk-8-jre \
libstdc++6:i386 \
libpulse0 \
gcc \
libc6-dev \
make \
cmake # cmake is necessary to build wabt
WORKDIR /android/
COPY android* /android/
ENV ANDROID_ARCH=aarch64
ENV PATH=$PATH:/android/sdk/tools:/android/sdk/platform-tools
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
ENV ANDROID_NDK_HOME=/android/ndk
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
ENV PATH=$PATH:/rust/bin:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin \
CARGO_TARGET_AARCH64_LINUX_ANDROID_AR=aarch64-linux-android-ar \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang++ \
CC_aarch64_linux_android=aarch64-linux-android28-clang \
CXX_aarch64_linux_android=aarch64-linux-android28-clang++ \
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \
HOME=/tmp
ADD runtest-android.rs /tmp/runtest.rs
ENTRYPOINT [ \
"bash", \
"-c", \
# set SHELL so android can detect a 64bits system, see
# http://stackoverflow.com/a/41789144
"SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \
rustc /tmp/runtest.rs -o /tmp/runtest && \
exec \"$@\"", \
"--" \
]

View File

@ -0,0 +1,31 @@
FROM ubuntu:19.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
libc-dev \
python \
unzip \
make \
cmake # cmake is necessary to build wabt
WORKDIR /android/
ENV ANDROID_ARCH=x86_64
COPY android-install-ndk.sh /android/
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
ENV ANDROID_NDK_HOME=/android/ndk/
# We do not run x86_64-linux-android tests on an android emulator.
# See ci/android-sysimage.sh for informations about how tests are run.
COPY android-sysimage.sh /android/
RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip
ENV PATH=$PATH:/rust/bin:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin \
CARGO_TARGET_X86_64_LINUX_ANDROID_AR=x86_64-linux-android-ar \
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android28-clang++ \
CC_x86_64_linux_android=x86_64-linux-android28-clang \
CXX_x86_64_linux_android=x86_64-linux-android28-clang++ \
LD_LIBRARY_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/ \
HOME=/tmp

35
ci/run-docker.sh Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env sh
# Small script to run tests for a target (or all targets) inside all the
# respective docker images.
set -e
echo "${HOME}"
pwd
TARGET="${1}"
shift
echo "Building docker container for target $target"
# use -f so we can use ci/ as build context
image_tag=test-"$TARGET"
docker build -t "$image_tag" -f "ci/docker/${TARGET}/Dockerfile" ci/
mkdir -p target
set -x
docker run \
--rm \
--user "$(id -u)":"$(id -g)" \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
--volume "$(pwd)"/target:/checkout/target \
--init \
--workdir /checkout \
"$image_tag" \
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec cargo test --target ${TARGET} $@"

60
ci/runtest-android.rs Normal file
View File

@ -0,0 +1,60 @@
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
fn main() {
let args = env::args_os()
.skip(1)
.filter(|arg| arg != "--quiet")
.collect::<Vec<_>>();
assert_eq!(args.len(), 1);
let test = PathBuf::from(&args[0]);
// required to run an executable depending on wabt-rs
let android_ndk_home = env::var("ANDROID_NDK_HOME").expect("Can't get ANDROID_NDK_HOME!");
let path = format!("{}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so", android_ndk_home);
let libcpp_shared = Path::new(&path);
let dst = Path::new("/data/local/tmp");
let dst_exec = Path::new("/data/local/tmp").join(test.file_name().unwrap());
let status = Command::new("adb")
.arg("wait-for-device")
.status()
.expect("failed to run: adb wait-for-device");
assert!(status.success());
let status = Command::new("adb")
.arg("push")
.arg(&test)
.arg(&libcpp_shared)
.arg(&dst)
.status()
.expect("failed to run: adb pushr");
assert!(status.success());
let output = Command::new("adb")
.arg("shell")
.arg("LD_LIBRARY_PATH=/data/local/tmp/")
.arg(&dst_exec)
.output()
.expect("failed to run: adb shell");
assert!(status.success());
println!(
"status: {}\nstdout ---\n{}\nstderr ---\n{}",
output.status,
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
let stdout = String::from_utf8_lossy(&output.stdout);
stdout
.lines()
.find(|l| {
(l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok")
})
.unwrap_or_else(|| {
panic!("failed to find successful test run");
});
}

View File

@ -23,7 +23,7 @@ byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"
rayon = "1.1"
wasm-debug = { optional = true, version = "0.1" }
wasm-debug = { optional = true, version = "0.2" }
# Dependencies for caching.
[dependencies.serde]

View File

@ -43,18 +43,27 @@ fn get_isa(config: Option<&CompilerConfig>) -> Box<dyn isa::TargetIsa> {
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("enable_jump_tables", "false").unwrap();
if cfg!(test) || cfg!(debug_assertions) {
builder.set("enable_verifier", "true").unwrap();
} else {
builder.set("enable_verifier", "false").unwrap();
}
let enable_verifier: bool;
if let Some(config) = config {
if config.nan_canonicalization {
builder.set("enable_nan_canonicalization", "true").unwrap();
}
enable_verifier = config.enable_verification;
} else {
// Set defaults if no config found.
// NOTE: cfg(test) probably does nothing when not running `cargo test`
// on this crate
enable_verifier = cfg!(test) || cfg!(debug_assertions);
}
builder
.set(
"enable_verifier",
if enable_verifier { "true" } else { "false" },
)
.unwrap();
let flags = settings::Flags::new(builder);
debug_assert_eq!(flags.opt_level(), settings::OptLevel::SpeedAndSize);
flags

View File

@ -78,7 +78,7 @@ pub extern "C" fn nearbyintf64(x: f64) -> f64 {
// FIXME: Is there a replacement on AArch64?
#[cfg(all(
any(target_os = "freebsd", target_os = "linux"),
any(target_os = "freebsd", target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
#[no_mangle]

View File

@ -229,7 +229,10 @@ unsafe fn get_faulting_addr_and_ip(
(si_addr, rip as _)
}
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
unsafe fn get_faulting_addr_and_ip(
_siginfo: *const c_void,
_ucontext: *const c_void,
@ -237,7 +240,10 @@ unsafe fn get_faulting_addr_and_ip(
(::std::ptr::null(), ::std::ptr::null())
}
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "x86_64"
))]
unsafe fn get_faulting_addr_and_ip(
siginfo: *const c_void,
ucontext: *const c_void,
@ -332,5 +338,7 @@ unsafe fn get_faulting_addr_and_ip(
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64"),
all(target_os = "android", target_arch = "x86_64"),
all(target_os = "android", target_arch = "aarch64"),
)))]
compile_error!("This crate doesn't yet support compiling on operating systems other than linux and macos and architectures other than x86_64");

View File

@ -86,7 +86,7 @@ impl Trampolines {
let sig_index = module.func_assoc[*exported_func_index];
let func_sig = &module.signatures[sig_index];
let trampoline_func = generate_func(&func_sig);
let trampoline_func = generate_func(isa, &func_sig);
ctx.func = trampoline_func;
@ -150,13 +150,13 @@ impl Trampolines {
/// This function generates a trampoline for the specific signature
/// passed into it.
fn generate_func(func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature();
fn generate_func(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature(isa);
let mut func =
ir::Function::with_name_signature(ir::ExternalName::testcase("trampln"), trampoline_sig);
let export_sig_ref = func.import_signature(generate_export_signature(func_sig));
let export_sig_ref = func.import_signature(generate_export_signature(isa, func_sig));
let entry_ebb = func.dfg.make_block();
let vmctx_ptr = func.dfg.append_block_param(entry_ebb, ir::types::I64);
@ -211,8 +211,8 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type {
}
}
fn generate_trampoline_signature() -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_trampoline_signature(isa: &dyn isa::TargetIsa) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut sig = ir::Signature::new(call_convention);
let ptr_param = ir::AbiParam {
@ -227,8 +227,8 @@ fn generate_trampoline_signature() -> ir::Signature {
sig
}
fn generate_export_signature(func_sig: &FuncSig) -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_export_signature(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut export_clif_sig = ir::Signature::new(call_convention);
let func_sig_iter = func_sig.params().iter().map(|wasm_ty| ir::AbiParam {

View File

@ -12,8 +12,8 @@ readme = "README.md"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.16.2", features = ["generate-debug-information-no-export-symbols"] }
wasmparser = "0.51.3"
smallvec = "0.6"
goblin = "0.0.24"
smallvec = "1"
goblin = "0.1"
libc = "0.2.60"
byteorder = "1"

View File

@ -21,7 +21,7 @@ singlepass = ["wasmer-singlepass-backend"]
[dev-dependencies]
wabt = "0.9.1"
criterion = "0.2"
criterion = "0.3"
[[bench]]
name = "metering_benchmark"

View File

@ -16,12 +16,12 @@ wasmparser = "0.51.3"
parking_lot = "0.10.0"
lazy_static = "1.4"
errno = "0.2"
libc = "0.2.60"
libc = "0.2.68"
hex = "0.4"
smallvec = "0.6"
smallvec = "1"
bincode = "1.1"
wasm-debug = { optional = true, version = "0.1.0" }
target-lexicon = "0.9"
wasm-debug = { optional = true, version = "0.2.0" }
target-lexicon = "0.10"
[dependencies.indexmap]
version = "1.2"

View File

@ -37,7 +37,7 @@ fn main() {
.file("image-loading-freebsd-x86-64.s")
.compile("image-loading");
}
("linux", "x86_64") => {
("linux", "x86_64") | ("android", "x86_64") => {
cc::Build::new()
.file("image-loading-linux-x86-64.s")
.compile("image-loading");

View File

@ -106,7 +106,7 @@ impl BackendCompilerConfig {
}
/// Configuration data for the compiler
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct CompilerConfig {
/// Symbol information generated from emscripten; used for more detailed debug messages
pub symbol_map: Option<HashMap<u32, String>>,
@ -136,6 +136,13 @@ pub struct CompilerConfig {
/// Enabling this makes execution deterministic but increases runtime overhead.
pub nan_canonicalization: bool,
/// Turns on verification that is done by default when `debug_assertions` are enabled
/// (for example in 'debug' builds). Disabling this flag will make compilation faster
/// in debug mode at the cost of not detecting bugs in the compiler.
///
/// These verifications are disabled by default in 'release' builds.
pub enable_verification: bool,
pub features: Features,
// Target info. Presently only supported by LLVM.
@ -148,6 +155,30 @@ pub struct CompilerConfig {
pub generate_debug_info: bool,
}
impl Default for CompilerConfig {
fn default() -> Self {
Self {
symbol_map: Default::default(),
memory_bound_check_mode: Default::default(),
enforce_stack_check: Default::default(),
track_state: Default::default(),
full_preemption: Default::default(),
nan_canonicalization: Default::default(),
features: Default::default(),
triple: Default::default(),
cpu_name: Default::default(),
cpu_features: Default::default(),
backend_specific_config: Default::default(),
generate_debug_info: Default::default(),
// Default verification to 'on' when testing or running in debug mode.
// NOTE: cfg(test) probably does nothing when not running `cargo test`
// on this crate
enable_verification: cfg!(test) || cfg!(debug_assertions),
}
}
}
impl CompilerConfig {
/// Use this to check if we should be generating debug information.
/// This function takes into account the features that runtime-core was

View File

@ -410,7 +410,7 @@ impl MiddlewareChain {
};
sink.push(ev);
for m in &mut self.chain {
let prev: SmallVec<[Event; 2]> = sink.buffer.drain().collect();
let prev: SmallVec<[Event; 2]> = sink.buffer.drain(..).collect();
for ev in prev {
m.feed_event(ev, module_info, &mut sink, source_loc)?;
}

View File

@ -743,7 +743,10 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> F
}
}
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
/// Get fault info from siginfo and ucontext.
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> FaultInfo {
#[allow(dead_code)]
@ -810,7 +813,10 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> F
}
}
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "x86_64"
))]
/// Get fault info from siginfo and ucontext.
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> FaultInfo {
use libc::{

View File

@ -34,7 +34,7 @@ version = "1.0"
[dev-dependencies]
tempfile = "3.1"
criterion = "0.2"
criterion = "0.3"
wabt = "0.9.1"
[dependencies.wasmer-llvm-backend]

View File

@ -17,8 +17,8 @@ dynasmrt = "0.5"
lazy_static = "1.4"
byteorder = "1.3"
nix = "0.15"
libc = "0.2.60"
smallvec = "0.6"
libc = "0.2.68"
smallvec = "1"
serde = "1.0"
serde_derive = "1.0"
bincode = "1.2"

View File

@ -17,8 +17,17 @@
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64"),
all(target_os = "android", target_arch = "x86_64"),
all(target_os = "android", target_arch = "aarch64"),
)))]
compile_error!("This crate doesn't yet support compiling on operating systems other than FreeBSD, linux and macos and architectures other than x86_64");
compile_error!("This crate doesn't yet support compiling on operating systems and architectures other than these:
- FreeBSD and x86_64
- FreeBSD and AArch64
- macOS and x86_64
- Linux and x86_64
- Linux and AArch64
- Android and x86_64
- Android and AArch64");
extern crate dynasmrt;

View File

@ -337,6 +337,7 @@ mod tests {
threads: true,
},
nan_canonicalization: true,
enable_verification: true,
..Default::default()
};
let module = compile_with_config(&module.into_vec(), config)
@ -776,6 +777,7 @@ mod tests {
threads: true,
},
nan_canonicalization: true,
enable_verification: true,
..Default::default()
};
compile_with_config(&module.into_vec(), config)
@ -829,6 +831,7 @@ mod tests {
threads: true,
},
nan_canonicalization: true,
enable_verification: true,
..Default::default()
};
compile_with_config(&module.into_vec(), config)
@ -881,6 +884,7 @@ mod tests {
threads: true,
},
nan_canonicalization: true,
enable_verification: true,
..Default::default()
};
let module = compile_with_config(&module.into_vec(), config)
@ -977,6 +981,7 @@ mod tests {
threads: true,
},
nan_canonicalization: true,
enable_verification: true,
..Default::default()
};
let module = compile_with_config(&module.into_vec(), config)

View File

@ -1,6 +1,11 @@
#![allow(unused, clippy::too_many_arguments)]
pub mod types;
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos"))]
#[cfg(any(
target_os = "freebsd",
target_os = "linux",
target_os = "android",
target_os = "macos"
))]
pub mod unix;
#[cfg(any(target_os = "windows"))]
pub mod windows;
@ -23,7 +28,12 @@ use std::convert::{Infallible, TryInto};
use std::io::{self, Read, Seek, Write};
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos"))]
#[cfg(any(
target_os = "freebsd",
target_os = "linux",
target_os = "android",
target_os = "macos"
))]
pub use unix::*;
#[cfg(any(target_os = "windows"))]