WASM2JS(1)

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

๐Ÿ’– WASM2JS(1) โ€” User Commands ๐Ÿ’–

okay bestie, sit down, hydrate, because this is the wasm2js glow-up page and it is long. we're doing this in cute little chunks so your brain doesn't melt. โœจ


๐ŸŒธ NAME ๐ŸŒธ

wasm2js โ€” literally just: transform .wasm/.wat files to asm.js. that's the whole vibe. ๐Ÿฆ‹

๐ŸŽ€ DESCRIPTION ๐ŸŽ€

so the shape of the whole thing is this:

wasm2js INFILE

and that's it! feed it a .wasm or .wat file, it hands you back asm.js. iconic behaviour, no notes. ๐Ÿ’…

๐ŸŒˆ wasm2js options ๐ŸŒˆ

these are the top-level switches, the main-character flags, the ones that shape the whole output before we get into the spicy optimization stuff. ๐Ÿซถ

  • --output, -o โ€” where do you want the good stuff to land? give it an output file. if you don't specify one, it just goes straight to stdout. you know, raw. unhinged. love that for you. ๐Ÿ’–
  • --allow-asserts โ€” lets you compile .wast testing asserts. yes, the testing-flavoured ones. go off. ๐ŸŽ€
  • --pedantic โ€” emulates WebAssembly trapping behavior. being pedantic is a personality, and here it's a feature. ๐Ÿ’€
  • --emscripten โ€” emulates the glue in emscripten-compatible form, and NOT in ES6 module form. so like, the old-school shape. pick your lane bestie. ๐ŸŒธ
  • --deterministic โ€” replaces WebAssembly trapping behavior deterministically. okay so real talk, the default is that it simply does not care what would trap in wasm โ€” we're talking a load out of bounds, integer divide by zero, the whole chaotic mess. with this flag we try to be deterministic at least in what happens, which might or might not be to trap like wasm actually does โ€” but at least it shouldn't vary. so: chaotic-but-consistent. slay. โœจ
  • --symbols-file โ€” emits a symbols file that maps function indexes to their original names. a little name tag for every function. so cute, so useful. ๐Ÿท๏ธ

๐ŸŒŸ Optimization passes ๐ŸŒŸ

this is the big one. the list. the way that there are like forty of these and every single one is doing something in the background like a little fairy godmother of your binary. ๐Ÿงš buckle up. โญ

  • --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. pausing? resuming? main character energy fr. ๐Ÿ”ฅ
  • --avoid-reinterprets โ€” tries to avoid reinterpret operations via more loads. load more, reinterpret less. ๐ŸŒˆ
  • --cfp โ€” propagate constant struct field values. ๐Ÿ“ฆ
  • --cfp-reftest โ€” propagate constant struct field values, using ref.test. same energy, different tool. ๐Ÿ’…
  • --coalesce-locals โ€” reduce # of locals by coalescing. fewer locals, same lore. ๐Ÿซถ
  • --coalesce-locals-learning โ€” reduce # of locals by coalescing and learning. it's studying. it's growing. ๐Ÿ‘‘
  • --code-folding โ€” fold code, merging duplicates. ๐Ÿ“
  • --code-pushing โ€” push code forward, potentially making it not always execute. moving things downstream, sometimes so they justโ€ฆ don't run. ๐Ÿ˜ญ
  • --const-hoisting โ€” hoist repeated constants to a local. ๐ŸŽˆ
  • --constraint-analysis โ€” finds and uses mathematical constraints on locals. math girlies rise. ๐Ÿ“
  • --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. glow-up edition. โœจ
  • --dae2 โ€” experimental reimplementation of DAE. (it's giving sequel. it's giving season two.) ๐Ÿ’€
  • --dce โ€” removes unreachable code. if you can't get there, it doesn't exist bestie. ๐Ÿšซ
  • --dealign โ€” forces all loads and stores to have alignment 1. no cap. ๐ŸŒธ
  • --denan โ€” instrument the wasm to convert NaNs into 0 at runtime. bye bye NaN, hello zero. ๐ŸŽ€
  • --dfo โ€” optimizes using the DataFlow SSA IR. ๐Ÿ’–
  • --directize โ€” turns indirect calls into direct ones. no more middleman. ๐Ÿ’…
  • --discard-global-effects โ€” discards global effect info. ๐Ÿ—‘๏ธ
  • --duplicate-function-elimination โ€” removes duplicate functions. if you have two, keep one. ๐Ÿซถ
  • --duplicate-import-elimination โ€” removes duplicate imports. same energy, import edition. ๐ŸŒˆ
  • --dwarfdump โ€” dump DWARF debug info sections from the read binary. deep lore extraction. ๐Ÿ”
  • --emit-target-features โ€” emit the target features section in the output. ๐Ÿท๏ธ
  • --enclose-world โ€” modify the wasm (destructively) for closed-world. yes bestie, destructively. it says so right there. ๐Ÿ™ˆ
  • --extract-function โ€” leaves just one function (useful for debugging). โœ‚๏ธ
  • --extract-function-index โ€” leaves just one function selected by index. same but numbered. ๐Ÿ”ข
  • --flatten โ€” flattens out code, removing nesting. no more layers, just vibes. ๐Ÿ“
  • --fpcast-emu โ€” emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work. sometimes. we said sometimes. โš ๏ธ
  • --func-metrics โ€” reports function metrics. ๐Ÿ“Š
  • --generate-dyncalls โ€” generate dynCall functions used by emscripten ABI. ๐ŸŽ€
  • --generate-global-effects โ€” generate global effect info (helps later passes). helping the girlies downstream. ๐Ÿซถ
  • --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. yes, that's the literal name. yes, it's iconic. ๐Ÿ‘‘
  • --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). okay but literally it's telling you what you want. listen to it. ๐Ÿ™ˆ
  • --inlining-optimizing โ€” inline functions and optimizes where we inlined. the deluxe version. ๐Ÿ’…
  • --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. (yes it's the same line as the one above, no we did not skip it, we are keeping everything, periodt.) ๐Ÿ“Œ
  • --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. family reunion. ๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ง
  • --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. (that's their spelling, not mine, and we keep it exact bestie.) ๐ŸŽ€
  • --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. (the full package, the deluxe, the everything.) ๐Ÿ’…
  • --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). it doesn't care if it's unhelpful, it's doing it anyway. ๐Ÿ˜ญ
  • --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. 1๏ธโƒฃ
  • --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 โ€” miscellaneous optimizations for Emscripten-generated code. ๐Ÿซถ
  • --precompute โ€” computes compile-time evaluatable expressions. ๐Ÿงฎ
  • --precompute-propagate โ€” computes compile-time evaluatable expressions and propagates them through locals. ๐Ÿงฎโœจ
  • --print โ€” print in s-expression format. ๐Ÿ–จ๏ธ
  • --print-boundary โ€” print boundary in JSON format. ๐Ÿ–จ๏ธ๐ŸŽ€
  • --print-call-graph โ€” print call graph. ๐Ÿ“ˆ
  • --print-features โ€” print options for enabled features. ๐Ÿ“‹
  • --print-full โ€” print in full s-expression format. ๐Ÿ–จ๏ธ๐Ÿ’–
  • --print-function-map โ€” print a map of function indexes to names. ๐Ÿ—บ๏ธ
  • --print-minified โ€” print in minified s-expression format. ๐Ÿ–จ๏ธ๐Ÿ—œ๏ธ
  • --propagate-debug-locs โ€” propagate debug location from parents or previous siblings to child nodes. ๐ŸŒณ
  • --propagate-globals-globally โ€” propagate global values to other globals (useful for tests). ๐ŸŒ
  • --remove-exports โ€” removes exports using a wildcard. ๐Ÿƒ
  • --remove-imports โ€” removes imports and replaces them with nops. ๐Ÿซฅ
  • --remove-memory โ€” removes memory init (legacy name). ๐Ÿ‘ต (the name is legacy, not the flag. keep up bestie.)
  • --remove-memory-init โ€” removes memory initialization. ๐Ÿงน
  • --remove-non-js-ops โ€” removes operations incompatible with js. ๐Ÿšซ
  • --remove-relaxed-simd โ€” replaces relaxed SIMD instructions with unreachable. ๐Ÿ’€
  • --remove-unused-brs โ€” removes breaks from locations that are not needed. โœ‚๏ธ
  • --remove-unused-module-elements โ€” removes unused module elements. ๐Ÿงน
  • --remove-unused-names โ€” removes names from locations that are never branched to. ๐Ÿท๏ธ๐Ÿšซ
  • --remove-unused-nonfunction-module-elements โ€” removes unused module elements that are not functions. ๐Ÿงฝ
  • --remove-unused-types โ€” remove unused private GC types. โ™ป๏ธ
  • --reorder-functions โ€” sorts functions by access frequency. ๐Ÿ“Š
  • --reorder-functions-by-name โ€” sorts functions by name (useful for debugging). ๐Ÿ”ค

and bestieโ€ฆ that is genuinely not the whole list. it keeps going. come back for part two, we're not even done being iconic yet. ๐Ÿ’–๐Ÿฆ‹

  • --reorder-globals โ€” sorts globals by access frequency โœจ hottest globals first, bestie
  • --reorder-locals โ€” sorts locals by access frequency ๐Ÿ’…
  • --reorder-types โ€” sorts private types by access frequency, no cap
  • --rereloop โ€” re-optimize control flow using the relooper algorithm ๐Ÿ” iconic
  • --roundtrip โ€” write the module to binary, then read it back. it's giving "just to be sure" ๐Ÿฆ‹
  • --rse โ€” remove redundant local.sets ๐Ÿงน
  • --safe-heap โ€” instrument loads and stores to check for invalid behavior. safety girl summer ๐Ÿ’–
  • --separate-data-segments โ€” write data segments to a file and strip them from the module
  • --set-globals โ€” sets specified globals to specified values
  • --signature-pruning โ€” remove params from function signature types where possible โœ‚๏ธ
  • --signature-refining โ€” apply more specific subtypes to signature types where possible
  • --signext-lowering โ€” lower sign-ext operations to wasm mvp and disable the sign extension feature
  • --simplify-globals โ€” miscellaneous globals-related optimizations
  • --simplify-globals-optimizing โ€” miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants
  • --simplify-locals โ€” miscellaneous locals-related optimizations
  • --simplify-locals-nonesting โ€” miscellaneous locals-related optimizations (no nesting at all; preserves flatness) ๐Ÿซถ flat is a vibe
  • --simplify-locals-nostructure โ€” miscellaneous locals-related optimizations (no structure)
  • --simplify-locals-notee โ€” miscellaneous locals-related optimizations (no tees)
  • --simplify-locals-notee-nostructure โ€” miscellaneous locals-related optimizations (no tees or structure) ๐Ÿ’€ none of the above
  • --souperify โ€” emit Souper IR in text form
  • --souperify-single-use โ€” emit Souper IR in text form (single-use nodes only)
  • --spill-pointers โ€” spill pointers to the C stack (useful for Boehm-style GC)
  • --ssa โ€” ssa-ify variables so that they have a single assignment ๐Ÿ‘‘ one assignment, one queen
  • --ssa-nomerge โ€” ssa-ify variables so that they have a single assignment, ignoring merges
  • --stack-check โ€” enforce limits on llvm's __stack_pointer global
  • --string-gathering โ€” gathers wasm strings to globals ๐Ÿงบ
  • --string-lifting โ€” lift string imports to wasm strings โฌ†๏ธ
  • --string-lowering โ€” lowers wasm strings and operations to imports โฌ‡๏ธ
  • --string-lowering-magic-imports โ€” same as string-lowering, but encodes well-formed strings as magic imports โœจ
  • --string-lowering-magic-imports-assert โ€” same as string-lowering-magic-imports, but raise a fatal error if there are invalid strings ๐Ÿ˜ญ
  • --strip โ€” deprecated; same as strip-debug
  • --strip-debug โ€” strip debug info (including the names section)
  • --strip-dwarf โ€” strip dwarf debug info
  • --strip-eh โ€” strip EH instructions
  • --strip-producers โ€” strip the wasm producers section
  • --strip-target-features โ€” strip the wasm target features section
  • --strip-toolchain-annotations โ€” strip all toolchain-specific code annotations
  • --stub-unsupported-js โ€” stub out unsupported JS operations
  • --symbolmap โ€” (alias for print-function-map)
  • --table64-lowering โ€” alias for memory64-lowering
  • --trace-calls โ€” instrument the build with code to intercept specific function calls ๐Ÿ”
  • --translate-to-exnref โ€” translate old Phase 3 EH instructions to new ones with exnref
  • --translate-to-new-eh โ€” deprecated; same as translate-to-exnref
  • --trap-mode-clamp โ€” replace trapping operations with clamping semantics
  • --trap-mode-js โ€” replace trapping operations with js semantics
  • --tuple-optimization โ€” optimize trivial tuples away
  • --type-finalizing โ€” mark all leaf types as final ๐Ÿ”’
  • --type-merging โ€” merge types to their supertypes where possible
  • --type-refining โ€” apply more specific subtypes to type fields where possible
  • --type-refining-gufa โ€” apply more specific subtypes to type fields where possible (using GUFA)
  • --type-ssa โ€” create new types to help other optimizations
  • --type-unfinalizing โ€” mark all types as non-final (open) ๐Ÿ”“
  • --unsubtyping โ€” removes unnecessary subtyping relationships
  • --untee โ€” removes local.tees, replacing them with sets and gets
  • --vacuum โ€” removes obviously unneeded code ๐Ÿงฝ it's giving spring cleaning

๐ŸŒˆ Optimization options ๐ŸŒˆ

  • -O โ€” execute default optimization passes (equivalent to -Os)
  • -O0 โ€” execute no optimization passes ๐Ÿ™ˆ
  • -O1 โ€” execute -O1 optimization passes (quick&useful opts, useful for iteration builds)
  • -O2 โ€” execute -O2 optimization passes (most opts, generally gets most perf) ๐Ÿ”ฅ
  • -O3 โ€” execute -O3 optimization passes (spends potentially a lot of time optimizing) โณ
  • -O4 โ€” execute -O4 optimization passes (also flatten the IR, which can take a lot more time and memory, but is useful on more nested / complex / less-optimized input) ๐Ÿ’€ main character energy but at what cost
  • -Os โ€” execute default optimization passes, focusing on code size
  • -Oz โ€” execute default optimization passes, super-focusing on code size ๐ŸŽ€ smol is the goal
  • --optimize-level,-ol โ€” How much to focus on optimizing code
  • --shrink-level,-s โ€” How much to focus on shrinking code size
  • --debuginfo,-g โ€” Emit names section in wasm binary (or full debuginfo in wast)
  • --always-inline-max-function-size,-aimfs โ€” Max size of functions that are always inlined (default 2, which is safe for use with -Os builds)
  • --flexible-inline-max-function-size,-fimfs โ€” Max size of functions that are inlined when lightweight (no loops or function calls) when optimizing aggressively for speed (-O3). Default: 20
  • --one-caller-inline-max-function-size,-ocimfs โ€” Max size of functions that are inlined when there is only one caller (default -1, which means all such functions are inlined)
  • --inline-max-combined-binary-size,-imcbs โ€” Max size of combined functions after inlining. Default: 409600
  • --inline-functions-with-loops,-ifwl โ€” Allow inlining functions with loops ๐Ÿ”
  • --partial-inlining-ifs,-pii โ€” 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 reached at runtime (from load, div/mod, etc.)
  • --low-memory-unused,-lmu โ€” Optimize under the helpful assumption that the low 1K of memory is not used by the application
  • --fast-math,-ffm โ€” Optimize floats without handling corner cases of NaNs and rounding
  • --zero-filled-memory,-uim โ€” Assume that an imported memory will be zero-initialized
  • --skip-pass,-sp โ€” Skip a pass (do not run it) ๐Ÿ™…โ€โ™€๏ธ
ok quick vibe check bestie: read those "helpful assumption" ones carefully โ€” they're literally assumptions about your program, so if they're wrong, that's on you, fr fr.

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

  • --mvp-features,-mvp โ€” Disable all non-MVP features
  • --all-features,-all โ€” Enable all features ๐Ÿ”ฅ everything everywhere all at once
  • --detect-features โ€” (deprecated - this flag does nothing) ๐Ÿ’€ it's giving ghost
  • --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 โ€” 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 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
  • --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

โœจ every single one of those has an --enable- / --disable- twin, so if you turn a feature on you can always turn it right back off. balance, bestie ๐Ÿ’–
  • --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 the compact import section ๐ŸŽ€
  • --disable-compact-imports โ€” turns OFF the compact import section ๐ŸŽ€
  • --enable-typed-function-references โ€” deprecated compatibility flag โš ๏ธ (yes bestie, it's a legacy thing, no cap)
  • --disable-typed-function-references โ€” deprecated compatibility flag โš ๏ธ (same energy, other direction)
  • --no-validation,-n โ€” straight up disables validation, because it just assumes ur inputs are correct ๐Ÿ˜ญ like okay queen, live dangerously
  • --pass-arg,-pa โ€” an argument that gets passed along to the optimization passes being run. Has to be in the form KEY@VALUE, fr fr. 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 doesn't inspect or interact with GC and function references, even if they get passed out. The outside may hold on to them and pass them back in, but it won't inspect their contents or call them ๐Ÿซถ
  • --preserve-type-order โ€” preserve the order of types from the input (lowkey 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 ๐ŸŒธ
  • --no-stack-ir โ€” do not use StackIR (even when it is the default) ๐Ÿ’€

๐ŸŒˆ General options ๐ŸŒˆ

  • --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, ur officially a wasm2js scholar ๐Ÿ“šโœจ it's giving main character compiler energy tbh. this was wasm2js 131, dated August 2026, and if u ever forget a flag just come back and reread ur girl's notes ๐Ÿ’œ no gatekeeping, periodt ๐ŸŽ€

๐Ÿ“ฆ where this page comes from