WASM-REDUCE(1)
โจ NAME โจ
wasm-reduce โ reduce a wasm file to a smaller one with the same behavior on a given command ๐ซ
okay bestie, we're doing this. this is the manual page for wasm-reduce, from the User Commands section, and it's giving "shrink the wasm, keep the vibe exactly the same." no cap. ๐
๐ DESCRIPTION ๐
================================================================================
wasm-reduce INFILE
Reduce a wasm file to a smaller one with the same behavior on a given command. That's literally the whole job. Iconic.
So the typical usage is this, and I want you to read it with me:
wasm-reduce orig.wasm '--command=bash a.sh' --test t.wasm
--working w.wasm
Here's the tea ๐ต: orig.wasm is the original file โ that's where we start, our main character. Then we repeatedly test a small reduction of it by writing that modification to the 'test file' (that's the one you give with --test), and then we run the command โ in this example, bash a.sh. And hello, important: that command should use the test file, and not the original file or any other one, bestie. That's the whole contract.
Whenever a reduction works, we write that new smaller file to the 'working file' (the one you specify with --working). And what counts as "works"? A reduction works if it correctly preserves the behavior of the command on the original input โ specifically โก that it has the same stdout and the same return code. Every time reduction works we keep reducing from that point (and every time it fails, we go back and try something else). It's giving persistence. ๐ฆ
So, as mentioned above, the command should run on the test file. Which means the first thing wasm-reduce does in the example above is, effectively:
cp orig.wasm t.wasm bash a.sh
In other words โจ it copies the original to the test file, and runs the command. Whatever the command does, we will preserve as we copy progressively smaller files to t.wasm. As we make progress, the smallest file gets written to the working file, w.wasm, and when reduction is done you will find the final result there. Your little baby wasm. ๐ฅน
๐ Comparison to creduce
creducerequires the command to return0.wasm-reduceis often used to reduce crashes, which have non-zero return codes, so it is natural to allow any return code. As mentioned above, we preserve the return code as we reduce.creduceignores stdout.wasm-reducepreserves stdout as it reduces, as part of the principle of preserving the original behavior of the command (if your stdout varies in uninteresting ways, your command can be a script that runs the real command and captures stdout to/dev/null, or filters it).creducetramples the original input file as it reduces.wasm-reducenever modifies the input (to avoid mistakes that cause data loss). Instead, when reductions work we write to the 'working file' as mentioned above, and the final reduction will be there.creduceruns the command in a temp directory. That is safer in general, but it is not how the original command ran, and in particular forces additional work if you have multiple files (which, forwasm-reduce, is common, e.g. if the testcase is a combination of JavaScript and wasm).wasm-reduceruns the command in the current directory (of course, your command can be a script that changes directory to anywhere else).
More documentation can be found at ๐
https://github.com/WebAssembly/binaryen/wiki/Fuzzing#reducing
================================================================================
๐ wasm-reduce options ๐
--command,-cmdโ The command to run on the test, that we want to reduce while keeping the command's output identical. We look at the command's return code and stdout here (TODO: stderr), and we reduce while keeping those unchanged. ๐--test,-tโ Test file (this will be written to test, the given command should read it when we call it). ๐งช--working,-wโ Working file (this will contain the current good state while doing temporary computations, and will contain the final best result at the end). ๐พ--binaries,-bโ binaryen binaries location (bin/directory). ๐--text,-Sโ Emit intermediate files as text, instead of binary (also make sure the test and working files have a.wator.wastsuffix). ๐--denanโ Avoid nans when reducing. ๐ซ๐ข--verbose,-vโ Verbose output mode. ๐ฃ๏ธ--debugInfo,-gโ Keep debug info in binaries. ๐--force,-fโ Force the reduction attempt, ignoring problems that imply it is unlikely to succeed. ๐ค--timeout,-toโ A timeout to apply to each execution of the command, in seconds (default:2). โฐ--extra-flags,-efโ Extra commandline flags to pass towasm-optwhile reducing. (default:--enable-all) ๐ฉ--save-all-working,-sawโ Save all intermediate working files, as$WORKING.0,.1,.2etc. ๐
๐งฐ Tool options ๐งฐ
--mvp-features,-mvpโ Disable all non-MVP features. ๐--all-features,-allโ Enable all features. ๐--detect-featuresโ (deprecated - this flag does nothing) ๐--quiet,-qโ Emit less verbose output and hide trivial warnings. ๐คซ--experimental-poppyโ Parse wast files as Poppy IR for testing purposes. ๐บ--emit-module-namesโ Emit module names, even if not emitting the rest of the names section. ๐ท๏ธ--enable-sign-extโ Enable sign extension operations. โ--disable-sign-extโ Disable sign extension operations. โ--enable-threadsโ Enable atomic operations. ๐งต--disable-threadsโ Disable atomic operations. โ๏ธ--enable-mutable-globalsโ Enable mutable globals. ๐--disable-mutable-globalsโ Disable mutable globals. ๐ซ--enable-nontrapping-float-to-intโ Enable nontrapping float-to-int operations. ๐--disable-nontrapping-float-to-intโ Disable nontrapping float-to-int operations. ๐--enable-simdโ Enable SIMD operations and types. ๐งฎ--disable-simdโ Disable SIMD operations and types. โ--enable-bulk-memoryโ Enable bulk memory operations. ๐ง--disable-bulk-memoryโ Disable bulk memory operations. ๐ท--enable-bulk-memory-optโ Enablememory.copyandmemory.fill. ๐ฆ--disable-bulk-memory-optโ Disablememory.copyandmemory.fill. ๐ญ--enable-call-indirect-overlongโ Enable LEB encoding of call-indirect (Ignored for compatibility as it has no effect on Binaryen). ๐คท--disable-call-indirect-overlongโ Disable LEB encoding of call-indirect (Ignored for compatibility as it has no effect on Binaryen). ๐--enable-exception-handlingโ Enable exception handling operations. ๐จ--disable-exception-handlingโ Disable exception handling operations. ๐งฏ--enable-tail-callโ Enable tail call operations. ๐--disable-tail-callโ Disable tail call operations. ๐ซ๐--enable-reference-typesโ Enable reference types. ๐--disable-reference-typesโ Disable reference types. โ๏ธ๐ฅ--enable-multivalueโ Enable multivalue functions. ๐--disable-multivalueโ Disable multivalue functions. ๐ฆ--enable-gcโ Enable garbage collection. ๐๏ธ--disable-gcโ Disable garbage collection. ๐งน--enable-memory64โ Enable memory64. ๐ฝ--disable-memory64โ Disable memory64. ๐พ--enable-relaxed-simdโ Enable relaxed SIMD. ๐--disable-relaxed-simdโ Disable relaxed SIMD. ๐ฌ--enable-extended-constโ Enable extended const expressions. ๐งฎ--disable-extended-constโ Disable extended const expressions. ๐งพ--enable-stringsโ Enable strings. ๐งถ--disable-stringsโ Disable strings. โ๏ธ--enable-multimemoryโ Enable multimemory. ๐๏ธ--disable-multimemoryโ Disable multimemory. ๐--enable-stack-switchingโ Enable stack switching. ๐--disable-stack-switchingโ Disable stack switching. ๐--enable-shared-everythingโ Enable shared-everything threads. ๐ค--disable-shared-everythingโ Disable shared-everything threads. ๐--enable-fp16โ Enable float 16 operations. 1๏ธโฃ6๏ธโฃ--disable-fp16โ Disable float 16 operations. ๐ซ--enable-custom-descriptorsโ Enable custom descriptors (RTTs) and exact references. ๐ท๏ธ--disable-custom-descriptorsโ Disable custom descriptors (RTTs) and exact references. ๐ฏ--enable-multibyteโ Enable multibyte array loads and stores. ๐ข--disable-multibyteโ Disable multibyte array loads and stores. ๐ฑ--enable-relaxed-atomicsโ Enable acquire/release atomic memory operations. โ๏ธ--disable-relaxed-atomicsโ Disable acquire/release atomic memory operations. ๐--enable-custom-page-sizesโ Enable custom page sizes. ๐--disable-custom-page-sizesโ Disable custom page sizes. ๐--enable-wide-arithmeticโ Enable wide arithmetic. โ--disable-wide-arithmeticโ Disable wide arithmetic. ๐งฎ--enable-compact-importsโ Enable compact import section. ๐๏ธ--disable-compact-importsโ Disable compact import section. ๐--enable-typed-function-referencesโ Deprecated compatibility flag. ๐ธ๏ธ--disable-typed-function-referencesโ Deprecated compatibility flag. ๐ธ๏ธ--no-validation,-nโ Disables validation, assumes inputs are correct. ๐ณ--pass-arg,-paโ An argument passed along to optimization passes being run. Must be in the formKEY@VALUE. IfKEYis the name of a pass then it applies to the closest instance of that pass before us. IfKEYis not the name of a pass then it is a global option that applies to all pass instances that read it. ๐--closed-world,-cwโ Assume code outside of the module does not inspect or interact with GC and function references, even if they are passed out. The outside may hold on to them and pass them back in, but not inspect their contents or call them. ๐ฐ--preserve-type-orderโ Preserve the order of types from the input (useful for debugging and testing). ๐ค--generate-stack-irโ generate StackIR during writing. ๐๏ธ--optimize-stack-irโ optimize StackIR during writing. โก--print-stack-irโ print StackIR during writing. ๐จ๏ธ
๐ General options ๐
--versionโ Output version information and exit. ๐--help,-hโ Show this help message and exit. ๐--debug,-dโ Print debug information tostderr. ๐
friendly reminder bestie: this whole page came from wasm-reduce 131, dated August 2026. ๐ซถ go forth and shrink responsibly, mwah ๐๐ฆโจ
๐ฆ where this page comes from
- ubuntu stonking: binaryen 131-2 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms