Skip to content

wasmtime: fix build on Linux/s390x. #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 51 additions & 28 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,53 @@ jobs:
addlicense -check .

build:
name: build (${{ matrix.name }})
name: ${{ matrix.action }} with ${{ matrix.name }}

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- name: 'V8 on Linux'
- name: 'V8 on Linux/x86_64'
runtime: 'v8'
os: ubuntu-20.04
action: test
flags: '--define crypto=system'
- name: 'V8 on macOS'
- name: 'V8 on macOS/x86_64'
runtime: 'v8'
os: macos-11
- name: 'WAMR on Linux'
action: test
- name: 'WAMR on Linux/x86_64'
runtime: 'wamr'
os: ubuntu-20.04
- name: 'WAMR on macOS'
action: test
- name: 'WAMR on macOS/x86_64'
runtime: 'wamr'
os: macos-11
- name: 'Wasmtime on Linux'
action: test
- name: 'Wasmtime on Linux/x86_64'
runtime: 'wasmtime'
os: ubuntu-20.04
- name: 'Wasmtime on macOS'
action: test
- name: 'Wasmtime on Linux/aarch64'
runtime: 'wasmtime'
os: ubuntu-20.04
action: build
run_under: docker run --rm --env HOME=$HOME --env USER=$(id -un) --volume "$HOME:$HOME" --workdir $(pwd) --user $(id -u):$(id -g) --platform linux/arm64 piotrsikora/build-tools:bazel-4.2.2-clang-13-gcc-11
- name: 'Wasmtime on Linux/s390x'
runtime: 'wasmtime'
os: ubuntu-20.04
action: build
run_under: docker run --rm --env HOME=$HOME --env USER=$(id -un) --volume "$HOME:$HOME" --workdir $(pwd) --user $(id -u):$(id -g) --platform linux/s390x piotrsikora/build-tools:bazel-4.2.2-clang-13-gcc-11
- name: 'Wasmtime on macOS/x86_64'
runtime: 'wasmtime'
os: macos-11
- name: 'WAVM on Linux'
action: test
- name: 'WAVM on Linux/x86_64'
runtime: 'wavm'
os: ubuntu-20.04
action: test

steps:
- uses: actions/checkout@v2
Expand All @@ -100,36 +117,42 @@ jobs:
if: startsWith(matrix.os, 'macos')
run: brew install ninja

- name: Activate Docker/QEMU
if: startsWith(matrix.run_under, 'docker')
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

- name: Bazel cache
if: matrix.runtime != 'wasmtime'
if: ${{ matrix.runtime != 'wasmtime' || startsWith(matrix.run_under, 'docker') }}
uses: actions/cache@v2
with:
path: |
~/.cache/bazel
/private/var/tmp/_bazel_runner/
key: bazel-${{ matrix.os }}-${{ matrix.runtime }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}

- name: Test
run: |
bazel test \
--verbose_failures \
--test_output=errors \
--define runtime=${{ matrix.runtime }} \
${{ matrix.flags }} \
//test/...

- name: Test (signed Wasm module)
run: |
bazel test \
--verbose_failures \
--test_output=errors \
--define runtime=${{ matrix.runtime }} \
${{ matrix.flags }} \
--per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" \
//test:signature_util_test
- name: Bazel build/test
run: >
${{ matrix.run_under }}
bazel ${{ matrix.action }}
--verbose_failures
--test_output=errors
--define runtime=${{ matrix.runtime }}
${{ matrix.flags }}
//test/...

- name: Bazel build/test (signed Wasm module)
run: >
${{ matrix.run_under }}
bazel ${{ matrix.action }}
--verbose_failures
--test_output=errors
--define runtime=${{ matrix.runtime }}
${{ matrix.flags }}
--per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\"
//test:signature_util_test

- name: Cleanup Bazel cache
if: matrix.runtime != 'wasmtime'
if: ${{ matrix.runtime != 'wasmtime' || startsWith(matrix.run_under, 'docker') }}
run: |
export OUTPUT=$(bazel info output_base)
# BoringSSL's test data (90 MiB).
Expand Down
11 changes: 11 additions & 0 deletions bazel/cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ additional_flags = [
buildrs_additional_deps = [
"@proxy_wasm_cpp_host__cc__1_0_72//:cc",
]

[package.metadata.raze.crates.wasmtime-jit.'*']
additional_deps = [
"@proxy_wasm_cpp_host__rustix__0_31_3//:rustix",
]

[package.metadata.raze.crates.wasmtime-runtime.'*']
patches = [
"@proxy_wasm_cpp_host//bazel/cargo:wasmtime.patch",
]
patch_args = ["-p3"]
6 changes: 6 additions & 0 deletions bazel/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,12 @@ def proxy_wasm_cpp_host_fetch_remote_crates():
type = "tar.gz",
sha256 = "abc7cd79937edd6e238b337608ebbcaf9c086a8457f01dfd598324f7fa56d81a",
strip_prefix = "wasmtime-runtime-0.33.0",
patches = [
"@proxy_wasm_cpp_host//bazel/cargo:wasmtime.patch",
],
patch_args = [
"-p3",
],
build_file = Label("//bazel/cargo/remote:BUILD.wasmtime-runtime-0.33.0.bazel"),
)

Expand Down
1 change: 1 addition & 0 deletions bazel/cargo/remote/BUILD.wasmtime-jit-0.33.0.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ rust_library(
"@proxy_wasm_cpp_host__gimli__0_26_1//:gimli",
"@proxy_wasm_cpp_host__object__0_27_1//:object",
"@proxy_wasm_cpp_host__region__2_2_0//:region",
"@proxy_wasm_cpp_host__rustix__0_31_3//:rustix",
"@proxy_wasm_cpp_host__serde__1_0_133//:serde",
"@proxy_wasm_cpp_host__target_lexicon__0_12_2//:target_lexicon",
"@proxy_wasm_cpp_host__thiserror__1_0_30//:thiserror",
Expand Down
20 changes: 20 additions & 0 deletions bazel/cargo/wasmtime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Fix build on s390x. (https://github.com/bytecodealliance/wasmtime/pull/3673)

diff --git a/crates/runtime/src/helpers.c b/crates/runtime/src/helpers.c
index 66b87a150..b036b06a8 100644
--- a/crates/runtime/src/helpers.c
+++ b/crates/runtime/src/helpers.c
@@ -8,10 +8,10 @@
#define platform_longjmp(buf, arg) longjmp(buf, arg)
typedef jmp_buf platform_jmp_buf;

-#elif defined(__clang__) && defined(__aarch64__)
+#elif defined(__clang__) && (defined(__aarch64__) || defined(__s390x__))

-// Clang on aarch64 doesn't support `__builtin_setjmp`, so use `sigsetjmp`
-// from libc.
+// Clang on aarch64 and s390x doesn't support `__builtin_setjmp`, so use
+//`sigsetjmp` from libc.
//
// Note that `sigsetjmp` and `siglongjmp` are used here where possible to
// explicitly pass a 0 argument to `sigsetjmp` that we don't need to preserve