WASM-OPT(1)

๐Ÿ“ฆ
version 131 ยท 3 versions
, in ubuntu stonking

๐ŸŒธ NAME ๐ŸŒธ

okay so bestie, welcome to wasm-opt ๐Ÿ’– it's a User Commands manual page and its whole entire job is: read, write, and optimize files. that's it, that's the vibe. ๐Ÿฆ‹


โœจ DESCRIPTION โœจ

================================================================================

wasm-opt INFILE

Read, write, and optimize files. ๐Ÿ’…

Example usage:

wasm-opt input.wasm -O3 -o output.wasm

so basically: it reads an input wasm file, optimizes with -O3, and writes out the result. iconic. no notes. ๐Ÿ‘‘

For more on how to optimize effectively, see

https://github.com/WebAssembly/binaryen/wiki/Optimizer-Cookbook
https://github.com/WebAssembly/binaryen/wiki/GC-Optimization-Guidebook

================================================================================


๐ŸŽ€ wasm-opt options ๐ŸŽ€

like, the main-character flags, fr fr:

  • --output, -o โ€” Output file. where the lil guy goes when it's done ๐Ÿซถ
  • --emit-text, -S โ€” Emit text instead of binary for the output file. so you can read it with your eyeballs ๐Ÿ‘€
  • --converge, -c โ€” Run passes to convergence, continuing while binary size decreases. it just keeps going while the numbers go down, obsessed ๐Ÿ“‰
  • --fuzz-exec-before, -feh โ€” Execute functions before optimization, helping fuzzing find bugs. shake it around first and see what falls out ๐Ÿ›
  • --fuzz-exec, -fe โ€” Execute functions before and after optimization, helping fuzzing find bugs. before and after, we love a comparison moment โœจ
  • --fuzz-exec-second โ€” A second module to link with the first, for --fuzz-exec-before (only before, as optimizations are not applied to it). a little plus-one module ๐Ÿงš
  • --extra-fuzz-command, -efc โ€” An extra command to run on the output before and after optimizing. The output is compared between the two, and an error occurs if they are not equal. if they don't match bestie, it's a whole thing ๐Ÿ’€
  • --translate-to-fuzz, -ttf โ€” Translate the input into a valid wasm module *somehow*, useful for fuzzing. yes "somehow" is the official energy here ๐Ÿ™ˆ
  • --initial-fuzz, -if โ€” Initial wasm content in --translate-to-fuzz (-ttf) mode.
  • --fuzz-passes, -fp โ€” When doing --translate-to-fuzz, pick a set of random passes from the input to further shape the wasm. chaos but make it structured ๐ŸŒช๏ธ
  • --no-fuzz-memory โ€” don't emit memory ops when fuzzing.
  • --no-fuzz-oob โ€” don't emit out-of-bounds loads/stores/indirect calls when fuzzing.
  • --fuzz-preserve-imports-exports โ€” don't add imports and exports in -ttf mode, and keep the start. do not perceive them, do not add them ๐Ÿšซ
  • --fuzz-against-js โ€” modify the wasm in valid ways that assume it is used only from JS.
  • --fuzz-import โ€” a module to use as an import in -ttf mode.
  • --emit-spec-wrapper, -esw โ€” Emit a wasm spec interpreter wrapper file that can run the wasm with some test values, useful for fuzzing.
  • --emit-wasm2c-wrapper, -esw โ€” Emit a C wrapper file that can run the wasm after it is compiled with wasm2c, useful for fuzzing. (yes bestie it's the same -esw short flag as the one above, that's literally what the page says, i do not make the rules ๐Ÿ’…)
  • --input-source-map, -ism โ€” Consume source map from the specified file.
  • --output-source-map, -osm โ€” Emit source map to the specified file.
  • --output-source-map-url, -osu โ€” Emit specified string as source map URL.
  • --experimental-new-eh โ€” Deprecated; same as --emit-exnref. it's giving "we're literally so over this one" ๐Ÿ˜ญ
  • --emit-exnref โ€” After running all requested transformations / optimizations, translate the instruction to use the new EH instructions at the end. Depending on the optimization level specified, this may do some more post-translation optimizations. a lil afterparty pass ๐ŸŽ‰

