-
Notifications
You must be signed in to change notification settings - Fork 8
83 lines (66 loc) · 2.54 KB
/
_wasm.yml
File metadata and controls
83 lines (66 loc) · 2.54 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
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
with:
workspaces: compiler
- uses: dtolnay/rust-toolchain@stable
- name: Install wasm target
run: rustup target add wasm32-unknown-unknown
working-directory: compiler
- 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: cargo build --target wasm32-unknown-unknown --features wasm --lib --release
working-directory: compiler
- name: Size (unoptimized)
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
working-directory: compiler
- name: Optimize
working-directory: compiler
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
working-directory: compiler
- name: Test
run: cargo test --features wasm-tests
working-directory: compiler
- name: Upload wasm artifact
uses: actions/upload-artifact@v6
with:
name: compiler_lib_wasm
path: compiler/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: compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm
fail_on_unmatched_files: true