authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-09 17:17:38-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-11 00:27:06+01:00
log68403267117bf5cf73e0f747887f2834336ae4a2
tree269fe534f6f3839922bb1224fc2b8f8e0fc340c8
parent7369008d8ca94fe48d9408d03851a4a17f7e1b73

compiler: override debug_io in release + evented mode

to avoid a dependency on std.Io.Threaded in such case

2 files changed, 19 insertions(+), 6 deletions(-)

lib/std/debug/ElfFile.zig+5-1
......@@ -86,7 +86,11 @@ pub const DebugInfoSearchPaths = struct {
8686 },
8787 .exe_dir = std.fs.path.dirname(exe_path) orelse ".",
8888 };
89 @compileError("std.Options.elf_debug_info_search_paths must be provided");
89 return .{
90 .debuginfod_client = null,
91 .global_debug = &.{"/usr/lib/debug"},
92 .exe_dir = std.fs.path.dirname(exe_path) orelse ".",
93 };
9094 }
9195};
9296
src/main.zig+14-5
......@@ -51,6 +51,17 @@ pub const std_options: std.Options = .{
5151 },
5252};
5353pub const std_options_cwd = if (native_os == .wasi) wasi_cwd else null;
54pub const std_options_debug_threaded_io: ?*Io.Threaded = switch (build_options.io_mode) {
55 .threaded => &io_impl,
56 .evented => switch (builtin.mode) {
57 .Debug => Io.Threaded.global_single_threaded,
58 .ReleaseFast, .ReleaseSmall, .ReleaseSafe => null,
59 },
60};
61pub const std_options_debug_io: Io = switch (build_options.io_mode) {
62 .threaded => io_impl.ioBasic(),
63 .evented => io_impl.io(),
64};
5465
5566pub const debug = struct {
5667 pub fn printCrashContext(terminal: Io.Terminal) void {
......@@ -189,7 +200,6 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
189200 var root_allocator: RootAllocator = .init;
190201 defer _ = root_allocator.deinit();
191202 const root_gpa = root_allocator.allocator();
192 var io_impl: IoImpl = undefined;
193203 switch (build_options.io_mode) {
194204 .threaded => io_impl = .init(root_gpa, .{
195205 .stack_size = thread_stack_size,
......@@ -205,7 +215,6 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
205215 }),
206216 }
207217 defer io_impl.deinit();
208 io_impl_ptr = &io_impl;
209218 const io = io_impl.io();
210219 const gpa = switch (build_options.io_mode) {
211220 .threaded => root_gpa,
......@@ -7815,7 +7824,7 @@ const IoImpl = switch (build_options.io_mode) {
78157824 .threaded => Io.Threaded,
78167825 .evented => Io.Evented,
78177826};
7818var io_impl_ptr: *IoImpl = undefined;
7827var io_impl: IoImpl = undefined;
78197828fn setThreadLimit(arena: std.mem.Allocator, n: usize) Allocator.Error!void {
78207829 switch (build_options.io_mode) {
78217830 .threaded => {
......@@ -7824,8 +7833,8 @@ fn setThreadLimit(arena: std.mem.Allocator, n: usize) Allocator.Error!void {
78247833 // linker can run concurrently, so we need to set both the async *and* the
78257834 // concurrency limit.
78267835 const limit: Io.Limit = .limited(n - 1);
7827 io_impl_ptr.setAsyncLimit(limit);
7828 io_impl_ptr.concurrent_limit = limit;
7836 io_impl.setAsyncLimit(limit);
7837 io_impl.concurrent_limit = limit;
78297838 },
78307839 .evented => {},
78317840 }