Skip to content

Commit

Permalink
Debug: Move Compilation.Config.DebugFormat to std.builtin for bro…
Browse files Browse the repository at this point in the history
…ader usage
  • Loading branch information
Doekin committed Jan 7, 2025
1 parent 67afb86 commit eef344f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 8 additions & 0 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ pub const OptimizeMode = enum {
/// Deprecated; use OptimizeMode.
pub const Mode = OptimizeMode;

/// DebugFormat specifies which type of debug information to generate:
pub const DebugFormat = union(enum) {
/// No debug information.
strip,
dwarf: std.dwarf.Format,
code_view,
};

/// The calling convention of a function defines how arguments and return values are passed, as well
/// as any other requirements which callers and callees must respect, such as register preservation
/// and stack alignment.
Expand Down
6 changes: 3 additions & 3 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -883,13 +883,13 @@ pub const cache_helpers = struct {
addEmitLoc(hh, optional_emit_loc orelse return);
}

pub fn addOptionalDebugFormat(hh: *Cache.HashHelper, x: ?Config.DebugFormat) void {
pub fn addOptionalDebugFormat(hh: *Cache.HashHelper, x: ?std.builtin.DebugFormat) void {
hh.add(x != null);
addDebugFormat(hh, x orelse return);
}

pub fn addDebugFormat(hh: *Cache.HashHelper, x: Config.DebugFormat) void {
const tag: @typeInfo(Config.DebugFormat).@"union".tag_type.? = x;
pub fn addDebugFormat(hh: *Cache.HashHelper, x: std.builtin.DebugFormat) void {
const tag: @typeInfo(std.builtin.DebugFormat).@"union".tag_type.? = x;
hh.add(tag);
switch (x) {
.strip, .code_view => {},
Expand Down
11 changes: 3 additions & 8 deletions src/Compilation/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import_memory: bool,
export_memory: bool,
shared_memory: bool,
is_test: bool,
debug_format: DebugFormat,
debug_format: std.builtin.DebugFormat,
root_strip: bool,
root_error_tracing: bool,
dll_export_fns: bool,
Expand All @@ -67,11 +67,6 @@ pub const CFrontend = enum { clang, aro };

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

pub const DebugFormat = union(enum) {
strip,
dwarf: std.dwarf.Format,
code_view,
};

pub const Options = struct {
output_mode: std.builtin.OutputMode,
Expand Down Expand Up @@ -109,7 +104,7 @@ pub const Options = struct {
import_memory: ?bool = null,
export_memory: ?bool = null,
shared_memory: ?bool = null,
debug_format: ?DebugFormat = null,
debug_format: ?std.builtin.DebugFormat = null,
dll_export_fns: ?bool = null,
rdynamic: ?bool = null,
san_cov_trace_pc_guard: bool = false,
Expand Down Expand Up @@ -441,7 +436,7 @@ pub fn resolve(options: Options) ResolveError!Config {
break :b false;
};

const debug_format: DebugFormat = b: {
const debug_format: std.builtin.DebugFormat = b: {
if (root_strip and !options.any_non_stripped) break :b .strip;
if (options.debug_format) |x| break :b x;
break :b switch (target.ofmt) {
Expand Down

0 comments on commit eef344f

Please sign in to comment.