compiler: override debug_io in release + evented mode

to avoid a dependency on std.Io.Threaded in such case
This commit is contained in:
Andrew Kelley
2026-02-09 17:17:38 -08:00
parent 7369008d8c
commit 6840326711
2 changed files with 19 additions and 6 deletions
+5 -1
View File
@@ -86,7 +86,11 @@ pub const DebugInfoSearchPaths = struct {
},
.exe_dir = std.fs.path.dirname(exe_path) orelse ".",
};
@compileError("std.Options.elf_debug_info_search_paths must be provided");
return .{
.debuginfod_client = null,
.global_debug = &.{"/usr/lib/debug"},
.exe_dir = std.fs.path.dirname(exe_path) orelse ".",
};
}
};
+14 -5
View File
@@ -51,6 +51,17 @@ pub const std_options: std.Options = .{
},
};
pub const std_options_cwd = if (native_os == .wasi) wasi_cwd else null;
pub const std_options_debug_threaded_io: ?*Io.Threaded = switch (build_options.io_mode) {
.threaded => &io_impl,
.evented => switch (builtin.mode) {
.Debug => Io.Threaded.global_single_threaded,
.ReleaseFast, .ReleaseSmall, .ReleaseSafe => null,
},
};
pub const std_options_debug_io: Io = switch (build_options.io_mode) {
.threaded => io_impl.ioBasic(),
.evented => io_impl.io(),
};
pub const debug = struct {
pub fn printCrashContext(terminal: Io.Terminal) void {
@@ -189,7 +200,6 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
var root_allocator: RootAllocator = .init;
defer _ = root_allocator.deinit();
const root_gpa = root_allocator.allocator();
var io_impl: IoImpl = undefined;
switch (build_options.io_mode) {
.threaded => io_impl = .init(root_gpa, .{
.stack_size = thread_stack_size,
@@ -205,7 +215,6 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
}),
}
defer io_impl.deinit();
io_impl_ptr = &io_impl;
const io = io_impl.io();
const gpa = switch (build_options.io_mode) {
.threaded => root_gpa,
@@ -7815,7 +7824,7 @@ const IoImpl = switch (build_options.io_mode) {
.threaded => Io.Threaded,
.evented => Io.Evented,
};
var io_impl_ptr: *IoImpl = undefined;
var io_impl: IoImpl = undefined;
fn setThreadLimit(arena: std.mem.Allocator, n: usize) Allocator.Error!void {
switch (build_options.io_mode) {
.threaded => {
@@ -7824,8 +7833,8 @@ fn setThreadLimit(arena: std.mem.Allocator, n: usize) Allocator.Error!void {
// linker can run concurrently, so we need to set both the async *and* the
// concurrency limit.
const limit: Io.Limit = .limited(n - 1);
io_impl_ptr.setAsyncLimit(limit);
io_impl_ptr.concurrent_limit = limit;
io_impl.setAsyncLimit(limit);
io_impl.concurrent_limit = limit;
},
.evented => {},
}