Skip to content

Commit

Permalink
Debug: Replace Module.dwarf_format with std.builtin.debug_format
Browse files Browse the repository at this point in the history
…for enhanced flexibility
  • Loading branch information
Doekin committed Jan 7, 2025
1 parent 1e0ddc8 commit 39888fb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/std/Build/Module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import_table: std.StringArrayHashMapUnmanaged(*Module),

resolved_target: ?std.Build.ResolvedTarget = null,
optimize: ?std.builtin.OptimizeMode = null,
dwarf_format: ?std.dwarf.Format,
debug_format: ?std.builtin.DebugFormat,

c_macros: std.ArrayListUnmanaged([]const u8),
include_dirs: std.ArrayListUnmanaged(IncludeDir),
Expand Down Expand Up @@ -219,7 +219,7 @@ pub const CreateOptions = struct {
single_threaded: ?bool = null,
strip: ?bool = null,
unwind_tables: ?std.builtin.UnwindTables = null,
dwarf_format: ?std.dwarf.Format = null,
debug_format: ?std.builtin.DebugFormat = null,
code_model: std.builtin.CodeModel = .default,
stack_protector: ?bool = null,
stack_check: ?bool = null,
Expand Down Expand Up @@ -259,7 +259,7 @@ pub fn init(
.optimize = options.optimize,
.link_libc = options.link_libc,
.link_libcpp = options.link_libcpp,
.dwarf_format = options.dwarf_format,
.debug_format = options.debug_format,
.c_macros = .{},
.include_dirs = .{},
.lib_paths = .{},
Expand Down Expand Up @@ -525,11 +525,17 @@ pub fn appendZigProcessFlags(
try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");

if (m.dwarf_format) |dwarf_format| {
try zig_args.append(switch (dwarf_format) {
.@"32" => "-gdwarf32",
.@"64" => "-gdwarf64",
});
if (m.debug_format) |debug_format| {
switch (debug_format) {
.strip => {},
.dwarf => |fmt| switch (fmt) {
.@"32" => try zig_args.append("-gdwarf32"),
.@"64" => try zig_args.append("-gdwarf64"),
},
.code_view => {
try zig_args.append("-gcodeview");
},
}
}

if (m.unwind_tables) |unwind_tables| {
Expand Down

0 comments on commit 39888fb

Please sign in to comment.