-
Notifications
You must be signed in to change notification settings - Fork 6
86 lines (69 loc) · 2.71 KB
/
_wasm.yml
File metadata and controls
86 lines (69 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: _WebAssembly Build
on:
workflow_call:
jobs:
build:
name: WebAssembly
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: Install wasm target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm-opt
run: |
curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz \
| tar -xz --strip-components=2 -C /usr/local/bin binaryen-version_121/bin/wasm-opt
wasm-opt --version
- name: Build
run: |
RUSTFLAGS="-Z location-detail=none -Z fmt-debug=none -Z unstable-options -C panic=immediate-abort" \
cargo +nightly build \
--target wasm32-unknown-unknown \
--lib \
--release \
-p edge-python \
-Z build-std=std,panic_abort
- name: Size (unoptimized)
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
- name: Optimize
run: |
INPUT=target/wasm32-unknown-unknown/release/compiler_lib.wasm
wasm-opt -Oz --converge \
--generate-global-effects \
--strip-debug --strip-producers \
--enable-bulk-memory-opt \
--enable-nontrapping-float-to-int \
--enable-sign-ext \
-tnh \
-o /tmp/wasm_stage1.wasm "$INPUT"
wasm-opt --flatten --rereloop -Oz -Oz \
--enable-bulk-memory-opt \
--enable-nontrapping-float-to-int \
--enable-sign-ext \
-o "$INPUT" /tmp/wasm_stage1.wasm
rm /tmp/wasm_stage1.wasm
- name: Size (optimized)
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
# `--no-default-features` disables the producer's `prebuilt` feature so `compiler/build.rs` doesn't try to fetch the release wasm asset (which is uploaded later in this job on a first-tag publish).
- name: Test
run: cargo test -p edge-python --no-default-features
- name: Upload wasm artifact
uses: actions/upload-artifact@v6
with:
name: compiler_lib_wasm
path: target/wasm32-unknown-unknown/release/compiler_lib.wasm
retention-days: 1
- name: Upload WASM Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/wasm32-unknown-unknown/release/compiler_lib.wasm
fail_on_unmatched_files: true
generate_release_notes: true