halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.91k stars 1.07k forks source link

DWARF version #8394

Open bpervan opened 3 months ago

bpervan commented 3 months ago

Hi,

I'm not sure if I'm getting everything correctly, so I'm going to put it plain and simple:

is it possible to force a specific DWARF version when cross-compiling Halide kernel? As far as I can see, it is possible to set Halide::Target::Debug feature but this defaults to DWARF v5 (at least for the Halide versions 16 and up).

The issue is that on the other side of the chain, I'm stuck with a customized toolchain based on GCC 7 which supports DWARF up to v4. When building the final executable (linking to the cross-precompiled .o library), the linker basically complains with:

.../v1.0.16-pulp-riscv-gcc-ubuntu-18/bin/../lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/bin/ld: Dwarf Error: found dwarf version '5', this reader only handles version 2, 3 and 4 information."

Or to rephrase: To which version of Halide do I have to revert to get debug symbols emitted in compliance with DWARF v4?

abadams commented 3 months ago

The -debug target flag does three things:

1) Modifies the pipeline to print information about the args on entry 2) Adds dwarf information to those parts of the runtime written in c++ 3) Modifies the behavior of the GPU runtime modules to print extra things and add additional synchronization

Note that the -debug target flag will never give you dwarf info for the compiled pipeline. We don't have sensible source locations, unfortunately, due to being an embedded DSL.

If you just want 1, you can just compile the pipeline with -debug and -no_runtime, and link it to a standalone non-debug runtime.

If you want 1, 2, and 3, then you'll need to mess with the Halide build files to add "-gdwarf-4" everywhere -DDEBUG_RUNTIME is set and rebuild libHalide.