Skip to content

Commit 68cf769

Browse files
committed
Add CI for WASIp1 and WASIp2 targets
Signed-off-by: Till Schneidereit <[email protected]>
1 parent 5faae3f commit 68cf769

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,53 @@ jobs:
247247
path: ./target/libmozjs-${{ matrix.target }}.tar.gz
248248
name: libmozjs-${{ matrix.target }}.tar.gz
249249

250+
wasi:
251+
name: wasm32-${{ matrix.target }}
252+
runs-on: ubuntu-latest
253+
strategy:
254+
fail-fast: false
255+
matrix:
256+
target:
257+
- wasip1
258+
- wasip2
259+
steps:
260+
- uses: actions/checkout@v4
261+
- name: Install Rust
262+
uses: dtolnay/rust-toolchain@master
263+
id: toolchain
264+
with:
265+
toolchain: "1.85.0"
266+
targets: "wasm32-${{ matrix.target }}"
267+
- uses: bytecodealliance/actions/wasmtime/setup@v1
268+
- name: Install WASI-SDK
269+
run: |
270+
cd /tmp
271+
curl --retry 5 --retry-all-errors -OL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
272+
tar -xzf wasi-sdk-25.0-x86_64-linux.tar.gz
273+
mv wasi-sdk-25.0-x86_64-linux wasi-sdk
274+
- name: Build
275+
run: |
276+
cargo +${{ steps.toolchain.outputs.name }} build --target=wasm32-${{ matrix.target }}
277+
env:
278+
WASI_SDK_PATH: "/tmp/wasi-sdk"
279+
- name: Test
280+
run: |
281+
cargo +${{ steps.toolchain.outputs.name }} test --target=wasm32-${{ matrix.target }}
282+
env:
283+
WASI_SDK_PATH: "/tmp/wasi-sdk"
284+
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run --dir=$PWD::/cwd
285+
CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime run --dir=$PWD::/cwd
286+
- name: Generate artifact attestation
287+
uses: actions/attest-build-provenance@v1
288+
if: ${{ inputs.release }}
289+
with:
290+
subject-path: "./target/libmozjs-wasm32-${{ matrix.target }}.tar.gz"
291+
- name: Upload artifact
292+
uses: actions/upload-artifact@v4
293+
with:
294+
path: ./target/libmozjs-wasm32-${{ matrix.target }}.tar.gz
295+
name: libmozjs-wasm32-${{ matrix.target }}.tar.gz
296+
250297
linux-cross-compile:
251298
name: linux (${{ matrix.target }})
252299
runs-on: ubuntu-latest

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.140.0-5"
5+
version = "0.140.0-6"
66
authors = ["Mozilla", "The Servo Project Developers"]
77
links = "mozjs"
88
license.workspace = true

mozjs-sys/makefile.cargo

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@ ifneq ($(HOST),$(TARGET))
101101
--disable-clang-plugin \
102102
--disable-jit \
103103
--disable-shared-memory \
104-
--lto=thin \
105104
--with-sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot \
106105
$(NULL)
106+
# LTO makes `cargo test --wasm32-wasi` take a very very long time. Since build scripts
107+
# don't have a way to detect if the build is for `cargo test`, enable LTO for release
108+
# builds only.
109+
ifneq (debug,$(PROFILE))
110+
CONFIGURE_FLAGS += --lto=thin
111+
endif
107112
endif
108113

109114
ifeq (android,$(findstring android,$(TARGET)))

mozjs/examples/wasm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//! and do some setup on both of these. You also need to enter a "realm"
77
//! (environment within one global object) before you can execute code.
88
9+
// The wasm example does not work on wasm32 targets.
10+
#![cfg(not(target_arch = "wasm32"))]
11+
912
use ::std::ptr;
1013
use ::std::ptr::null_mut;
1114

0 commit comments

Comments
 (0)