authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-04-18 18:57:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-18 21:29:20-07:00
loga1aa55ebe52636f28335fd7ab30321fc52f48775
treeffcd11295f9865acc27e0b7f1572318885ed0260
parent0e394cf922fc84e45e70c0b4a183c9c8b8f079fb

compilation: fix generating coff debug info on -gnu

The issue with just passing `-gcodeview` is that it's not part of the `OPT_g_Group` in `clang/Driver/Options.td`, so it doesn't trigger debug info to be generated. Passing only `-g` is sufficient on MSVC, as there is logic in `Clang.cpp` which enables codeview if that is the default for the toolchain. Since the default for -gnu is not codeview, we do pass `-gcodeview` in that case.

1 files changed, 5 insertions(+), 1 deletions(-)

src/Compilation.zig+5-1
......@@ -4483,7 +4483,11 @@ pub fn addCCArgs(
44834483
44844484 if (!comp.bin_file.options.strip) {
44854485 switch (target.ofmt) {
4486 .coff => try argv.append("-gcodeview"),
4486 .coff => {
4487 // -g is required here because -gcodeview doesn't trigger debug info
4488 // generation, it only changes the type of information generated.
4489 try argv.appendSlice(&.{ "-g", "-gcodeview" });
4490 },
44874491 .elf, .macho => try argv.append("-gdwarf-4"),
44884492 else => try argv.append("-g"),
44894493 }