authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-02 18:08:41-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 00:27:08-08:00
logca5c5ade5f6ba73430ae9dd107c774d31382ad02
tree7d6d2053edd3bc124c14dda095ff3871ab5df374
parentbf74827ddb34e36906c5f7615f8b488d90e16be4

std.Options: work around not lazy enough compiler


2 files changed, 9 insertions(+), 3 deletions(-)

lib/std/debug/ElfFile.zig+1-1
...@@ -67,7 +67,7 @@ pub const DebugInfoSearchPaths = struct {...@@ -67,7 +67,7 @@ pub const DebugInfoSearchPaths = struct {
67 };67 };
6868
69 pub fn native(exe_path: []const u8) DebugInfoSearchPaths {69 pub fn native(exe_path: []const u8) DebugInfoSearchPaths {
70 if (std.options.elf_debug_info_search_paths) |f| return f(exe_path);70 if (std.Options.elf_debug_info_search_paths) |f| return f(exe_path);
71 if (std.Options.debug_threaded_io) |t| return .{71 if (std.Options.debug_threaded_io) |t| return .{
72 .debuginfod_client = p: {72 .debuginfod_client = p: {
73 if (t.environString("DEBUGINFOD_CACHE_PATH")) |p| {73 if (t.environString("DEBUGINFOD_CACHE_PATH")) |p| {
lib/std/std.zig+8-2
...@@ -173,15 +173,21 @@ pub const Options = struct {...@@ -173,15 +173,21 @@ pub const Options = struct {
173 /// stack traces will just print an error to the relevant `Io.Writer` and return.173 /// stack traces will just print an error to the relevant `Io.Writer` and return.
174 allow_stack_tracing: bool = !@import("builtin").strip_debug_info,174 allow_stack_tracing: bool = !@import("builtin").strip_debug_info,
175175
176 elf_debug_info_search_paths: ?fn (exe_path: []const u8) switch (@import("builtin").object_format) {176 /// TODO This is a separate decl instead of a field as a workaround around
177 /// compilation errors due to zig not being lazy enough.
178 pub const elf_debug_info_search_paths: ?fn (exe_path: []const u8) switch (@import("builtin").object_format) {
177 .elf => debug.ElfFile.DebugInfoSearchPaths,179 .elf => debug.ElfFile.DebugInfoSearchPaths,
178 else => void,180 else => void,
179 } = null,181 } = if (@hasDecl(root, "std_options_elf_debug_info_search_paths"))
182 root.std_options_elf_debug_info_search_paths
183 else
184 null;
180185
181 pub const debug_threaded_io: ?*Io.Threaded = if (@hasDecl(root, "std_options_debug_threaded_io"))186 pub const debug_threaded_io: ?*Io.Threaded = if (@hasDecl(root, "std_options_debug_threaded_io"))
182 root.std_options_debug_threaded_io187 root.std_options_debug_threaded_io
183 else188 else
184 Io.Threaded.global_single_threaded;189 Io.Threaded.global_single_threaded;
190
185 /// The `Io` instance that `std.debug` uses for `std.debug.print`,191 /// The `Io` instance that `std.debug` uses for `std.debug.print`,
186 /// capturing stack traces, loading debug info, finding the executable's192 /// capturing stack traces, loading debug info, finding the executable's
187 /// own path, and environment variables that affect terminal mode193 /// own path, and environment variables that affect terminal mode