walrus icon indicating copy to clipboard operation
walrus copied to clipboard

Produces code that fails wasm-opt

Open jpochyla opened this issue 1 year ago • 5 comments

Describe the Bug

When the wasm-opt == 116, with -O3 -g flags, is run on Rust crate compiled with the following wasm-bindgen-cli-support == 0.2.89 setup:

Bindgen::new()
            .input_path(...)
            .out_name(...)
            .debug(false)
            .keep_debug(true)
            .web(true)?
            .weak_refs(true)
            .generate(...)?;

...it crashes with the following error:

$ wasm-opt-e61e7b9e41e11ab4/wasm-opt foo.wasm -o foo.wasm -O3 -g
compile unit size was incorrect (this may be an unsupported version of DWARF)
UNREACHABLE executed at /Users/runner/work/binaryen/binaryen/third_party/llvm-project/DWARFEmitter.cpp:201!

I think it's likely that the latest DWARF changes broke this, as it used to work before (or at least result in a working binary.)

Is there anything I can do to help?

jpochyla avatar Jan 03 '24 10:01 jpochyla

Can you confirm exactly which version of Walrus is being used here, and verify it is the latest version?

Once we've confirmed that getting a good sample output / replication would help to start investigating this further.

guybedford avatar Jan 03 '24 15:01 guybedford

Sorry about the delay :| The version is indeed the latest:

$ cargo tree -i walrus
walrus v0.20.3
├── wasm-bindgen-cli-support v0.2.92
...

Unfortunately the codebase is quite large (and not open), would you have any ideas about finding the culprit? For example, is it possible to programmatically remove parts of the DWARF from the binary to find the offending module? Do you have any ideas about what the error might mean?

Thanks!

jpochyla avatar Mar 04 '24 19:03 jpochyla

It sounds like this is a DWARF encoding issue - so disabling the DWARF output should fix the error.

guybedford avatar Mar 04 '24 20:03 guybedford

Oh it does fix the error, sorry I should've made that clear. But i'd like to keep the DWARF output :)

jpochyla avatar Mar 05 '24 09:03 jpochyla

Yeah I can confirm this is a bug. I'm only really able to manage releases of this project myself, and not do a lot of maintenance work at this point. Will leave this open.

guybedford avatar Mar 05 '24 15:03 guybedford