Determine wasm compatibility

A while back when I first dipped my toes into wasm, I found some tips on how to reduce the size of the wasm blobs. It involved running wasm-strip, wasm-snip and wasm-opt. I wrote a script that would automatically run all of these, and it not only worked, it worked surprisingly well -- the blob was pretty drastically reduced in size.

I recently started experimenting with wasm again, and while I have upgraded Rust toolchains and wasm-snip (because I upgrade all my cargo-built packages regularly), the other wasm tools remained the same.

When I ran my old script wasm-opt and wasm-strip complained about errors in the wasm blob. I figured it was due to upgraded Rust toolchains, and old tools, so I upgraded wabt and binaryen, but not only did it still print errors, I got other (and more) errors. There's clearly some incompatibility between tools and the wasm blob Rust is generating.

I did read the proverbial warning label on the box; the page that recommended wasm-opt et al was very explicit about it being experimental tools and one shouldn't expect them to work at all or (even worse) not to introduce subtle bugs.

Ignoring the "use at your own risk" warning labels for a moment .. Is there some way to determine what versions of Rust and the wasm tools are compatible? Like some revision header field in the blob that can be compared to some constant in the tools' headers? Or is this just a case of moving targets [and it'll stabilize with time]?

Surprisingly (at least to me), this may have been an issue in wasm-bindgen. At least, that's what I got from reading some Issues on GitHub. I updated from 0.2.95 to 0.2.97, and the problems went away.

Edit: Strike that. Problem was not fixed.

Maybe this is caused by

1 Like

So it turns out this was part of the problem. Apparently I just bad-lucked and chose to dip my toe into wasm just as there were a few bumps in the road.

A good place to start reading for those who want to know more is in wasm-pack issue #1441.