WASM-TOOLS(1)
π 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.wasmis a Wasm file that triggers a crash in your Wasm compiler when you try to compile it, andcompile.shis 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 (-vinfo,-vvdebug,-vvvtrace). 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
- ubuntu stonking: wasm-tools 1.239.0+ds-10 Β· Apache-2.0 OR Apache-2.0 WITH LLVM exception OR MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms