Stream: general

Topic: WebAssembly pass/transformation libraries written in Rust


view this post on Zulip Ian Davis (Feb 25 2026 at 16:52):

Are there any well-supported WebAssembly pass or transformation libraries written in Rust? I’m looking for a framework with a robust IR that supports both existing passes and the development of custom ones.

I’ve evaluated Walrus and Waffle, but Walrus appears primarily tailored to wasm-bindgen, and Waffle, while interesting, lacks coverage of several important WASM features. Neither seem to be under very active development with only a couple commits over the last couple years. Ideally, I’d like to avoid (re)implementing something, especially on the scale of Binaryen.

view this post on Zulip Chris Fallin (Feb 25 2026 at 16:55):

Waffle is well-supported in the sense that I'm the author and am here and happy to take PRs :-) It isn't actively developed because, well, I'm just one person; but if there are missing bits, feel free to send contributions

view this post on Zulip Chris Fallin (Feb 25 2026 at 16:57):

(I have more thoughts on "no recent commits == bad" which I'll mostly leave aside; just to say that stable software can remain working for what's needed)

view this post on Zulip Victor Adossi (Feb 25 2026 at 17:05):

See also wirm, formerly known as Orca

view this post on Zulip Ian Davis (Feb 25 2026 at 17:20):

Chris Fallin said:

(I have more thoughts on "no recent commits == bad" which I'll mostly leave aside; just to say that stable software can remain working for what's needed)

I never said what you have quoted, and I agree with you.

I am looking for something that already supports current WebAssembly features and continues to evolve with it. Maybe that doesn't exist, but that's why I'm asking about what is available.

view this post on Zulip Bailey Hayes (Feb 25 2026 at 17:23):

wirm will soon get additional component model traversal support. It certainly cleaned up what I was doing here: https://github.com/cosmonic-labs/cviz/pull/1/changes

view this post on Zulip Chris Fallin (Feb 25 2026 at 17:24):

Sorry, that's an idea that floats around a lot, maybe I read too much into your "Neither seem to be under very active development" combined with "(re)implementing" as the alternative.

I guess I'd ask about your requirements and go from there: do you need a full SSA IR or a Wasm AST? That's the top-level choice; Waffle is the former and all the others are the latter (Binaryen kind-of has "SSA" as a side-pass / IR subset but it's weird)

view this post on Zulip Ian Davis (Feb 25 2026 at 18:04):

Wasm in Wasm out - that is the first requirement. I would like to use (worst case write) standard optimization passes (dce, directize, heap2local, inlining, optimize_instruction, precompute, etc) plus some custom analysis/transforms. Debug info and component support would be great, but not deal breakers at the moment. The shape of the IR I'm less worried about, but can create issues.

I wish I'd saved my notes, but I tried using walrus to write passes as a prototype and had to write a stack simulator due to its IR. I implemented coalesce locals, const_drop_elimination, copy_propagation, dce, dead_store_elimination, and a poor sccp. The sccp was hampered by difficulty tracking the stack and having to walk the tree IIRC.

view this post on Zulip Chris Fallin (Feb 25 2026 at 18:06):

yep, those are the kinds of issues that led me to build waffle -- having SSA makes all of the usual optimizations much simpler to write

view this post on Zulip Chris Fallin (Feb 25 2026 at 18:07):

it has basic DCE, GVN, and some cprop, but I'd happily welcome more passes if you end up going that way

view this post on Zulip evilg (Feb 26 2026 at 22:08):

Hi! I'm the maintainer of wirm, which is a transformation library that works on either Wasm modules or components. You can use the library to do Wasm instrumentation (inject into an already-existing Wasm module/component) or to generate components/modules from scratch. This is done all through transformations on the IR. There are also component/module iterators you can use to simply iterate over functions in the IR, or you can use visitors on Wasm components to help perform analyses.

I assume what you mean about the stack simulator is basically an abstract interpreter? Unfortunately, that's not a feature of the library right now, but I'd like to add it in some future release. I currently use the library in several projects (whamm, splicer) and having an abstract interpreter built in to wirm would to reason about the stack at arbitrary program points a lot.

If you have more questions, have new features you need or there are issues with using the library, feel free to reach out!

view this post on Zulip Ian Davis (Feb 27 2026 at 02:34):

From what I've gathered, waffle's SSA + CFG + block-parameters IR feels architecturally the correct design for optimization passes, and was built for an earlier version of WebAssembly that doesn't include the proposal evolution. Wirm has the most complete WASM proposal coverage; however, it is architecturally not ideal for optimization because it stores raw instruction sequences without SSA, CFG, or data-flow analysis capability. Walrus falls into the same category as wirm; its typed ID system and debug-info preservation are really nice, and it is missing component and full gc support.

Thank you all for your help.


Last updated: Mar 23 2026 at 16:19 UTC