std.Options: work around not lazy enough compiler

This commit is contained in:
Andrew Kelley 2026-01-02 18:08:41 -08:00
parent bf74827ddb
commit ca5c5ade5f
2 changed files with 9 additions and 3 deletions

View file

@ -67,7 +67,7 @@ pub const DebugInfoSearchPaths = struct {
};
pub fn native(exe_path: []const u8) DebugInfoSearchPaths {
if (std.options.elf_debug_info_search_paths) |f| return f(exe_path);
if (std.Options.elf_debug_info_search_paths) |f| return f(exe_path);
if (std.Options.debug_threaded_io) |t| return .{
.debuginfod_client = p: {
if (t.environString("DEBUGINFOD_CACHE_PATH")) |p| {

View file

@ -173,15 +173,21 @@ pub const Options = struct {
/// stack traces will just print an error to the relevant `Io.Writer` and return.
allow_stack_tracing: bool = !@import("builtin").strip_debug_info,
elf_debug_info_search_paths: ?fn (exe_path: []const u8) switch (@import("builtin").object_format) {
/// TODO This is a separate decl instead of a field as a workaround around
/// compilation errors due to zig not being lazy enough.
pub const elf_debug_info_search_paths: ?fn (exe_path: []const u8) switch (@import("builtin").object_format) {
.elf => debug.ElfFile.DebugInfoSearchPaths,
else => void,
} = null,
} = if (@hasDecl(root, "std_options_elf_debug_info_search_paths"))
root.std_options_elf_debug_info_search_paths
else
null;
pub const debug_threaded_io: ?*Io.Threaded = if (@hasDecl(root, "std_options_debug_threaded_io"))
root.std_options_debug_threaded_io
else
Io.Threaded.global_single_threaded;
/// The `Io` instance that `std.debug` uses for `std.debug.print`,
/// capturing stack traces, loading debug info, finding the executable's
/// own path, and environment variables that affect terminal mode