wasm-tools 1.248.0

CLI tools for interoperating with WebAssembly files
Documentation
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
name: CI
on:
  # Run CI for PRs to `main` and to release branches.
  pull_request:
  # This is the CI that runs for PRs-to-merge.
  merge_group:
  # Run full CI on pushes to release branches since the merge queue can't be
  # used with for all release branches (wildcard pattern turns that off)
  push:
    branches:
    - 'release-*'

# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

defaults:
  run:
    shell: bash

jobs:
  build:
    name: Build wasm-tools
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: ${{ github.event_name != 'pull_request' }}
      matrix:
        include:
        - build: x86_64-linux
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu
            DOCKER_IMAGE: ./ci/docker/x86_64-linux/Dockerfile
        - build: x86_64-musl
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
            DOCKER_IMAGE: ./ci/docker/x86_64-musl/Dockerfile
        - build: aarch64-linux
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
            DOCKER_IMAGE: ./ci/docker/aarch64-linux/Dockerfile
        - build: aarch64-musl
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: aarch64-unknown-linux-musl
            DOCKER_IMAGE: ./ci/docker/aarch64-musl/Dockerfile
        - build: riscv64-linux
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: riscv64gc-unknown-linux-gnu
            DOCKER_IMAGE: ./ci/docker/riscv64-linux/Dockerfile

        - build: x86_64-macos
          os: macos-latest
          env:
            CARGO_BUILD_TARGET: x86_64-apple-darwin
            MACOSX_DEPLOYMENT_TARGET: 10.12
        - build: aarch64-macos
          os: macos-latest
          env:
            CARGO_BUILD_TARGET: aarch64-apple-darwin
            MACOSX_DEPLOYMENT_TARGET: 10.12

        - build: x86_64-windows
          os: windows-latest
          env:
            CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
            RUSTFLAGS: -Ctarget-feature=+crt-static
        - build: aarch64-windows
          os: windows-11-arm
          env:
            CARGO_BUILD_TARGET: aarch64-pc-windows-msvc
            RUSTFLAGS: -Ctarget-feature=+crt-static

        - build: wasm32-wasip1
          os: ubuntu-latest
          env:
            CARGO_BUILD_TARGET: wasm32-wasip1
    env: ${{ matrix.env }}
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
    - run: rustup target add $CARGO_BUILD_TARGET
    - run: ./ci/build-release-artifacts.sh
    - run: ./ci/build-tarballs.sh "${{ matrix.build }}"
    - uses: actions/upload-artifact@v4
      with:
        name: bins-${{ matrix.build }}
        path: dist

  test-prefer-btree-collections:
    name: Test (no-hash-maps)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          submodules: true
      - uses: ./.github/actions/install-rust
      - name: Test (prefer-btree-collections)
        run: cargo test --workspace --locked --features prefer-btree-collections

  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: ${{ github.event_name != 'pull_request' }}
      matrix:
        include:
          - os: ubuntu-latest
            rust: stable
          - os: ubuntu-latest
            rust: beta
          - os: ubuntu-latest
            rust: nightly-2026-01-20
          - os: macos-latest
            rust: stable
          - os: windows-latest
            rust: stable
          - os: ubuntu-latest
            rust: msrv
            # skip testing crates that require wasmtime since wasmtime has a
            # more aggressive msrv than wasm-tools
            flags: --exclude fuzz-stats --exclude wit-component --exclude wasm-mutate-stats --exclude wit-dylib --exclude wit-dylib-ffi --exclude test-programs
          # this is the rust nightly that oss-fuzz currently uses so we don't
          # want this to break.
          - os: ubuntu-latest
            rust: nightly-2025-07-16
          # test that if `RUST_BACKTRACE=1` is set in the environment that all
          # tests with blessed error messages still pass.
          - os: ubuntu-latest
            rust: stable
            env:
              RUST_BACKTRACE: 1
          # test the 'try_op' feature
          - os: ubuntu-latest
            rust: stable
            env:
              RUSTFLAGS: --cfg=debug_check_try_op
            flags: -F wasmparser/try-op
    env: ${{ matrix.env || fromJSON('{}') }}
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: ${{ matrix.rust }}
    - run: cargo test --locked --all ${{ matrix.flags }}

  test_extra_features:
    name: Test with extra Cargo features
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
    - run: cargo test --locked -p wasmparser --benches
    - run: cargo test --locked --all-features --manifest-path crates/wasm-encoder/Cargo.toml
    - run: cargo test -p wasm-smith --features wasmparser
    - run: cargo test -p wasm-smith --features component-model
    - run: cargo test --locked -p wasmparser --features try-op

  test_capi:
    name: Test the C API
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: ${{ github.event_name != 'pull_request' }}
      matrix:
        include:
          - os: ubuntu-latest
          - os: macos-latest
          - os: windows-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
    - run: cmake -S examples -B examples/build -DCMAKE_BUILD_TYPE=Release
    - run: cmake --build examples/build --config Release

  testdl:
    name: Test libdl.so
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: 1.89.0
    - run: rustup target add wasm32-wasip1
    - run: cd crates/wit-component/dl && bash check.sh

  wasm:
    name: Test on WebAssembly
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
    - run: rustup target add wasm32-wasip1
    - run: |
        tag=v10.0.1
        curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/${tag}/wasmtime-${tag}-x86_64-linux.tar.xz
        tar xf wasmtime-${tag}-x86_64-linux.tar.xz
        echo `pwd`/wasmtime-${tag}-x86_64-linux >> $GITHUB_PATH
        echo CARGO_TARGET_WASM32_WASIP1_RUNNER='wasmtime run --dir . --' >> $GITHUB_ENV
        echo CARGO_BUILD_TARGET='wasm32-wasip1' >> $GITHUB_ENV
    - run: |
        cargo --locked test --workspace \
          --exclude fuzz-stats \
          --exclude wasm-tools-fuzz \
          --exclude wasm-mutate-stats \
          --exclude dl \
          --exclude test-programs

  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
    - uses: ./.github/actions/install-rust
    - run: rustup component add rustfmt
    - run: printf "\n" > playground/component/src/bindings.rs
    # Note that this doesn't use `cargo fmt` because that doesn't format
    # modules-defined-in-macros which is in use in `wast` for example. This is
    # the best alternative I can come up with at this time
    - run: find . -name '*.rs' | xargs rustfmt --check --edition 2021

  fuzz:
    name: Fuzz
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: nightly
    - run: cargo install cargo-fuzz
    - run: cargo fuzz build --dev -s none
    - run: cargo fuzz build --dev --features wasmtime -s none

  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/install-rust
      - run: rustup target add x86_64-unknown-none
      - run: cargo check --benches -p wasm-smith
      - run: cargo check --no-default-features
      - run: cargo check --no-default-features --features print
      - run: cargo check --no-default-features --features parse
      - run: cargo check --no-default-features --features validate
      - run: cargo check --no-default-features --features smith
      - run: cargo check --no-default-features --features shrink
      - run: cargo check --no-default-features --features mutate
      - run: cargo check --no-default-features --features dump
      - run: cargo check --no-default-features --features objdump
      - run: cargo check --no-default-features --features strip
      - run: cargo check --no-default-features --features compose
      - run: cargo check --no-default-features --features demangle
      - run: cargo check --no-default-features --features component
      - run: cargo check --no-default-features --features metadata
      - run: cargo check --no-default-features --features wit-smith
      - run: cargo check --no-default-features --features addr2line
      - run: cargo check --no-default-features --features json-from-wast
      - run: cargo check --no-default-features --features completion
      - run: cargo check --no-default-features --features wast
      - run: cargo check --no-default-features --features wit-dylib
      - run: cargo check --no-default-features -p wit-parser
      - run: cargo check --no-default-features -p wit-parser --target x86_64-unknown-none
      - run: cargo check --no-default-features -p wit-parser --features wat
      - run: cargo check --no-default-features -p wit-parser --features serde
      - run: cargo check --no-default-features -p wit-parser --features decoding
      - run: cargo check --no-default-features -p wit-parser --features serde,decoding,wat
      - run: cargo check --no-default-features -p wasmparser
      - run: cargo check --no-default-features -p wasmparser --target x86_64-unknown-none
      - run: cargo check --no-default-features -p wasmparser --target x86_64-unknown-none --features validate,serde
      - run: cargo check --no-default-features -p wasmparser --target x86_64-unknown-none --features validate,serde,prefer-btree-collections
      - run: cargo check --no-default-features -p wasmparser --features std
      - run: cargo check --no-default-features -p wasmparser --features validate
      - run: cargo check --no-default-features -p wasmparser --features validate,try-op
      - run: cargo check --no-default-features -p wasmparser --features features
      - run: cargo check --no-default-features -p wasmparser --features features,validate
      - run: cargo check --no-default-features -p wasmparser --features prefer-btree-collections
      - run: cargo check --no-default-features -p wasmparser --features serde
      - run: cargo check --no-default-features -p wasmparser --features serde,prefer-btree-collections
      - run: cargo check --no-default-features -p wasmparser --features component-model
      - run: cargo check --no-default-features -p wasmparser --features component-model,validate
      - run: cargo check --no-default-features -p wasmparser --features std,component-model
      - run: cargo check --no-default-features -p wasmparser --features std,component-model,validate
      - run: cargo check --no-default-features -p wasmprinter
      - run: cargo check --no-default-features -p wasmprinter --features component-model
      - run: cargo check --no-default-features -p wast
      - run: cargo check --no-default-features -p wast --features wasm-module
      - run: cargo check --no-default-features -p wast --features wasm-module,component-model
      - run: cargo check --no-default-features -p wat
      - run: cargo check --no-default-features -p wat --features component-model
      - run: cargo check --no-default-features -p wat --features dwarf
      - run: cargo check --no-default-features --manifest-path crates/wasm-encoder/Cargo.toml
      - run: cargo check --no-default-features --manifest-path crates/wasm-encoder/Cargo.toml --target x86_64-unknown-none
      - run: cargo check --no-default-features --manifest-path crates/wasm-encoder/Cargo.toml --target x86_64-unknown-none --features wasmparser,component-model
      - run: cargo check --no-default-features --manifest-path crates/wasm-encoder/Cargo.toml --features component-model
      - run: cargo check --no-default-features --manifest-path crates/wasm-encoder/Cargo.toml --features wasmparser
      - run: cargo check --no-default-features -p wasm-smith
      - run: cargo check --no-default-features -p wasm-smith --features component-model
      - run: cargo check --no-default-features -p wasm-smith --features wasmparser
      - run: cargo check --no-default-features -p wasm-smith --features wasmparser,component-model
      - run: cargo check --no-default-features -p wasm-smith --features serde
      - run: cargo check --no-default-features -p wasm-metadata
      - run: cargo check --no-default-features -p wasm-metadata --features serde
      - run: cargo check --no-default-features -p wasm-metadata --features oci
      - run: cargo check --no-default-features -p wasm-wave
      - run: cargo check --no-default-features -p wasm-wave --target x86_64-unknown-none
      - run: cargo check --no-default-features -p wasm-wave --features std
      - run: cargo check --no-default-features -p wasm-wave --features wit
      - run: cargo check --no-default-features -p wasm-wave --features std,wit
      - run: cargo check --no-default-features -p wasm-compose
      - run: cargo check --no-default-features -p wasm-compose --features serde
      - run: cargo check --no-default-features -p wasm-compose --features yaml
      - run: |
          if cargo tree -p wasm-smith --no-default-features -e no-dev | grep wasmparser; then
            echo wasm-smith without default features should not depend on wasmparser
            exit 1
          fi

  # Double-check that files and such related to the `tests/cli` test suite are
  # up-to-date.
  generated_files_up_to_date:
    name: Check generated files are up-to-date
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          submodules: true
      - uses: ./.github/actions/install-rust
      - run: rm -rf tests/snapshots
      - run: rustc ci/generate-spec-tests.rs && ./generate-spec-tests
      - run: find tests/cli -name '*.stderr' | xargs rm
      - run: BLESS=1 cargo test --test cli
      - run: git diff --exit-code

  doc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/install-rust
      - run: RUSTDOCFLAGS="-Dwarnings" cargo doc --all

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/install-rust
      - run: rustup component add clippy
      - run: cargo clippy --workspace --all-targets --exclude dl --exclude component

  verify-publish:
    if: github.repository_owner == 'bytecodealliance'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
    - run: rustc ci/publish.rs
    # Make sure we can bump version numbers for the next release
    - run: ./publish bump
    # Make sure the tree is publish-able as-is
    - run: ./publish verify

  # "Join node" which the merge queue waits on.
  ci-status:
    name: Record the result of testing and building steps
    runs-on: ubuntu-latest
    needs:
      - test
      - testdl
      - wasm
      - rustfmt
      - fuzz
      - check
      - doc
      - build
      - verify-publish
      - test_capi
      - test_extra_features
      - test-prefer-btree-collections
      - clippy
      - generated_files_up_to_date
    if: always()

    steps:
    - name: Successful test and build
      if: ${{ !(contains(needs.*.result, 'failure')) }}
      run: exit 0
    - name: Failing test and build
      if: ${{ contains(needs.*.result, 'failure') }}
      run: exit 1
    - name: Report failure on cancellation
      if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
      run: exit 1

  # Once CI has finished on `release-*` branches test to see if a release needs
  # to be made based on the commits of this push.
  maybe-trigger-tag:
    runs-on: ubuntu-latest
    needs: ci-status
    if: |
      always()
      && needs.ci-status.result == 'success'
      && github.event_name == 'push'
      && startsWith(github.ref, 'refs/heads/release-')
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
        fetch-depth: 0
    - uses: ./.github/actions/publish-release
      with:
        cargo_token: ${{ secrets.CARGO_REGISTRY_TOKEN }}