WASM-TOOLS(1)

πŸ“¦ version 1.239.0, in ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, welcome to wasm-tools shrink β€” the little tool that takes a Wasm file and munches it down while keeping a property of interest alive, like triggering a compiler bug. no cap, it's literally the "make the bug small enough to actually debug" machine. πŸ¦‹


✨ SYNOPSIS ✨

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

🌸 DESCRIPTION 🌸

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

That's it, that's the whole vibe: you hand it something big and cursed, it hands you back something small and equally cursed. πŸ’…

πŸŽ€ Example πŸŽ€

So picture this, bestie:

  • 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.

Okay so given all that 😌, 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

iconic behavior, honestly. πŸ‘‘

🧚 Arguments 🧚

  • <PREDICATE> β€” the interestingness predicate script. this is the thing that tells the shrinker "yesss keep it, this one's still cursed" 🌈
  • [INPUT] β€” the input file to process.

If not provided or if this is - then stdin is read entirely and processed. lowkey important: for most subcommands this input can either be a binary *.wasm file or a textual format *.wat file. so bring whichever one you got. 🫢


πŸ’œ OPTIONS πŸ’œ

  • -a, --attempts <ATTEMPTS> β€” how many 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.
okay bestie listen: this is usually not desired and typically reflects a bug in the predicate script. if you turn this on and get an empty boi back, your script is lying to you. 😭
  • -s, --seed <SEED> β€” the RNG seed that picks which size-reducing mutation to attempt next. deterministic chaos, we love her. ✨

[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. short queen behavior. πŸ’…
  • -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). the more v's, the more tea. πŸ“
  • --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). your girl always got the receipts. πŸŽ€

🌈 SEE ALSO 🌈

no extra cross-references in this one bestie, it's just us and the shrinker. πŸ¦‹


and that's the whole page!! manual name was WASM-TOOLS(1), this page is wasm-tools shrink, and it's from version 1.239.0+ds, dated August 2026. mwah, go shrink something cursed, ily, byeee πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from