Skip to content

Commit

Permalink
windows-gnu: Add support for -gcodeview flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Doekin committed Jan 7, 2025
1 parent a49834a commit e69c4ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/std/Build/Step/Compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,11 @@ pub fn producesPdbFile(compile: *Compile) bool {
.windows, .uefi => {},
else => return false,
}
if (target.abi.isGnu()) return false;
if (compile.root_module.debug_format) |fmt| {
if (fmt != .code_view) return false;
} else {
if (target.abi.isGnu()) return false;
}
if (target.ofmt == .c) return false;
if (compile.root_module.strip == true or
(compile.root_module.strip == null and compile.root_module.optimize == .ReleaseSmall))
Expand Down
2 changes: 2 additions & 0 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6321,6 +6321,7 @@ fn buildOutputFromZig(
.emit_bin = true,
.root_optimize_mode = optimize_mode,
.root_strip = strip,
.debug_format = comp.config.debug_format,
.link_libc = comp.config.link_libc,
});

Expand Down Expand Up @@ -6457,6 +6458,7 @@ pub fn build_crt_file(
.emit_bin = true,
.root_optimize_mode = comp.compilerRtOptMode(),
.root_strip = comp.compilerRtStrip(),
.debug_format = comp.config.debug_format,
.link_libc = false,
.lto = switch (output_mode) {
.Lib => comp.config.lto,
Expand Down
1 change: 0 additions & 1 deletion src/Compilation/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pub const CFrontend = enum { clang, aro };

pub const LtoMode = enum { none, full, thin };


pub const Options = struct {
output_mode: std.builtin.OutputMode,
resolved_target: Module.ResolvedTarget,
Expand Down
9 changes: 8 additions & 1 deletion src/clang_options_data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4148,7 +4148,14 @@ flagpd1("g3"),
.pd2 = false,
.psl = false,
},
flagpd1("gcodeview"),
.{
.name = "gcodeview",
.syntax = .flag,
.zig_equivalent = .gcodeview,
.pd1 = true,
.pd2 = false,
.psl = false,
},
flagpd1("gcodeview-command-line"),
flagpd1("gcodeview-ghash"),
flagpd1("gcolumn-info"),
Expand Down
7 changes: 7 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,8 @@ fn buildOutputType(
create_module.opts.debug_format = .{ .dwarf = .@"32" };
} else if (mem.eql(u8, arg, "-gdwarf64")) {
create_module.opts.debug_format = .{ .dwarf = .@"64" };
} else if (mem.eql(u8, arg, "-gcodeview")) {
create_module.opts.debug_format = .code_view;
} else if (mem.eql(u8, arg, "-fformatted-panics")) {
// Remove this after 0.15.0 is tagged.
warn("-fformatted-panics is deprecated and does nothing", .{});
Expand Down Expand Up @@ -2181,6 +2183,10 @@ fn buildOutputType(
try cc_argv.appendSlice(arena, it.other_args);
}
},
.gcodeview => {
mod_opts.strip = false;
create_module.opts.debug_format = .code_view;
},
.gdwarf32 => {
mod_opts.strip = false;
create_module.opts.debug_format = .{ .dwarf = .@"32" };
Expand Down Expand Up @@ -5797,6 +5803,7 @@ pub const ClangArgIterator = struct {
asm_only,
optimize,
debug,
gcodeview,
gdwarf32,
gdwarf64,
sanitize,
Expand Down
4 changes: 4 additions & 0 deletions tools/update_clang_options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ const known_options = [_]KnownOpt{
.name = "debug",
.ident = "debug",
},
.{
.name = "gcodeview",
.ident = "gcodeview",
},
.{
.name = "gdwarf32",
.ident = "gdwarf32",
Expand Down

0 comments on commit e69c4ad

Please sign in to comment.