WASM-TOOLS(1)

NAME
wasm-tools shrink - Shrink a Wasm file while maintaining a property of interest (such as triggering a compiler bug).

SYNOPSIS
wasm-tools shrink [OPTIONS] <PREDICATE> [INPUT]

DESCRIPTION
Shrink a Wasm file while maintaining a property of interest (such as triggering a compiler bug).

## Example

Given that

* `crasher.wasm` is a Wasm file that triggers a crash in your Wasm compiler when you try to compile it, and

* `compile.sh` is a script that exits with code zero if its first command-line argument triggers a crash in your Wasm compiler, and exits with a non-zero code otherwise.

then you can shrink `crasher.wasm` into a smaller Wasm file that still triggers the crash and save it at `shrunken.wasm` with the following command:

$ wasm-shrink compile.sh crasher.wasm -o shrunken.wasm

  Arguments:

    <PREDICATE>

    The interestingness predicate script

    [INPUT]

    Input file to process.

    If not provided or if this is `-` then stdin is read entirely and processed. Note that for most subcommands this input can either be a binary `*.wasm` file or a textual format `*.wat` file.

OPTIONS

-a, --attempts <ATTEMPTS>

    The number of shrink attempts to try before considering a Wasm module as small as it will ever get

    [default: 1000]

--allow-empty

    Allow shrinking the input down to an empty Wasm module.

    This is usually not desired and typically reflects a bug in the predicate script.

-s, --seed <SEED>

    The RNG seed for choosing which size-reducing mutation to attempt next

    [default: 42]

--generate-dwarf <lines|full>

    Optionally generate DWARF debugging information from WebAssembly text files.

    When the input to this command is a WebAssembly text file, such as `*.wat`, then this option will instruct the text parser to insert DWARF debugging information to map binary locations back to the original source locations in the input `*.wat` file. This option has no effect if the `INPUT` argument is already a WebAssembly binary or if the text format uses `(module binary ...)`.

-g

    Shorthand for `--generate-dwarf full`

-o, --output <OUTPUT>

    Where to place output.

    If not provided then stdout is used.

-v, --verbose...

    Use verbose output (-v info, -vv debug, -vvv trace)

--color <COLOR>

    Configuration over whether terminal colors are used in output.

    Supports one of `auto|never|always|always-ansi`. The default is to detect what to do based on the terminal environment, for example by using `isatty`.

    [default: auto]

-h, --help

    Print help (see a summary with '-h')