๐Ÿ”ฅ Optimization passes ๐Ÿ”ฅ

the pass list. it's long. it's giving encyclopedia. we're doing all of them, no skips, periodt. ๐Ÿ’œ

  • --abstract-type-refining โ€” refine and merge abstract (never-created) types
  • --alignment-lowering โ€” lower unaligned loads and stores to smaller aligned ones
  • --asyncify โ€” async/await style transform, allowing pausing and resuming โธ๏ธโ–ถ๏ธ
  • --avoid-reinterprets โ€” Tries to avoid reinterpret operations via more loads
  • --cfp โ€” propagate constant struct field values
  • --cfp-reftest โ€” propagate constant struct field values, using ref.test
  • --coalesce-locals โ€” reduce # of locals by coalescing
  • --coalesce-locals-learning โ€” reduce # of locals by coalescing and learning
  • --code-folding โ€” fold code, merging duplicates
  • --code-pushing โ€” push code forward, potentially making it not always execute
  • --const-hoisting โ€” hoist repeated constants to a local
  • --constraint-analysis โ€” finds and uses mathematical constraints on locals
  • --dae โ€” removes arguments to calls in an lto-like manner
  • --dae-optimizing โ€” removes arguments to calls in an lto-like manner, and optimizes where we removed
  • --dae2 โ€” Experimental reimplementation of DAE
  • --dce โ€” removes unreachable code ๐Ÿ—‘๏ธ
  • --dealign โ€” forces all loads and stores to have alignment 1
  • --denan โ€” instrument the wasm to convert NaNs into 0 at runtime
  • --dfo โ€” optimizes using the DataFlow SSA IR
  • --directize โ€” turns indirect calls into direct ones
  • --discard-global-effects โ€” discards global effect info
  • --duplicate-function-elimination โ€” removes duplicate functions
  • --duplicate-import-elimination โ€” removes duplicate imports
  • --dwarfdump โ€” dump DWARF debug info sections from the read binary
  • --emit-target-features โ€” emit the target features section in the output
  • --enclose-world โ€” modify the wasm (destructively) for closed-world โš ๏ธ yes bestie it says destructively, read it again
  • --extract-function โ€” leaves just one function (useful for debugging)
  • --extract-function-index โ€” leaves just one function selected by index
  • --flatten โ€” flattens out code, removing nesting
  • --fpcast-emu โ€” emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work ๐Ÿ™ƒ
  • --func-metrics โ€” reports function metrics
  • --generate-dyncalls โ€” generate dynCall functions used by emscripten ABI
  • --generate-global-effects โ€” generate global effect info (helps later passes)
  • --generate-i64-dyncalls โ€” generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support).
  • --global-refining โ€” refine the types of globals
  • --gsi โ€” globally optimize struct values
  • --gsi-desc-cast โ€” globally optimize struct values, also emitting ref.cast_desc_eq
  • --gto โ€” globally optimize GC types
  • --gufa โ€” Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location
  • --gufa-cast-all โ€” GUFA plus add casts for all inferences
  • --gufa-optimizing โ€” GUFA plus local optimizations in functions we modified
  • --heap-store-optimization โ€” optimize heap (GC) stores
  • --heap2local โ€” replace GC allocations with locals
  • --i64-to-i32-lowering โ€” lower all uses of i64s to use i32s instead
  • --inline-main โ€” inline __original_main into main
  • --inlining โ€” inline functions (you probably want --inlining-optimizing)
  • --inlining-optimizing โ€” inline functions and optimizes where we inlined
  • --instrument-branch-hints โ€” instrument branch hints so we can see which guessed right ๐Ÿ”ฎ
  • --instrument-locals โ€” instrument the build with code to intercept all loads and stores
  • --instrument-memory โ€” instrument the build with code to intercept all loads and stores
  • --intrinsic-lowering โ€” lower away binaryen intrinsics
  • --legalize-and-prune-js-interface โ€” legalizes the import/export boundary and prunes when needed
  • --legalize-js-interface โ€” legalizes i64 types on the import/export boundary
  • --licm โ€” loop invariant code motion
  • --limit-segments โ€” attempt to merge segments to fit within web limits
  • --llvm-memory-copy-fill-lowering โ€” Lower memory.copy and memory.fill to wasm mvp and disable the bulk-memory feature.
  • --llvm-nontrapping-fptoint-lowering โ€” lower nontrapping float-to-int operations to wasm mvp and disable the nontrapping fptoint feature
  • --local-cse โ€” common subexpression elimination inside basic blocks
  • --local-subtyping โ€” apply more specific subtypes to locals where possible
  • --log-execution โ€” instrument the build with logging of where execution goes
  • --mark-js-called โ€” mark js called functions (using configureAll) as doing so
  • --memory-packing โ€” packs memory into separate segments, skipping zeros
  • --memory64-lowering โ€” lower loads and stores to a 64-bit memory to instead use a 32-bit one
  • --merge-blocks โ€” merges blocks to their parents
  • --merge-j2cl-itables โ€” Merges itable structures into vtables to make types more compact
  • --merge-locals โ€” merges locals when beneficial
  • --merge-similar-functions โ€” merges similar functions when benefical (yes, spelled like that in the original, i'm just the messenger ๐Ÿ“)
  • --metrics โ€” reports metrics (with an optional title, --metrics[=TITLE])
  • --minify-imports โ€” minifies import names (only those, and not export names), and emits a mapping to the minified ones
  • --minify-imports-and-exports โ€” minifies both import and export names, and emits a mapping to the minified ones
  • --minify-imports-and-exports-and-modules โ€” minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well
  • --minimize-rec-groups โ€” Split types into minimal recursion groups
  • --monomorphize โ€” creates specialized versions of functions
  • --monomorphize-always โ€” creates specialized versions of functions (even if unhelpful) ๐Ÿ™ˆ
  • --multi-memory-lowering โ€” combines multiple memories into a single memory
  • --multi-memory-lowering-with-bounds-checks โ€” combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data
  • --name-types โ€” (re)name all heap types
  • --nm โ€” name list
  • --no-full-inline โ€” mark functions as no-inline (for full inlining only)
  • --no-inline โ€” mark functions as no-inline
  • --no-partial-inline โ€” mark functions as no-inline (for partial inlining only)
  • --once-reduction โ€” reduces calls to code that only runs once
  • --optimize-added-constants โ€” optimizes added constants into load/store offsets
  • --optimize-added-constants-propagate โ€” optimizes added constants into load/store offsets, propagating them across locals too
  • --optimize-casts โ€” eliminate and reuse casts
  • --optimize-for-js โ€” early optimize of the instruction combinations for js
  • --optimize-instructions โ€” optimizes instruction combinations
  • --optimize-j2cl โ€” optimizes J2CL specific constructs.
  • --outlining โ€” outline instructions
  • --pick-load-signs โ€” pick load signs based on their uses
  • --poppify โ€” Transform Binaryen IR into Poppy IR
  • --post-emscripten โ€” all the lil miscellaneous glow-ups for code that Emscripten made ๐Ÿ’–
  • --precompute โ€” crunches expressions that can be figured out at compile time, so they're just... already done โœจ
  • --precompute-propagate โ€” same energy as --precompute, except it also pushes those computed values through your locals, no cap ๐Ÿซถ
  • --print โ€” prints everything in s-expression format ๐ŸŒธ
  • --print-boundary โ€” prints the boundary in JSON format, iconic ๐ŸŽ€
  • --print-call-graph โ€” prints the call graph, so you can see who's calling whom (drama map fr) ๐Ÿ’…
  • --print-features โ€” prints the options for the features you've got enabled, so you know exactly what you're working with โœจ
  • --print-full โ€” prints in the full s-expression format, extra detailed bestie ๐ŸŒˆ
  • --print-function-map โ€” prints a map of function indexes to names, iykyk ๐Ÿ—บ๏ธ
  • --print-minified โ€” prints in minified s-expression format, compact queen ๐Ÿ’…
  • --propagate-debug-locs โ€” carries debug locations down from parents or previous siblings onto their child nodes ๐Ÿงš
  • --propagate-globals-globally โ€” propagates global values into other globals (handy for tests) ๐Ÿ’œ
  • --remove-exports โ€” yeets exports using a wildcard ๐Ÿ˜ญ
  • --remove-imports โ€” takes imports out and swaps them for nops, gone but not forgotten ๐Ÿ’€
  • --remove-memory โ€” removes memory init (this is the legacy name, so it's giving vintage) ๐ŸŽ€
  • --remove-memory-init โ€” removes memory initialization โœจ
  • --remove-non-js-ops โ€” strips out operations that js can't vibe with ๐Ÿšซ
  • --remove-relaxed-simd โ€” swaps relaxed SIMD instructions out for unreachable ๐ŸŒธ
  • --remove-unused-brs โ€” removes breaks that are sitting at locations where they're just not needed ๐Ÿ™ˆ
  • --remove-unused-module-elements โ€” removes module elements nobody's using, decluttering era ๐Ÿงน
  • --remove-unused-names โ€” removes names from locations that are never branched to โœจ
  • --remove-unused-nonfunction-module-elements โ€” removes unused module elements that aren't functions (yes, specifically the non-function ones) ๐Ÿ’…
  • --remove-unused-types โ€” removes unused private GC types ๐Ÿซถ
  • --reorder-functions โ€” sorts functions by access frequency, hottest first ๐Ÿ”ฅ
  • --reorder-functions-by-name โ€” sorts functions by name (this one's for debugging, so cute) ๐ŸŽ€
  • --reorder-globals โ€” sorts globals by access frequency ๐Ÿ”ฅ
  • --reorder-locals โ€” sorts locals by access frequency ๐Ÿ”ฅ
  • --reorder-types โ€” sorts private types by access frequency ๐Ÿ”ฅ
  • --rereloop โ€” re-optimizes control flow using the relooper algorithm, we love a rerun ๐Ÿ‘‘
  • --roundtrip โ€” writes the module out to binary, then reads it right back in. a lil circular moment โœจ
  • --rse โ€” removes redundant local.sets ๐Ÿงš
  • --safe-heap โ€” instruments loads and stores so they check for invalid behavior ๐Ÿ‘€
  • --separate-data-segments โ€” writes data segments out to a file and strips them from the module ๐Ÿ“ฆ
  • --set-globals โ€” sets the globals you specify to the values you specify ๐ŸŽฏ
  • --signature-pruning โ€” removes params from function signature types wherever it possibly can โœ‚๏ธ
  • --signature-refining โ€” applies more specific subtypes to signature types wherever possible ๐Ÿ’…
  • --signext-lowering โ€” lowers sign-ext operations down to wasm mvp and turns the sign extension feature off ๐ŸŒธ
  • --simplify-globals โ€” all the miscellaneous globals-related optimizations โœจ
  • --simplify-globals-optimizing โ€” same miscellaneous globals-related optimizations, plus it optimizes wherever we swapped global.gets out for constants ๐Ÿซถ
  • --simplify-locals โ€” all the miscellaneous locals-related optimizations ๐Ÿ’–
  • --simplify-locals-nonesting โ€” miscellaneous locals-related optimizations, but with no nesting at all โ€” it preserves flatness ๐ŸงŠ
  • --simplify-locals-nostructure โ€” miscellaneous locals-related optimizations, no structure edition ๐ŸŒˆ
  • --simplify-locals-notee โ€” miscellaneous locals-related optimizations, no tees edition ๐ŸŽ€
  • --simplify-locals-notee-nostructure โ€” miscellaneous locals-related optimizations with absolutely no tees and no structure. minimalist queen ๐Ÿ’…
  • --souperify โ€” emits Souper IR in text form โœ๏ธ
  • --souperify-single-use โ€” emits Souper IR in text form, but single-use nodes only ๐Ÿ“
  • --spill-pointers โ€” spills pointers onto the C stack (this is the one for Boehm-style GC) ๐ŸŒŠ
  • --ssa โ€” ssa-ifies your variables so every one of them gets a single assignment ๐ŸŽฏ
  • --ssa-nomerge โ€” ssa-ifies your variables so each gets a single assignment, ignoring merges ๐Ÿ™…
  • --stack-check โ€” enforces limits on llvm's __stack_pointer global ๐Ÿšง
  • --string-gathering โ€” gathers wasm strings up into globals ๐Ÿงบ
  • --string-lifting โ€” lifts string imports up into wasm strings ๐ŸŽˆ
  • --string-lowering โ€” lowers wasm strings and operations down into imports โฌ‡๏ธ
  • --string-lowering-magic-imports โ€” same as string-lowering, except it encodes well-formed strings as magic imports โœจ
  • --string-lowering-magic-imports-assert โ€” same as string-lowering-magic-imports, except it raises a fatal error if there are invalid strings ๐Ÿ’€
  • --strip โ€” deprecated; same as strip-debug โš ๏ธ
  • --strip-debug โ€” strips debug info, and that includes the names section ๐Ÿงน
  • --strip-dwarf โ€” strips dwarf debug info ๐Ÿงน
  • --strip-eh โ€” strips EH instructions ๐Ÿงน
  • --strip-producers โ€” strips the wasm producers section ๐Ÿงน
  • --strip-target-features โ€” strips the wasm target features section ๐Ÿงน
  • --strip-toolchain-annotations โ€” strips out every toolchain-specific code annotation ๐Ÿงน
  • --stub-unsupported-js โ€” stubs out the JS operations that aren't supported ๐Ÿ™ˆ
  • --symbolmap โ€” (alias for print-function-map) ๐Ÿ—บ๏ธ
  • --table64-lowering โ€” alias for memory64-lowering ๐Ÿ”
  • --trace-calls โ€” instruments the build with code that intercepts specific function calls ๐Ÿ‘€
  • --translate-to-exnref โ€” translates old Phase 3 EH instructions into the new ones with exnref ๐Ÿ”„
  • --translate-to-new-eh โ€” deprecated; same as translate-to-exnref โš ๏ธ
  • --trap-mode-clamp โ€” replaces trapping operations with clamping semantics ๐Ÿงฒ
  • --trap-mode-js โ€” replaces trapping operations with js semantics ๐ŸŸจ
  • --tuple-optimization โ€” optimizes trivial tuples right out of existence ๐Ÿซฅ
  • --type-finalizing โ€” marks every leaf type as final ๐Ÿƒ
  • --type-merging โ€” merges types into their supertypes wherever possible ๐Ÿซ‚
  • --type-refining โ€” applies more specific subtypes to type fields wherever possible ๐Ÿ’…
  • --type-refining-gufa โ€” applies more specific subtypes to type fields wherever possible, using GUFA โœจ
  • --type-ssa โ€” creates new types to help out the other optimizations (team player fr) ๐Ÿซถ
  • --type-unfinalizing โ€” marks every type as non-final (open) ๐Ÿ”“
  • --unsubtyping โ€” removes the subtyping relationships that aren't necessary โœ‚๏ธ
  • --untee โ€” removes local.tees and replaces them with sets and gets ๐Ÿ”
  • --vacuum โ€” sucks up code that's obviously unneeded ๐Ÿงน

๐Ÿš€ Optimization options ๐Ÿš€

bestie this is the big one. the -O dial. turn it up, turn it down, pick your fighter ๐Ÿ’–
  • -O โ€” run the default optimization passes (it's equivalent to -Os) โœจ
  • -O0 โ€” run no optimization passes at all. nothing. raw. ๐Ÿ˜Œ
  • -O1 โ€” run the -O1 optimization passes: quick & useful opts, great for iteration builds ๐Ÿ”
  • -O2 โ€” run the -O2 optimization passes: most of the opts, generally gets you most of the perf ๐Ÿ“ˆ
  • -O3 โ€” run the -O3 optimization passes: it spends potentially a lot of time optimizing, and honestly? it's worth it ๐Ÿ”ฅ
  • -O4 โ€” run the -O4 optimization passes: this one also flattens the IR, which can take a lot more time and memory, but it's genuinely useful on more nested / complex / less-optimized input ๐Ÿ’…
  • -Os โ€” run the default optimization passes, but focusing on code size ๐Ÿ“ฆ
  • -Oz โ€” run the default optimization passes with super-focus on code size. teeny tiny ๐Ÿ‘‘
  • --optimize-level,-ol โ€” how much to focus on optimizing code โšก
  • --shrink-level,-s โ€” how much to focus on shrinking code size ๐Ÿœ
  • --debuginfo,-g โ€” emit the names section in the wasm binary (or full debuginfo in wast) ๐Ÿ›
  • --always-inline-max-function-size,-aimfs โ€” the max size of functions that are always inlined (default 2, which is safe to use with -Os builds) ๐Ÿซถ
  • --flexible-inline-max-function-size,-fimfs โ€” the max size of functions that get inlined when they're lightweight (no loops or function calls) while optimizing aggressively for speed (-O3). Default: 20 ๐Ÿชถ
  • --one-caller-inline-max-function-size,-ocimfs โ€” the max size of functions that get inlined when there's only one caller (default -1, which means all such functions are inlined) โ˜๏ธ
  • --inline-max-combined-binary-size,-imcbs โ€” the max size of combined functions after inlining. Default: 409600 ๐Ÿ“
  • --inline-functions-with-loops,-ifwl โ€” allow inlining of functions that have loops ๐Ÿ”„
  • --partial-inlining-ifs,-pii โ€” the number of ifs allowed in partial inlining (zero means partial inlining is disabled) (default: 0) ๐Ÿค”
  • --ignore-implicit-traps,-iit โ€” optimize under the helpful assumption that no surprising traps occur (from load, div/mod, etc.) โš ๏ธ
  • --traps-never-happen,-tnh โ€” optimize under the helpful assumption that no trap is ever reached at runtime (from load, div/mod, etc.) ๐Ÿ™ˆ
  • --low-memory-unused,-lmu โ€” optimize under the helpful assumption that the low 1K of memory isn't used by the application ๐Ÿง 
  • --fast-math,-ffm โ€” optimize floats without handling the corner cases of NaNs and rounding ๐ŸŒŠ
  • --zero-filled-memory,-uim โ€” assume that an imported memory will be zero-initialized 0๏ธโƒฃ
  • --skip-pass,-sp โ€” skip a pass (as in, don't run it) ๐Ÿ™…

๐Ÿ› ๏ธ Tool options ๐Ÿ› ๏ธ

  • --mvp-features,-mvp โ€” disable every non-MVP feature ๐Ÿšซ
  • --all-features,-all โ€” enable every feature. all of them. the whole buffet ๐Ÿฝ๏ธ
  • --detect-features โ€” (deprecated - this flag does nothing) ๐Ÿ’€
  • --quiet,-q โ€” emit less verbose output and hide the trivial warnings. peace and quiet era ๐Ÿคซ
  • --experimental-poppy โ€” parse wast files as Poppy IR, for testing purposes ๐ŸŒผ
  • --emit-module-names โ€” emit module names, even if you're 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 โ€” enable memory.copy and memory.fill ๐Ÿ“‹
  • --disable-bulk-memory-opt โ€” disable memory.copy and memory.fill ๐Ÿšซ
  • --enable-call-indirect-overlong โ€” enable LEB encoding of call-indirect (ignored for compatibility, since it has no effect on Binaryen) ๐Ÿคท
  • --disable-call-indirect-overlong โ€” disable LEB encoding of call-indirect (ignored for compatibility, since it has no effect on Binaryen) ๐Ÿคท
  • --enable-exception-handling โ€” turns ON exception handling operations ๐Ÿ’–
  • --disable-exception-handling โ€” turns OFF exception handling operations
  • --enable-tail-call โ€” turns ON tail call operations โœจ
  • --disable-tail-call โ€” turns OFF tail call operations
  • --enable-reference-types โ€” turns ON reference types ๐ŸŽ€
  • --disable-reference-types โ€” turns OFF reference types
  • --enable-multivalue โ€” turns ON multivalue functions ๐Ÿฆ‹
  • --disable-multivalue โ€” turns OFF multivalue functions
  • --enable-gc โ€” turns ON garbage collection ๐ŸŒธ
  • --disable-gc โ€” turns OFF garbage collection
  • --enable-memory64 โ€” turns ON memory64 ๐Ÿ’…
  • --disable-memory64 โ€” turns OFF memory64
  • --enable-relaxed-simd โ€” turns ON relaxed SIMD ๐Ÿซถ
  • --disable-relaxed-simd โ€” turns OFF relaxed SIMD
  • --enable-extended-const โ€” turns ON extended const expressions ๐Ÿ˜ญ
  • --disable-extended-const โ€” turns OFF extended const expressions
  • --enable-strings โ€” turns ON strings ๐Ÿ”ฅ
  • --disable-strings โ€” turns OFF strings
  • --enable-multimemory โ€” turns ON multimemory ๐Ÿ‘‘
  • --disable-multimemory โ€” turns OFF multimemory
  • --enable-stack-switching โ€” turns ON stack switching ๐ŸŒˆ
  • --disable-stack-switching โ€” turns OFF stack switching
  • --enable-shared-everything โ€” turns ON shared-everything threads โญ
  • --disable-shared-everything โ€” turns OFF shared-everything threads
  • --enable-fp16 โ€” turns ON float 16 operations ๐Ÿ’€
  • --disable-fp16 โ€” turns OFF float 16 operations
  • --enable-custom-descriptors โ€” turns ON custom descriptors (RTTs) and exact references ๐Ÿ™ˆ
  • --disable-custom-descriptors โ€” turns OFF custom descriptors (RTTs) and exact references
  • --enable-multibyte โ€” turns ON multibyte array loads and stores ๐Ÿ“
  • --disable-multibyte โ€” turns OFF multibyte array loads and stores
  • --enable-relaxed-atomics โ€” turns ON acquire/release atomic memory operations ๐Ÿงš
  • --disable-relaxed-atomics โ€” turns OFF acquire/release atomic memory operations
  • --enable-custom-page-sizes โ€” turns ON custom page sizes ๐Ÿ’œ
  • --disable-custom-page-sizes โ€” turns OFF custom page sizes
  • --enable-wide-arithmetic โ€” turns ON wide arithmetic ๐Ÿ’–
  • --disable-wide-arithmetic โ€” turns OFF wide arithmetic
  • --enable-compact-imports โ€” turns ON compact import section โœจ
  • --disable-compact-imports โ€” turns OFF compact import section
  • --enable-typed-function-references โ€” deprecated compat flag, bestie, it's just vibing here for the old days ๐Ÿ’€
  • --disable-typed-function-references โ€” also a deprecated compatibility flag, same energy ๐Ÿ™ˆ
  • --no-validation, -n โ€” disables validation, and yes it literally just assumes your inputs are correct ๐Ÿ˜ญ it does NOT check for you, it trusts you completely, which is either iconic or terrifying depending on the day
  • --pass-arg, -pa โ€” an argument you pass along to whatever optimization passes are being run ๐Ÿซถ. It must be in the form KEY@VALUE. If KEY is the name of a pass then it applies to the closest instance of that pass before us. If KEY isn't the name of a pass then it's 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 (so good for debugging and testing, fr fr) ๐ŸŒธ
  • --generate-stack-ir โ€” generate StackIR during writing ๐Ÿฆ‹
  • --optimize-stack-ir โ€” optimize StackIR during writing ๐ŸŽ€
  • --print-stack-ir โ€” print StackIR during writing ๐Ÿ’…
  • --no-stack-ir โ€” do not use StackIR (even when it is the default) ๐Ÿšซ

๐ŸŽ€ General options ๐ŸŒˆ

the little housekeeping besties, the ones you actually need every single day

  • --version โ€” output version information and exit โญ
  • --help, -h โ€” show this help message and exit ๐Ÿซถ
  • --debug, -d โ€” print debug information to stderr ๐Ÿ›

and that's the whole thing, bestie, you made it to the end ๐Ÿ’– this was wasm-opt from version 131, dated August 2026, and the page you just read is WASM-OPT(1). go forth and optimize, no cap ๐Ÿ‘‘โœจ

๐Ÿ“ฆ where this page comes from