Skip to content

Commit

Permalink
Shrink Wasm binary
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Nov 20, 2024
1 parent ee8bbb2 commit 4249394
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: cargo test
- run: cargo build --package=floretta-wasm --target=wasm32-unknown-unknown --release
- run: cp target/wasm32-unknown-unknown/release/floretta_wasm.wasm floretta.wasm
- run: cargo build --package=floretta-wasm --target=wasm32-unknown-unknown --profile=tiny -Zbuild-std=std,panic_abort -Zbuild-std-features=optimize_for_size,panic_immediate_abort
- run: cp target/wasm32-unknown-unknown/tiny/floretta_wasm.wasm floretta.wasm
- run: .github/summary.py >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ wasmparser = "0.220"
wasmprinter = "0.220"
wasmtime = "26"
wat = "1"

# https://github.com/johnthagen/min-sized-rust
[profile.tiny]
codegen-units = 1
inherits = "release"
lto = true
opt-level = "z"
strip = true
3 changes: 2 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[toolchain]
channel = "stable"
channel = "nightly-2024-11-20"
profile = "default"
components = ["rust-src"]
targets = ["wasm32-unknown-unknown"]

0 comments on commit 4249394

Please sign in to comment.