Skip to content

Commit a31b449

Browse files
committed
make LLVM and Clang emit DWARF 4 instead of 5
This reverts 6d679eb and additionally changes the command line parameters passed to Clang to match. Clang 14 defaults to DWARFv5 which is an interesting choice. v5 has been out for 5 years and yet Valgrind does not support it, and apparently neither does either GDB or LLD, I haven't determined which, but I wasn't able to use GDB to debug my LLVM-emitted dwarf 5 zig code that was linked with LLD. A couple years ago when I was working on the self-hosted ELF linker, I emitted DWARFv5 but then downgraded to v4 when I realized that third party tools were stuck in the past. Years later, they still are. Hopefully, Clang 14's bold move will inspire third party tools to get their shit together, however, in the meantime, everything's broken, so we're passing `-gdwarf-4` to clang and instructing LLVM to emit DWARFv4. Note that Zig's std.debug code *does* support DWARFv5 already as of a previous commit that I made today.
1 parent 6072226 commit a31b449

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Compilation.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -4085,10 +4085,10 @@ pub fn addCCArgs(
40854085
}
40864086

40874087
if (!comp.bin_file.options.strip) {
4088-
try argv.append("-g");
40894088
switch (target.ofmt) {
40904089
.coff => try argv.append("-gcodeview"),
4091-
else => {},
4090+
.elf, .macho => try argv.append("-gdwarf-4"),
4091+
else => try argv.append("-g"),
40924092
}
40934093
}
40944094

src/zig_llvm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ void ZigLLVMGetNativeTarget(ZigLLVM_ArchType *arch_type,
11301130

11311131
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {
11321132
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
1133-
unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 5);
1133+
unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4);
11341134
}
11351135

11361136
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {

0 commit comments

Comments
 (0)