Merge remote-tracking branch 'origin/master' into wasix

This commit is contained in:
Christoph Herzog
2023-01-02 09:33:31 +01:00
30 changed files with 817 additions and 643 deletions

11
.github/codecov.yml vendored
View File

@@ -1,11 +0,0 @@
coverage:
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 5%
base: auto

View File

@@ -9,7 +9,3 @@ https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->
# Review
- [ ] Add a short description of the change to the CHANGELOG.md file

View File

@@ -1,15 +0,0 @@
on:
push:
branches:
- '**'
- '!master'
name: cargo-deny
jobs:
deny-check:
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: EmbarkStudios/cargo-deny-action@v1

View File

@@ -1,50 +0,0 @@
name: Coverage
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off"
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'staging'
- 'trying'
paths:
- 'lib/**'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
paths:
- 'lib/**'
coverage:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update stable
- name: Install LLVM (Linux)
run: |
curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -L -o llvm.tar.xz
mkdir -p /opt/llvm-10
tar xf llvm.tar.xz --strip-components=1 -C /opt/llvm-10
echo '/opt/llvm-10/bin' >> $GITHUB_PATH
echo 'LLVM_SYS_100_PREFIX=/opt/llvm-10' >> $GITHUB_ENV
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
env:
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: true

View File

@@ -1,43 +0,0 @@
on:
push:
branches:
- '**'
- '!master'
name: lint
env:
RUST_BACKTRACE: 1
jobs:
lint:
name: Code lint
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- name: Set up libstdc++ on Linux
run: |
sudo apt-get update -y
sudo apt-get install -y --allow-downgrades libstdc++6=8.4.0-1ubuntu1~18.04
sudo apt-get install --reinstall g++-8
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.64
components: rustfmt, clippy
- name: Install LLVM (Linux)
run: |
curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz -L -o /opt/llvm.tar.xz
mkdir -p /opt/llvm-12
tar xf /opt/llvm.tar.xz --strip-components=1 -C /opt/llvm-12
echo '/opt/llvm-12/bin' >> $GITHUB_PATH
echo 'LLVM_SYS_120_PREFIX=/opt/llvm-12' >> $GITHUB_ENV
- run: make lint
env:
ENABLE_CRANELIFT: "1"
ENABLE_LLVM: "1"
ENABLE_SINGLEPASS: "1"
- name: Assert no files have changed
run: |
git status
! [[ $(git status -s) ]]

View File

@@ -1,48 +0,0 @@
name: Runtime tests - JS
env:
RUST_BACKTRACE: 1
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'staging'
- 'trying'
paths:
- 'lib/api/**'
- 'lib/wasi/**'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
paths:
- 'lib/api/**'
- 'lib/wasi/**'
jobs:
test:
name: Test on NodeJS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.64
- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Compile Wasmer to WebAssembly and test with a JavaScript host
run: make test-js

View File

@@ -1,303 +0,0 @@
name: Runtime tests
env:
RUST_BACKTRACE: 1
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'staging'
- 'trying'
paths:
- 'lib/**'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
paths:
- 'lib/**'
jobs:
setup:
name: Set up
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.setup.outputs.VERSION }}
DOING_RELEASE: ${{ steps.setup.outputs.DOING_RELEASE }}
steps:
- name: Set up env vars
id: setup
shell: bash
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo ::set-output name=VERSION::${VERSION}
DOING_RELEASE=$(echo $VERSION | grep -c '^[0-9]\+\.[0-9]\+\.[0-9]\+\(-\([a-zA-Z]\+\)\?[0-9]*\)\?$' || true)
echo ::set-output name=DOING_RELEASE::${DOING_RELEASE}
echo $VERSION
echo $DOING_RELEASE
test:
name: Test on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: setup
strategy:
fail-fast: false
matrix:
include:
- build: linux-x64
os: ubuntu-18.04
target: x86_64-unknown-linux-gnu
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
run_test: true
run_test_capi: true
run_integration_tests: true
run_build_docs: true
use_sccache: true
- build: macos-x64
os: macos-11
target: x86_64-apple-darwin
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
run_test: true
run_test_capi: true
use_sccache: true
run_integration_tests: true
run_ios_tests: true
run_build_docs: false
- build: macos-arm64
os: macos-11.0
target: aarch64-apple-darwin
use_sccache: true
run_test: false
run_test_capi: false
run_build_docs: false
- build: windows-x64
os: windows-2019
#target: x86_64-pc-windows-msvc commented because of bug in rust setup action
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/12.x/windows-amd64.tar.gz'
llvm_choco_version: 13.0.0
run_integration_tests: true
use_sccache: true
run_test: true
run_test_capi: false # We can't run yet the capi tests on Windows
run_build_docs: false
- build: linux-musl-x64
target: x86_64-unknown-linux-musl
os: ubuntu-latest
container: alpine:latest
run_test: true
run_test_capi: false # It can't run the capi tests because of a cc linker issue (`wasm_engine_new` is redefined)
run_integration_tests: false
run_build_docs: false
use_sccache: false
container: ${{ matrix.container }}
env:
SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
steps:
- uses: actions/checkout@v3
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.0
- name: Set up libstdc++ on Linux
if: matrix.build == 'linux-x64'
run: |
sudo apt-get update -y
sudo apt-get install -y --allow-downgrades libstdc++6=8.4.0-1ubuntu1~18.04
sudo apt-get install --reinstall g++-8
- name: Set up base deps on musl
if: matrix.build == 'linux-musl-x64'
run: |
apk add build-base bash musl-dev curl make libtool libffi-dev gcc automake autoconf git openssl-dev g++
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.64
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v1
if: matrix.use_sccache != true
- name: Install LLVM (Choco - Windows)
if: matrix.llvm_choco_version
shell: bash
run: |
choco install llvm --version ${{ matrix.llvm_choco_version }} --allow-downgrade
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM (macOS Apple Silicon)
if: matrix.os == 'macos-11.0' && !matrix.llvm_url
run: |
brew install llvm
- name: Install LLVM
if: matrix.llvm_url
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.llvm_url }} -L -o llvm.tar.xz
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
mkdir ${LLVM_DIR}
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
env:
LLVM_DIR: .llvm
- name: Set up dependencies for Mac OS
run: |
brew install automake
# using gnu-tar is a workaround for https://github.com/actions/cache/issues/403
brew install gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' || matrix.os == 'macos-11.0'
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ matrix.build }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}-v1
- uses: actions/cache@v2
if: matrix.use_sccache
with:
path: ${{ runner.tool_cache }}/cargo-sccache
key: ${{ matrix.build }}-${{ matrix.target }}-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }}-v1
- name: Install sccache
if: matrix.use_sccache
run: |
if [ ! -f '${{ runner.tool_cache }}/cargo-sccache/bin/sccache' ]; then
cargo install sccache --no-default-features --features=dist-client,azure --root '${{ runner.tool_cache }}/cargo-sccache'
fi
shell: bash
- name: Setup Rust target
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
target = "${{ matrix.target }}"
EOF
if: matrix.target
- name: Set sccache port
if: matrix.use_sccache && matrix.random_sccache_port
run: |
netstat -aln | awk '
$6 == "LISTEN" {
if ($4 ~ "[.:][0-9]+$") {
n = split($4, a, /[:.]/);
port = a[n];
p[port] = 1
}
}
END {
for (i = 3000; i < 65000 && p[i]; i++){};
if (i == 65000) {exit 1};
print "SCCACHE_SERVER_PORT=" i
}
' >> $GITHUB_ENV
# echo "SCCACHE_SERVER_PORT=9000"
echo "Setting random sccache port to: $SCCACHE_SERVER_PORT"
shell: bash
- name: Start sccache
if: matrix.use_sccache
run: |
chmod +x '${{ runner.tool_cache }}/cargo-sccache/bin/sccache'
'${{ runner.tool_cache }}/cargo-sccache/bin/sccache' --start-server
'${{ runner.tool_cache }}/cargo-sccache/bin/sccache' -s
echo 'RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache' >> $GITHUB_ENV
shell: bash
- name: Test integration CLI
if: matrix.run_test && matrix.os != 'windows-2019'
shell: bash
run: |
make build-wasmer && make build-capi && make package-capi && make package && export WASMER_DIR=`pwd`/package && make test-integration-cli
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test integration CLI
if: matrix.run_test && matrix.os == 'windows-2019'
shell: bash
run: |
make build-wasmer &&
cargo test --package wasmer-integration-tests-cli --test run -- test_wasmer_run_complex_url --exact --nocapture
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target x86_64-pc-windows-msvc
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# cargo test --package wasmer-integration-tests-cli --test run -- test_wasmer_run_complex_url --exact --nocapture
#- name: Test integration CLI
# if: matrix.run_test && matrix.os == 'windows-2019'
# shell: bash
# run: |
# make && make build-wasmer && make build-capi && make package-capi && make package
# export WASMER_DIR=`pwd`/package
# make test-integration-cli
# env:
# TARGET: x86_64-pc-windows-msvc
# TARGET_DIR: target/x86_64-pc-windows-msvc/release
# CARGO_TARGET: --target x86_64-pc-windows-msvc
- name: Test
if: matrix.run_test && matrix.os != 'windows-2019'
run: |
make
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
- name: Test
if: matrix.run_test && matrix.os != 'windows-2019'
run: |
make build-capi && make package-capi && export WASMER_DIR=`pwd`/package && make test
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
- name: Test C API
if: matrix.run_test_capi && matrix.os != 'windows-2019'
run: |
make test-capi
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
- name: Test
if: matrix.run_test && matrix.os == 'windows-2019'
shell: bash
run: |
make build-capi && make package-capi && export WASMER_DIR=`pwd`/package && make test
- name: Test C API
if: matrix.run_test_capi && matrix.os == 'windows-2019'
shell: bash
run: |
export WASMER_DIR=`pwd`/package && make test-capi
- name: Build Doc
if: matrix.run_build_docs
run: |
make package-docs
audit:
name: Audit
env:
CARGO_AUDIT_VERSION: 0.16.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@master
with:
path: ${{ runner.tool_cache }}/cargo-audit
key: cargo-audit-bin-${{ env.CARGO_AUDIT_VERSION }}
- run: |
echo "'${{ runner.tool_cache }}/cargo-audit/bin'" >> $GITHUB_PATH
- run: |
cargo install cargo-audit --version ${{ env.CARGO_AUDIT_VERSION }} --root '${{ runner.tool_cache }}/cargo-audit'
cargo audit
test-wasm-build:
name: Test wasm build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
rustup target add wasm32-wasi
make build-wasmer-wasm

613
.github/workflows/test.yaml vendored Normal file
View File

@@ -0,0 +1,613 @@
name: test-sys
on:
push:
branches:
- '**'
pull_request:
types: [ synchronize ]
workflow_dispatch:
inputs:
release:
description: 'Make release'
env:
RUST_BACKTRACE: 1
jobs:
setup:
name: Set up
runs-on: ubuntu-22.04
outputs:
VERSION: ${{ steps.setup.outputs.VERSION }}
DOING_RELEASE: ${{ steps.setup.outputs.DOING_RELEASE }}
steps:
- name: Set up env vars
id: setup
shell: bash
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo ::set-output name=VERSION::${VERSION}
DOING_RELEASE=$(echo $VERSION | grep -c '^[0-9]\+\.[0-9]\+\.[0-9]\+\(-\([a-zA-Z]\+\)\?[0-9]*\)\?$' || true)
echo ::set-output name=DOING_RELEASE::${DOING_RELEASE}
echo $VERSION
echo $DOING_RELEASE
lint:
name: Code lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.63
components: rustfmt, clippy
- name: Install libtinfo
shell: bash
run: |
sudo apt install -y libtinfo5
- name: Install LLVM (Linux)
run: |
curl --proto '=https' --tlsv1.2 -sSf https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz -L -o /opt/llvm.tar.xz
mkdir -p /opt/llvm-12
tar xf /opt/llvm.tar.xz --strip-components=1 -C /opt/llvm-12
echo '/opt/llvm-12/bin' >> $GITHUB_PATH
echo 'LLVM_SYS_120_PREFIX=/opt/llvm-12' >> $GITHUB_ENV
- name: Cache
uses: whywaita/actions-cache-s3@v2
with:
path: |
~/.cargo/*
./target/*
key: r22-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-wasmer-make-lint-linux-x64
aws-s3-bucket: wasmer-github-ci-cache
aws-access-key-id: ${{ secrets.GOOGLE_CACHE_ID }}
aws-secret-access-key: ${{ secrets.GOOGLE_CACHE_SECRET }}
aws-region: auto
aws-endpoint: https://storage.googleapis.com
aws-s3-bucket-endpoint: false
aws-s3-force-path-style: true
- run: make lint
env:
ENABLE_CRANELIFT: "1"
ENABLE_LLVM: "1"
ENABLE_SINGLEPASS: "1"
- name: Assert no files have changed
run: |
git status
! [[ $(git status -s) ]]
cargo_deny:
name: cargo-deny
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
test_nodejs:
name: Test on NodeJS
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.63
- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: make test-js
run: |
make test-js
- name: make test-js-core
run: |
make test-js-core
test_wasm_build:
name: Test wasm build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: rustup target add wasm32-wasi
run: rustup target add wasm32-wasi
- name: make build-wasmer-wasm
run: make build-wasmer-wasm
build_linux_aarch64:
name: ${{ matrix.build-what.name }} on linux-aarch64
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build-what: [
{
key: capi,
build-cmd: 'make build-capi',
name: 'Build C-API'
},
{
key: wasmer,
build-cmd: 'make build-wasmer && make package-wasmer && make tar-wasmer',
name: 'Build wasmer-cli'
}
]
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.61
target: aarch64-unknown-linux-gnu
- name: Build cross image
run: |
docker build -t wasmer/aarch64 ${GITHUB_WORKSPACE}/.github/cross-linux-aarch64/
env:
CROSS_DOCKER_IN_DOCKER: true
- name: Build ${{ matrix.build-what.key }}
run: |
${{ matrix.build-what.build-cmd }}
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/aarch64 cross
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: --target aarch64-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
ENABLE_LLVM: 0
build:
name: ${{ matrix.build-what.name }} on ${{ matrix.metadata.build }}
runs-on: ${{ matrix.metadata.os }}
needs: setup
strategy:
fail-fast: false
matrix:
build-what: [
{
key: capi,
build-cmd: 'make build-capi && make package-capi && make tar-capi',
name: 'Build and test C-API'
},
{
key: wasmer,
build-cmd: 'make build-wasmer && make package-wasmer && make tar-wasmer',
name: 'Build wasmer-cli'
}
]
metadata: [
{
build: linux-x64,
os: ubuntu-22.04,
target: x86_64-unknown-linux-gnu,
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
},
{
build: linux-musl,
target: x86_64-unknown-linux-musl,
os: ubuntu-22.04,
container: 'alpine:latest'
},
{
build: macos-x64,
os: macos-11,
target: x86_64-apple-darwin,
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
},
{
build: macos-arm,
os: macos-11,
target: aarch64-apple-darwin,
},
{
build: windows-x64,
os: windows-2019,
target: x86_64-pc-windows-msvc,
llvm_choco_version: 13.0.0
},
{
build: windows-gnu,
target: x86_64-pc-windows-gnu,
os: ubuntu-22.04,
}
]
container: ${{ matrix.metadata.container }}
env:
SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
steps:
- uses: actions/checkout@v3
- name: Set up libstdc++ on Linux
if: matrix.metadata.build == 'linux-x64'
run: |
sudo apt-get update -y
sudo apt-get install -y --allow-downgrades libstdc++6
sudo apt-get install --reinstall g++
- name: Set up base deps on musl
if: matrix.metadata.build == 'linux-musl'
run: |
apk add build-base bash musl-dev curl tar make libtool libffi-dev gcc automake autoconf git openssl-dev g++
- name: Set up dependencies for Mac OS
run: |
brew install automake
# using gnu-tar is a workaround for https://github.com/actions/cache/issues/403
brew install gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
if: matrix.metadata.os == 'macos-latest' || matrix.metadata.os == 'macos-11.0'
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.63
target: ${{ matrix.metadata.target }}
- name: Install Windows-GNU linker
if: ${{ matrix.metadata.build == 'windows-gnu' }}
shell: bash
run: |
sudo apt install -y mingw-w64
- name: Install Windows-GNU target
if: ${{ matrix.metadata.build == 'windows-gnu' }}
shell: bash
run: |
rustup target add x86_64-pc-windows-gnu
- name: Install Windows 10 SDK with xwin
if: ${{ matrix.metadata.build == 'windows-gnu' }}
shell: bash
run: |
mkdir -p /tmp/xwin
mkdir -p /tmp/xwindownload
mkdir -p /tmp/xwincache
git clone https://github.com/wasmerio/xwin --depth=1 /tmp/xwin
cargo build --release --manifest-path=/tmp/xwin/Cargo.toml
/tmp/xwin/target/release/xwin --accept-license --cache-dir /tmp/xwincache splat --output /tmp/xwindownload
mkdir -p /tmp/winsdk
cp /tmp/xwindownload/sdk/lib/10.0.20348/um/x86_64/WS2_32.lib /tmp/winsdk/
cp /tmp/xwindownload/sdk/lib/10.0.20348/um/x86_64/KERNEL32.lib /tmp/winsdk/
cp /tmp/xwindownload/sdk/lib/10.0.20348/um/x86_64/BCRYPT.lib /tmp/winsdk/
cp /tmp/xwindownload/sdk/lib/10.0.20348/um/x86_64/ADVAPI32.lib /tmp/winsdk/
cp /tmp/xwindownload/sdk/lib/10.0.20348/um/x86_64/USERENV.lib /tmp/winsdk/
echo "WinSDK files:"
ls -laH /tmp/winsdk
echo ""
mkdir -p package
mkdir -p package/winsdk
cp -r /tmp/winsdk/* package/winsdk
- name: Choco install LLVM
uses: crazy-max/ghaction-chocolatey@v2
if: matrix.metadata.llvm_choco_version
with:
args: install llvm --version ${{ matrix.metadata.llvm_choco_version }} --allow-downgrade
- name: Install LLVM (Choco - Windows)
if: matrix.metadata.llvm_choco_version
shell: bash
run: |
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM (macOS Apple Silicon)
if: matrix.metadata.os == 'macos-11.0' && !matrix.metadata.llvm_url
run: |
brew install llvm
- name: Install LLVM
if: matrix.metadata.llvm_url
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.metadata.llvm_url }} -L -o llvm.tar.xz
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
mkdir ${LLVM_DIR}
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
env:
LLVM_DIR: .llvm
- name: Setup Rust target
shell: bash
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
target = "${{ matrix.metadata.target }}"
EOF
if: matrix.metadata.target
- name: which cargo
if: ${{ matrix.build-what.key == 'capi' && matrix.metadata.build == 'windows-x64' }}
run: which cargo
- name: Set cargo env
run: echo "CARGO_ROOT_DIR=$(dirname $(dirname $( which cargo )))" >> $GITHUB_ENV
- name: List root dir
shell: bash
if: ${{ matrix.build-what.key == 'capi' && matrix.metadata.build == 'windows-x64' }}
run: ls -R $CARGO_ROOT_DIR
- name: Cache
uses: whywaita/actions-cache-s3@v2
with:
path: |
~/.cargo/*
./target/*
$CARGO_ROOT_DIR/*
key: r22-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-wasmer-make-build-wasmer-${{ matrix.build-what.key }}-${{ matrix.metadata.build }}
aws-s3-bucket: wasmer-github-ci-cache
aws-access-key-id: ${{ secrets.GOOGLE_CACHE_ID }}
aws-secret-access-key: ${{ secrets.GOOGLE_CACHE_SECRET }}
aws-region: auto
aws-endpoint: https://storage.googleapis.com
aws-s3-bucket-endpoint: false
aws-s3-force-path-style: true
- name: Build C-API
shell: bash
run: ${{ matrix.build-what.build-cmd }}
if: ${{ matrix.build-what.key == 'capi' }}
env:
TARGET: ${{ matrix.metadata.target }}
TARGET_DIR: target/${{ matrix.metadata.target }}/release
CARGO_TARGET: --target ${{ matrix.metadata.target }}
- name: Build Wasmer
shell: bash
if: ${{ matrix.build-what.key == 'wasmer' && matrix.metadata.build != 'windows-gnu' }}
run: ${{ matrix.build-what.build-cmd }}
env:
TARGET: ${{ matrix.metadata.target }}
TARGET_DIR: target/${{ matrix.metadata.target }}/release
CARGO_TARGET: --target ${{ matrix.metadata.target }}
- name: Test C-API
shell: bash
if: ${{ matrix.build-what.key == 'capi' && !(matrix.metadata.build == 'linux-musl' || matrix.metadata.build == 'macos-arm' || matrix.metadata.build == 'windows-gnu') }}
run: make test-capi-ci
env:
TARGET: ${{ matrix.metadata.target }}
TARGET_DIR: target/${{ matrix.metadata.target }}/release
CARGO_TARGET: --target ${{ matrix.metadata.target }}
# C-API tests were disabled for linux-musl and macos-arm (we can't run them)
- name: Test C-API integration
shell: bash
if: ${{ matrix.build-what.key == 'capi' && !(matrix.metadata.build == 'linux-musl' || matrix.metadata.build == 'macos-arm' || matrix.metadata.build == 'windows-gnu') }}
run: export WASMER_DIR=`pwd`/package && make test-stage-7-capi-integration-tests
env:
TARGET: ${{ matrix.metadata.target }}
TARGET_DIR: target/${{ matrix.metadata.target }}/release
CARGO_TARGET: --target ${{ matrix.metadata.target }}
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: wasmer-cli-${{ matrix.metadata.build }}
path: build-wasmer.tar.gz
if-no-files-found: ignore
retention-days: 2
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: capi-${{ matrix.metadata.build }}
path: build-capi.tar.gz
if-no-files-found: ignore
retention-days: 2
test:
name: ${{ matrix.stage.description }} on ${{ matrix.metadata.build }}
runs-on: ${{ matrix.metadata.os }}
needs: setup
strategy:
fail-fast: false
matrix:
stage: [
{
description: 'Run wast test suite for all compilers',
make: 'test-stage-0-wast',
},
{
description: 'Unit-test packages on std',
make: 'test-stage-1-test-all',
},
{
description: 'Unit-test cranelift on no-std',
make: 'test-stage-2-test-compiler-cranelift-nostd',
},
{
description: 'Unit-test singlepass on no-std',
make: 'test-stage-3-test-compiler-singlepass-nostd',
},
{
description: 'Unit-test wasmer-cli',
make: 'test-stage-4-wasmer-cli',
},
{
description: 'Unit-test examples',
make: 'test-stage-5-test-examples',
}
]
metadata: [
# We cannot test on macos-arm since we don't have ARM runners
{
build: linux-x64,
os: ubuntu-22.04,
target: x86_64-unknown-linux-gnu,
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
},
{
build: macos-x64,
os: macos-11,
target: x86_64-apple-darwin,
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
},
{
build: windows-x64,
os: windows-2019,
target: x86_64-pc-windows-msvc,
llvm_choco_version: 13.0.0
},
{
build: linux-musl,
target: x86_64-unknown-linux-musl,
os: ubuntu-22.04,
container: 'alpine:latest'
}
]
container: ${{ matrix.metadata.container }}
env:
SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
steps:
- uses: actions/checkout@v3
- name: Set up libstdc++ on Linux
if: matrix.metadata.build == 'linux-x64'
run: |
sudo apt-get update -y
sudo apt-get install -y --allow-downgrades libstdc++6
sudo apt-get install --reinstall g++
- name: Set up base deps on musl
if: matrix.metadata.build == 'linux-musl'
run: |
apk add build-base bash musl-dev curl tar make libtool libffi-dev gcc automake autoconf git openssl-dev g++
- name: Set up dependencies for Mac OS
run: |
brew install automake
# using gnu-tar is a workaround for https://github.com/actions/cache/issues/403
brew install gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
if: matrix.metadata.os == 'macos-latest' || matrix.metadata.os == 'macos-11.0'
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.63
target: ${{ matrix.metadata.target }}
- name: Choco install LLVM
uses: crazy-max/ghaction-chocolatey@v2
if: matrix.metadata.llvm_choco_version
with:
args: install llvm --version ${{ matrix.metadata.llvm_choco_version }} --allow-downgrade
- name: Install LLVM (Choco - Windows)
if: matrix.metadata.llvm_choco_version
shell: bash
run: |
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM (macOS Apple Silicon)
if: matrix.metadata.os == 'macos-11.0' && !matrix.metadata.llvm_url
run: |
brew install llvm
- name: Install LLVM
if: matrix.metadata.llvm_url
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.metadata.llvm_url }} -L -o llvm.tar.xz
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
mkdir ${LLVM_DIR}
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
env:
LLVM_DIR: .llvm
- name: Setup Rust target
shell: bash
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
target = "${{ matrix.metadata.target }}"
EOF
if: matrix.metadata.target
- name: Cache
uses: whywaita/actions-cache-s3@v2
with:
path: |
~/.cargo/*
./target/*
key: r22-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-wasmer-make-test-stage-${{ matrix.stage.make }}-${{ matrix.metadata.build }}
aws-s3-bucket: wasmer-github-ci-cache
aws-access-key-id: ${{ secrets.GOOGLE_CACHE_ID }}
aws-secret-access-key: ${{ secrets.GOOGLE_CACHE_SECRET }}
aws-region: auto
aws-endpoint: https://storage.googleapis.com
aws-s3-bucket-endpoint: false
aws-s3-force-path-style: true
- name: ${{ matrix.stage.description }}
run: make ${{ matrix.stage.make }}
env:
TARGET: ${{ matrix.metadata.target }}
TARGET_DIR: target/${{ matrix.metadata.target }}/release
CARGO_TARGET: --target ${{ matrix.metadata.target }}
test_integration_cli:
name: CLI integration tests on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
fail-fast: false
matrix:
include:
- build: linux-x64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
- build: macos-x64
os: macos-11
target: x86_64-apple-darwin
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
# we only build the integration-test CLI, we don't run tests
- build: macos-arm
os: macos-11
target: aarch64-apple-darwin,
- build: linux-musl
target: x86_64-unknown-linux-musl
os: ubuntu-22.04
container: alpine:latest
container: ${{ matrix.container }}
env:
SCCACHE_AZURE_BLOB_CONTAINER: wasmerstoragesccacheblob
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
steps:
- uses: actions/checkout@v3
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.0
- name: Set up base deps on musl
if: matrix.build == 'linux-musl'
run: |
apk add build-base bash musl-dev curl tar make libtool libffi-dev gcc automake autoconf git openssl-dev g++
- uses: actions/download-artifact@v3
id: download
with:
name: capi-${{ matrix.build }}
- uses: actions/download-artifact@v3
with:
name: wasmer-cli-${{ matrix.build }}
- name: 'Echo download path'
run: echo ${{steps.download.outputs.download-path}}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.63
target: ${{ matrix.metadata.target }}
- name: Cache
uses: whywaita/actions-cache-s3@v2
with:
path: |
~/.cargo/*
./target/*
key: r22-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-wasmer-make-test-integration-cli-${{ matrix.build }}
aws-s3-bucket: wasmer-github-ci-cache
aws-access-key-id: ${{ secrets.GOOGLE_CACHE_ID }}
aws-secret-access-key: ${{ secrets.GOOGLE_CACHE_SECRET }}
aws-region: auto
aws-endpoint: https://storage.googleapis.com
aws-s3-bucket-endpoint: false
aws-s3-force-path-style: true
- name: Unzip Artifacts
shell: bash
run: |
make untar-capi
- name: Unzip Artifacts
shell: bash
run: |
make untar-wasmer
- name: Test integration CLI
if: matrix.build != 'macos-arm'
shell: bash
run: export WASMER_DIR=`pwd`/package && make test-integration-cli-ci
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored
View File

@@ -20,3 +20,7 @@ wasmer.toml
/core
/vendor
out.txt
wapm.toml
build-capi.tar.gz
build-wasmer.tar.gz
lcov.info

173
Makefile
View File

@@ -38,6 +38,7 @@ SHELL=/usr/bin/env bash
#####
IS_DARWIN := 0
IS_LINUX := 0
IS_FREEBSD := 0
@@ -362,10 +363,11 @@ check-wasmer:
check-wasmer-wasm:
$(CARGO_BINARY) check --manifest-path lib/cli-compiler/Cargo.toml --target wasm32-wasi --features singlepass,cranelift --bin wasmer-compiler
check-capi: capi-setup
check-capi:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) check $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml \
--no-default-features --features wat,compiler,wasi,middlewares $(capi_compiler_features)
build-wasmer:
$(CARGO_BINARY) build $(CARGO_TARGET) --release --manifest-path lib/cli/Cargo.toml $(compiler_features) --features="webc_runner" --bin wasmer
@@ -404,12 +406,7 @@ endif
build-docs:
$(CARGO_BINARY) doc $(CARGO_TARGET) --release $(compiler_features) --document-private-items --no-deps --workspace --exclude wasmer-c-api
capi-setup:
ifeq ($(IS_WINDOWS), 1)
RUSTFLAGS += -C target-feature=+crt-static
endif
build-docs-capi: capi-setup
build-docs-capi:
# `wasmer-c-api` lib's name is `wasmer`. To avoid a conflict
# when generating the documentation, we rename it to its
# crate's name. Then we restore the lib's name.
@@ -417,37 +414,37 @@ build-docs-capi: capi-setup
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) doc $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,compiler,cranelift,wasi
sed "$(SEDI)" -e 's/name = "wasmer_c_api" # ##lib.name##/name = "wasmer" # ##lib.name##/' lib/c-api/Cargo.toml
build-capi: capi-setup
build-capi:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features)
build-capi-singlepass: capi-setup
build-capi-singlepass:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner
build-capi-singlepass-universal: capi-setup
build-capi-singlepass-universal:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,singlepass,wasi,middlewares,webc_runner
build-capi-cranelift: capi-setup
build-capi-cranelift:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner
build-capi-cranelift-universal: capi-setup
build-capi-cranelift-universal:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,cranelift,wasi,middlewares,webc_runner
build-capi-llvm: capi-setup
build-capi-llvm:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner
build-capi-llvm-universal: capi-setup
build-capi-llvm-universal:
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner
# Headless (we include the minimal to be able to run)
build-capi-headless: capi-setup
build-capi-headless:
ifeq ($(CARGO_TARGET),)
RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi
@@ -456,7 +453,7 @@ else
--no-default-features --features compiler-headless,wasi
endif
build-capi-headless-ios: capi-setup
build-capi-headless-ios:
RUSTFLAGS="${RUSTFLAGS} -C panic=abort" cargo lipo --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi
@@ -466,18 +463,39 @@ build-capi-headless-ios: capi-setup
#
#####
test: test-compilers test-packages test-examples
test-compilers:
# test compilers
test-stage-0-wast:
$(CARGO_BINARY) test $(CARGO_TARGET) --release --tests $(compiler_features)
test-packages:
$(CARGO_BINARY) test $(CARGO_TARGET) --all --release $(exclude_tests)
# test packages
test-stage-1-test-all:
$(CARGO_BINARY) test $(CARGO_TARGET) --all --release $(exclude_tests) --exclude wasmer-c-api-test-runner --exclude wasmer-capi-examples-runner
test-stage-2-test-compiler-cranelift-nostd:
$(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/compiler-cranelift/Cargo.toml --release --no-default-features --features=std
test-stage-3-test-compiler-singlepass-nostd:
$(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std
test-stage-4-wasmer-cli:
$(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/cli/Cargo.toml $(compiler_features) --release
$(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/vfs/Cargo.toml $(compiler_features) --release
# test examples
test-stage-5-test-examples:
$(CARGO_BINARY) test $(CARGO_TARGET) $(compiler_features) --features wasi --examples
test-stage-6-test-examples-release:
$(CARGO_BINARY) test $(CARGO_TARGET) --release $(compiler_features) --features wasi --examples
test-stage-7-capi-integration-tests:
$(CARGO_BINARY) test $(CARGO_TARGET) --release --package wasmer-c-api-test-runner
$(CARGO_BINARY) test $(CARGO_TARGET) --release --package wasmer-capi-examples-runner
test: test-compilers test-packages test-examples
test-compilers: test-stage-0-wast
test-packages: test-stage-1-test-all test-stage-2-test-compiler-cranelift-nostd test-stage-3-test-compiler-singlepass-nostd test-stage-4-wasmer-cli
test-examples: test-stage-5-test-examples test-stage-6-test-examples-release
test-js: test-js-api test-js-wasi
# TODO: disabled because the no-std / core feature doesn't actually work at the moment.
@@ -514,9 +532,13 @@ test-cranelift: $(foreach cranelift_engine,$(filter cranelift-%,$(compilers_engi
test-llvm: $(foreach llvm_engine,$(filter llvm-%,$(compilers_engines)),test-$(llvm_engine))
# same as test-capi, but without the build-capi step first
test-capi-ci: $(foreach compiler_engine,$(capi_compilers_engines),test-capi-crate-$(compiler_engine) test-capi-integration-$(compiler_engine))
# This test requires building the capi with all the available
# compilers first
test-capi: build-capi package-capi $(foreach compiler_engine,$(capi_compilers_engines),test-capi-crate-$(compiler_engine) test-capi-integration-$(compiler_engine))
test-capi: build-capi package-capi test-capi-ci
test-capi-crate-%:
WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) $(CARGO_BINARY) test $(CARGO_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
@@ -535,14 +557,14 @@ test-wasi-unit:
test-wasi:
$(CARGO_BINARY) test $(CARGO_TARGET) --release --tests $(compiler_features) -- wasi::wasitests
test-examples:
$(CARGO_BINARY) test $(CARGO_TARGET) $(compiler_features) --features wasi --examples
$(CARGO_BINARY) test $(CARGO_TARGET) --release $(compiler_features) --features wasi --examples
test-integration-cli:
rustup target add wasm32-wasi
$(CARGO_BINARY) test $(CARGO_TARGET) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1
test-integration-cli-ci:
rustup target add wasm32-wasi
$(CARGO_BINARY) test $(CARGO_TARGET) --features webc_runner -p wasmer-integration-tests-cli -- --nocapture || $(CARGO_BINARY) test $(CARGO_TARGET) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1
test-integration-ios:
$(CARGO_BINARY) test $(CARGO_TARGET) --features webc_runner -p wasmer-integration-tests-ios
@@ -569,10 +591,21 @@ endif
package-wasmer:
mkdir -p "package/bin"
ls -R target
ifeq ($(IS_WINDOWS), 1)
cp $(TARGET_DIR)/wasmer.exe package/bin/
if [ -f "$(TARGET_DIR)/wasmer.exe" ]; then \
cp "$(TARGET_DIR)/wasmer.exe" package/bin ;\
fi
if [ -f "target/$(HOST_TARGET)/release/wasmer.exe" ]; then \
cp "target/$(HOST_TARGET)/release/wasmer.exe" package/bin ;\
fi
else
cp $(TARGET_DIR)/wasmer package/bin/
if [ -f "$(TARGET_DIR)/wasmer" ]; then \
cp $(TARGET_DIR)/wasmer package/bin ;\
fi
if [ -f "target/$(HOST_TARGET)/release/wasmer" ]; then \
cp "target/$(HOST_TARGET)/release/wasmer" package/bin ;\
fi
ifeq ($(IS_DARWIN), 1)
codesign -s - package/bin/wasmer || true
endif
@@ -585,7 +618,6 @@ package-capi:
cp lib/c-api/wasmer_wasm.h* package/include
cp lib/c-api/tests/wasm-c-api/include/wasm.h* package/include
cp lib/c-api/README.md package/include/README.md
if [ -f $(TARGET_DIR)/wasmer.dll ]; then \
cp $(TARGET_DIR)/wasmer.dll package/lib/wasmer.dll ;\
fi
@@ -608,6 +640,28 @@ package-capi:
cp $(TARGET_DIR)/libwasmer.a package/lib/libwasmer.a ;\
fi
if [ -f target/$(HOST_TARGET)/release/wasmer.dll ]; then \
cp target/$(HOST_TARGET)/release/wasmer.dll package/lib/wasmer.dll ;\
fi
if [ -f target/$(HOST_TARGET)/release/wasmer.dll.lib ]; then \
cp target/$(HOST_TARGET)/release/wasmer.dll.lib package/lib/wasmer.dll.lib ;\
fi
if [ -f target/$(HOST_TARGET)/release/wasmer.lib ]; then \
cp target/$(HOST_TARGET)/release/wasmer.lib package/lib/wasmer.lib ;\
fi
if [ -f target/$(HOST_TARGET)/release/libwasmer.dylib ]; then \
cp target/$(HOST_TARGET)/release/libwasmer.dylib package/lib/libwasmer.dylib ;\
fi
if [ -f target/$(HOST_TARGET)/release/libwasmer.so ]; then \
cp target/$(HOST_TARGET)/release/libwasmer.so package/lib/libwasmer.so ;\
fi
if [ -f target/$(HOST_TARGET)/release/libwasmer.a ]; then \
cp target/$(HOST_TARGET)/release/libwasmer.a package/lib/libwasmer.a ;\
fi
package-capi-headless: build-capi-headless
mkdir -p "package/include"
mkdir -p "package/lib"
@@ -642,32 +696,49 @@ package-docs: build-docs build-docs-capi
package: package-wasmer package-minimal-headless-wasmer package-capi
package-gnu: package-capi-gnu
tar-capi:
ls -R package
tar -C package -zcvf build-capi.tar.gz lib include
package-capi-gnu:
mkdir -p "package/include"
mkdir -p "package/lib"
cp lib/c-api/wasmer.h* package/include
cp lib/c-api/wasmer_wasm.h* package/include
cp lib/c-api/tests/wasm-c-api/include/wasm.h* package/include
cp lib/c-api/README.md package/include/README.md
if [ -f target/x86_64-pc-windows-gnu/release/wasmer.dll ]; then \
cp target/x86_64-pc-windows-gnu/release/wasmer.dll package/lib/wasmer.dll ;\
fi
untar-capi:
mkdir -p package
mkdir -p target/release
mkdir -p target/$(HOST_TARGET)/release
tar -C package -xf ./build-capi.tar.gz
cp package/lib/* target/release
cp package/lib/* target/$(HOST_TARGET)/release
mkdir -p target/debug
mkdir -p target/$(HOST_TARGET)/debug
tar -C package -xf ./build-capi.tar.gz
cp package/lib/* target/debug
cp package/lib/* target/$(HOST_TARGET)/debug
echo "untar capi"
ls -R target
echo "package"
ls -R package
if [ -f target/x86_64-pc-windows-gnu/release/wasmer.dll.lib ]; then \
cp target/x86_64-pc-windows-gnu/release/wasmer.dll.lib package/lib/wasmer.dll.lib ;\
fi
tar-wasmer:
ls -R package
tar -C package -zcvf build-wasmer.tar.gz bin
if [ -f target/x86_64-pc-windows-gnu/release/wasmer.lib ]; then \
cp target/x86_64-pc-windows-gnu/release/wasmer.lib package/lib/wasmer.lib ;\
fi
untar-wasmer:
mkdir -p package
mkdir -p target/release
mkdir -p target/$(HOST_TARGET)/release
tar -C package -xf ./build-wasmer.tar.gz
cp package/bin/* target/release
cp package/bin/* target/$(HOST_TARGET)/release
mkdir -p target/debug
mkdir -p target/$(HOST_TARGET)/debug
tar -C package -xf ./build-wasmer.tar.gz
cp package/bin/* target/debug
cp package/bin/* target/$(HOST_TARGET)/debug
echo "untar wasmer"
ls -R target
echo "package"
ls -R package
if [ -f target/x86_64-pc-windows-gnu/release/libwasmer.a ]; then \
cp target/x86_64-pc-windows-gnu/release/libwasmer.a package/lib/libwasmer.a ;\
fi
distribution-gnu: package-gnu
distribution-gnu: package-capi
cp LICENSE package/LICENSE
cp ATTRIBUTIONS.md package/ATTRIBUTIONS
mkdir -p dist

View File

@@ -294,11 +294,11 @@ impl Module {
/// # }
/// ```
pub unsafe fn deserialize_from_file(
store: &impl AsStoreRef,
engine: &impl AsEngineRef,
path: impl AsRef<Path>,
) -> Result<Self, DeserializeError> {
let artifact = store
.as_store_ref()
let artifact = engine
.as_engine_ref()
.engine()
.deserialize_from_file(path.as_ref())?;
Ok(Self::from_artifact(artifact))

View File

@@ -347,7 +347,11 @@ fn shared_object_dir() -> PathBuf {
// We either find `target` or the target triple if cross-compiling.
if shared_object_dir.file_name() != Some(OsStr::new("target")) {
let target = env::var("TARGET").unwrap();
if shared_object_dir.file_name() != Some(OsStr::new("llvm-cov-target")) {
assert_eq!(shared_object_dir.file_name(), Some(OsStr::new(&target)));
} else {
shared_object_dir.set_file_name(&target);
}
}
shared_object_dir.push(env::var("PROFILE").unwrap());

View File

@@ -445,6 +445,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_engine_new() {
(assert_c! {

View File

@@ -102,6 +102,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_set_host_global_immutable() {
(assert_c! {
@@ -134,6 +135,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_set_guest_global_immutable() {
(assert_c! {

View File

@@ -137,6 +137,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_extern_copy() {
(assert_c! {

View File

@@ -212,6 +212,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_instance_new() {
(assert_c! {

View File

@@ -485,6 +485,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_validate() {
(assert_c! {
@@ -512,6 +513,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_new() {
(assert_c! {
@@ -541,6 +543,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_exports() {
(assert_c! {
@@ -649,6 +652,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_imports() {
(assert_c! {
@@ -767,6 +771,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_serialize() {
(assert_c! {
@@ -801,6 +806,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_module_serialize_and_deserialize() {
(assert_c! {

View File

@@ -149,6 +149,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_trap_message_null_terminated() {
(assert_c! {
@@ -181,6 +182,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_trap_message_not_null_terminated() {
(assert_c! {

View File

@@ -540,6 +540,7 @@ mod tests {
#[cfg(target_os = "windows")]
use wasmer_inline_c::assert_c;
#[cfg_attr(coverage, ignore)]
#[test]
fn test_wasi_get_wasi_version_snapshot0() {
(assert_c! {
@@ -573,6 +574,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_wasi_get_wasi_version_snapshot1() {
(assert_c! {
@@ -606,6 +608,7 @@ mod tests {
.success();
}
#[cfg_attr(coverage, ignore)]
#[test]
fn test_wasi_get_wasi_version_invalid() {
(assert_c! {

View File

@@ -1,5 +1,7 @@
#[cfg(test)]
use std::error::Error;
#[cfg(test)]
use std::process::Stdio;
#[cfg(test)]
static INCLUDE_REGEX: &str = "#include \"(.*)\"";
@@ -23,52 +25,7 @@ impl Config {
if config.wasmer_dir.is_empty() {
println!("manifest dir = {manifest_dir}, wasmer root dir = {wasmer_base_dir}");
config.wasmer_dir = wasmer_base_dir.clone() + "/package";
if !std::path::Path::new(&config.wasmer_dir).exists() {
println!("running make build-capi...");
// run make build-capi
let mut cmd = std::process::Command::new("make");
cmd.arg("build-capi");
cmd.current_dir(wasmer_base_dir.clone());
let result = cmd.output();
println!("make build-capi: {result:#?}");
println!("running make package...");
// run make package-capi
let mut cmd = std::process::Command::new("make");
cmd.arg("package-capi");
cmd.current_dir(wasmer_base_dir.clone());
let result = cmd.output();
make_package();
println!("make package: {result:#?}");
println!("list {}", config.wasmer_dir);
match std::fs::read_dir(&config.wasmer_dir) {
Ok(o) => {
for entry in o {
let entry = entry.unwrap();
let path = entry.path();
println!(" {:?}", path.file_name());
}
}
Err(e) => {
println!("error in reading config.wasmer_dir: {e}");
}
};
println!("list {}/include", config.wasmer_dir);
match std::fs::read_dir(&format!("{}/include", config.wasmer_dir)) {
Ok(o) => {
for entry in o {
let entry = entry.unwrap();
let path = entry.path();
println!(" {:?}", path.file_name());
}
}
Err(e) => {
println!("error in reading config.wasmer_dir: {e}");
}
};
}
assert!(std::path::Path::new(&config.wasmer_dir).exists());
}
if config.root_dir.is_empty() {
config.root_dir = wasmer_base_dir + "/lib/c-api/tests";
@@ -132,41 +89,6 @@ impl Drop for RemoveTestsOnDrop {
}
}
fn make_package() {
let wasmer_root_dir = find_wasmer_base_dir();
let _ = std::fs::create_dir_all(&format!("{wasmer_root_dir}/package/lib"));
let _ = std::fs::create_dir_all(&format!("{wasmer_root_dir}/package/include"));
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/lib/c-api/tests/wasm.h"),
&format!("{wasmer_root_dir}/package/include/wasm.h"),
);
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/lib/c-api/tests/wasmer.h"),
&format!("{wasmer_root_dir}/package/include/wasmer.h"),
);
#[cfg(target_os = "windows")]
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/target/release/wasmer.dll"),
&format!("{wasmer_root_dir}/package/lib"),
);
#[cfg(target_os = "windows")]
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/target/release/wasmer.dll.lib"),
&format!("{wasmer_root_dir}/package/lib"),
);
#[cfg(not(target_os = "windows"))]
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/target/release/libwasmer.so"),
&format!("{wasmer_root_dir}/package/lib"),
);
#[cfg(not(target_os = "windows"))]
let _ = std::fs::copy(
&format!("{wasmer_root_dir}/target/release/libwasmer.lib"),
&format!("{wasmer_root_dir}/package/lib"),
);
println!("copying done (make package)");
}
#[cfg(test)]
pub const CAPI_BASE_TESTS: &[&str] = &[
"wasm-c-api/example/callback",
@@ -358,6 +280,9 @@ fn test_ok() {
println!("compile: {command:#?}");
// compile
let output = command
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.current_dir(find_wasmer_base_dir())
.output()
.expect(&format!("failed to compile {command:#?}"));
if !output.status.success() {
@@ -397,6 +322,14 @@ fn print_wasmer_root_to_stdout(config: &Config) {
use walkdir::WalkDir;
println!(
"wasmer dir: {}",
std::path::Path::new(&config.wasmer_dir)
.canonicalize()
.unwrap()
.display()
);
for entry in WalkDir::new(&config.wasmer_dir)
.into_iter()
.filter_map(Result::ok)
@@ -405,6 +338,14 @@ fn print_wasmer_root_to_stdout(config: &Config) {
println!("{f_name}");
}
println!(
"root dir: {}",
std::path::Path::new(&config.root_dir)
.canonicalize()
.unwrap()
.display()
);
for entry in WalkDir::new(&config.root_dir)
.into_iter()
.filter_map(Result::ok)

View File

@@ -4,7 +4,7 @@
use crate::hash::Hash;
use std::error::Error;
use wasmer::{Module, Store};
use wasmer::{AsEngineRef, Module};
/// A generic cache for storing and loading compiled wasm modules.
pub trait Cache {
@@ -19,7 +19,7 @@ pub trait Cache {
/// This function is unsafe as the cache store could be tampered with.
unsafe fn load(
&self,
store: &Store,
engine: &impl AsEngineRef,
key: Hash,
) -> Result<Module, Self::DeserializeError>;

View File

@@ -4,7 +4,7 @@ use crate::hash::Hash;
use std::fs::{create_dir_all, File};
use std::io::{self, Write};
use std::path::PathBuf;
use wasmer::{DeserializeError, Module, SerializeError, Store};
use wasmer::{AsEngineRef, DeserializeError, Module, SerializeError};
/// Representation of a directory that contains compiled wasm artifacts.
///
@@ -91,14 +91,18 @@ impl Cache for FileSystemCache {
type DeserializeError = DeserializeError;
type SerializeError = SerializeError;
unsafe fn load(&self, store: &Store, key: Hash) -> Result<Module, Self::DeserializeError> {
unsafe fn load(
&self,
engine: &impl AsEngineRef,
key: Hash,
) -> Result<Module, Self::DeserializeError> {
let filename = if let Some(ref ext) = self.ext {
format!("{}.{}", key.to_string(), ext)
} else {
key.to_string()
};
let path = self.path.join(filename);
let ret = Module::deserialize_from_file(store, path.clone());
let ret = Module::deserialize_from_file(engine, path.clone());
if ret.is_err() {
// If an error occurs while deserializing then we can not trust it anymore
// so delete the cache file

View File

@@ -464,9 +464,9 @@ impl CreateExe {
let file = files
.iter()
.find(|f| f.ends_with("libwasmer.a")).cloned()
.find(|f| f.ends_with("libwasmer.a") || f.ends_with("wasmer.lib")).cloned()
.ok_or_else(|| {
anyhow!("Could not find libwasmer.a for {} target in the provided tarball path (files = {files:#?})", target)
anyhow!("Could not find libwasmer.a / wasmer.lib for {} target in the provided tarball path (files = {files:#?})", target)
})?;
Ok((file, tarball_dir))

View File

@@ -29,7 +29,6 @@ pub enum SpawnType {
/// An implementation of task management
#[allow(unused_variables)]
pub trait VirtualTaskManager: std::fmt::Debug + Send + Sync + 'static {
/// Invokes whenever a WASM thread goes idle. In some runtimes (like singlethreaded
/// execution environments) they will need to do asynchronous work whenever the main
/// thread goes idle and this is the place to hook for that.

View File

@@ -33,12 +33,10 @@ impl Default for TokioTaskManager {
struct TokioRuntimeGuard<'g> {
#[allow(unused)]
inner: tokio::runtime::EnterGuard<'g>
inner: tokio::runtime::EnterGuard<'g>,
}
impl<'g> Drop
for TokioRuntimeGuard<'g> {
fn drop(&mut self) {
}
impl<'g> Drop for TokioRuntimeGuard<'g> {
fn drop(&mut self) {}
}
impl VirtualTaskManager for TokioTaskManager {
@@ -83,7 +81,7 @@ impl VirtualTaskManager for TokioTaskManager {
#[allow(dyn_drop)]
fn runtime_enter<'g>(&'g self) -> Box<dyn std::ops::Drop + 'g> {
Box::new(TokioRuntimeGuard {
inner: self.0.enter()
inner: self.0.enter(),
})
}

View File

@@ -178,8 +178,7 @@ pub(crate) fn poll_oneoff_internal(
// sleep time which is roughly equal the size of a Linux time interval
// that exponentially builds up when file descriptors are not being triggered
if let Some(sleep_time) = time_to_sleep.clone() {
time_to_sleep = Some(
match env.poll_backoff {
time_to_sleep = Some(match env.poll_backoff {
a if a < 50 => sleep_time,
a if a < 100 => Duration::from_millis(1).max(sleep_time),
a if a < 150 => Duration::from_millis(2).max(sleep_time),
@@ -189,8 +188,7 @@ pub(crate) fn poll_oneoff_internal(
a if a < 350 => Duration::from_millis(50).max(sleep_time),
a if a < 400 => Duration::from_millis(100).max(sleep_time),
_ => Duration::from_millis(200).max(sleep_time),
}
);
});
}
drop(env);

View File

@@ -151,7 +151,7 @@ def make_release(version):
proc = subprocess.Popen(['git','checkout', "-b", "release-" + RELEASE_VERSION], stdout = subprocess.PIPE, cwd = temp_dir.name)
proc.wait()
proc = subprocess.Popen(['git','pull', "origin", "release-" + RELEASE_VERSION], stdout = subprocess.PIPE, cwd = temp_dir.name)
proc = subprocess.Popen(['git','pull', "origin", "release-" + RELEASE_VERSION, "--depth", "1"], stdout = subprocess.PIPE, cwd = temp_dir.name)
proc.wait()
proc = subprocess.Popen(['git','log', "--oneline"], stdout = subprocess.PIPE, cwd = temp_dir.name)
@@ -331,7 +331,7 @@ def make_release(version):
while not(already_released):
print("git pull origin master...")
proc = subprocess.Popen(['git','pull', "origin", "master"], stdout = subprocess.PIPE, cwd = temp_dir.name)
proc = subprocess.Popen(['git','pull', "origin", "master", "--depth", "1"], stdout = subprocess.PIPE, cwd = temp_dir.name)
proc.wait()
if proc.returncode != 0:
for line in proc.stdout: