`-gdwarf64` does not produce object with 64bit DWARF debug info
Zig Version
0.12.0-dev.3475+71d878ba5
Steps to Reproduce and Observed Behavior
Run the following build command with a minimal zig file
zig build-obj -gdwarf64 -O Debug -target x86_64-linux example.zig
Example.zig:
const std = @import("std");
pub fn main() void {
std.debug.print("example zig\n", .{});
}
Then use objdump to check DWARF info:
objdump --dwarf=info example.o
example.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x25f5d (32-bit)
Version: 4
Abbrev Offset: 0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x1887b): zig 0.12.0
<10> DW_AT_language : 12 (ANSI C99)
<12> DW_AT_name : (indirect string, offset: 0x6753): example
...
It shows 32-bit instead of 64-bit, as seen from another object file built with GCC with -g -gdwarf64:
gcc -g -gdwarf64 -c hello.c
objdump --dwarf=info hello.o
hello.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0xff (64-bit)
Version: 5
Unit Type: DW_UT_compile (1)
Abbrev Offset: 0
Pointer Size: 8
...
Expected Behavior
-gdwarf32 and -gdwarf64 should produce 32-bit and 64-bit DWARF debug info accordingly.
My speculation on this:
Those two options were added in https://github.com/ziglang/zig/commit/d026202a26e56e7e2ea20ca49509fdcf8b937020 , at that time there were no CreateModule struct, and those options get passed directly to Compilation.create.
But now it is stored in create_module.opts, which is resolved into create_module.resolved_options at:
https://github.com/ziglang/zig/blob/a2df84d0ffe3b7bce96f55a5d7063630aac75116/src/Compilation/Config.zig#L424-L435
The code above didn't consider options.debug_format to generate create_module.resolved_options, so the options were not in effect.
@geezmolycos I started a PR to address this issue here: https://github.com/ziglang/zig/pull/19633 I have a question on it, and I was wondering if you could lend some guidance. Thanks!