WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.5k stars 745 forks source link

plan to create DWARF section #4026

Open xuxbuptisc opened 3 years ago

xuxbuptisc commented 3 years ago

Hello, as far as I know, binaryen currently only has the ability to modify DWARF section, but not the ability to create DWARF information. Are there plans to provide the ability to create DWARF information? In this case, the binaryen-based compiler can reuse this part of the ability without the need to implement it from scratch.

kripken commented 3 years ago

I'm not aware of current plans to work on this. I'm not sure how much work it would be, but I'd guess not a small amount.

Do you have a compiler that would benefit from it?

xuxbuptisc commented 3 years ago

I'm not aware of current plans to work on this. I'm not sure how much work it would be, but I'd guess not a small amount.

Do you have a compiler that would benefit from it?

I have talked with Assemblyscript maintainers(@MaxGraey), they expect to use the power of binaryen to achieve dwarf debugging capabilities.

MaxGraey commented 3 years ago

I have also seen this request from other participants not associated with AssemblyScript or Grain on the WebAssembly discord server.

I'm well aware of how huge a piece of work this is. So I would just like to know if this is planned at some point in the future or is it out of scope?

kripken commented 3 years ago

It isn't currently planned, but it's also not out of scope. In general it would be good to support the functionality.

If we want to do it, perhaps a different approach than the current one might be needed. The current code is ported from LLVM, and is mostly suitable for updating existing DWARF. Perhaps there is another library that has a nice interface for also creating it from scratch. If we find such a library, it might not be that hard to migrate to it, as the hard part of supporting offsets in Binaryen IR is done, as is finding the things to update in DWARF. And then the work to add DWARF creation might be easier with such a library.

MaxGraey commented 3 years ago

Hmm. Need to inveterate to Libcwd, libdwarf and elfutils

kripken commented 3 years ago

Another possibility might be gimli (that would also require adding Rust integration, but that might be a nice first step in that area).

MaxGraey commented 3 years ago

Yeah, also good option. Rust have cbindgen tool which can create C/C++-Api automatically

MaxGraey commented 3 years ago

DW_OP_WASM_location supports in:

WebAssembly relocations (R_WASM_*) supports in: