Hi @Alex Crichton and @fitzgen (he/him),
Here at Dfinity we were using the parity-wasm
crate to instrument wasm modules, but it's now been deprecated. We started building a replacement using wasmparser
and wasm-encode
, but then realized we were essentially re-implementing code that you already have in the wasm-mutate
crate (mainly the info
and translate
modules).
Would you be open to PR's that expose those modules so that they can be used as a replacement for parity-wasm
?
wasm-mutate
isn't really designed for general purpose Wasm rewrites, it is focused specifically on random mutations for fuzzing
I wouldn't really want to grow its use cases larger than that from a scope and maintainability perspective
I agree that wasm-mutate
probably isn't the best place to expose this, but at the same time I've also found myself frequently translating between wasmparser and wasm-encoder for small passes. I wouldn't be opposed to trying to extract out these bits of wasm-mutate
into a crate somewhere, probably wasm-encoder
for now.
I've historically been hesitant to make wasmparser
a "public dependency" of wasm-encoder
but I think it's reasonable enough to add in the long run
I do think there's possible interesting design work to be had here though, the problem of "I'd like to apply this simple transformation to a wasm module" I don't think is really all that well of a solved problem. Using parity-wasm
was a historical option, wasm-bindgen
uses the largely-unmaintained walrus
crate (which Nick and I originally authored), and nowadays it's not the worst thing in the world to fuse wasmparser
and wasm-encoder
with some macros.
All that to say that I'd love to see a better library and tooling exist here for this purpose. I at least personally have never found a solution that "felt right"
That makes sense. But even if it wasn't perfect, it seems like a lot of projects were using parity-wasm
. So I suspect a crate that combines wasmparser
and wasm-encoder
(or adding a translator to wasm-encoder
) would get a lot of use.
Last updated: Nov 22 2024 at 17:03 UTC