authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-08-13 13:01:20+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-08-13 23:50:57+01:00
loge304a478c0654e8a6c506eedbd5556f99ac79d6c
tree0d4e414134e438b156b67d62ae5b87a9b6e2f287
parent4f639ff8805b33fa6c75416eddfb205e3a04e09a

build runner: fix single-threaded build

Resolves: #24723

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

lib/compiler/build_runner.zig+18-14
...@@ -340,9 +340,10 @@ pub fn main() !void {...@@ -340,9 +340,10 @@ pub fn main() !void {
340 }340 }
341 }341 }
342342
343 if (webui_listen != null and watch) fatal(343 if (webui_listen != null) {
344 \\the build system does not yet support combining '--webui' and '--watch'; consider omitting '--watch' in favour of the web UI "Rebuild" button344 if (watch) fatal("using '--webui' and '--watch' together is not yet supported; consider omitting '--watch' in favour of the web UI \"Rebuild\" button", .{});
345 , .{});345 if (builtin.single_threaded) fatal("'--webui' is not yet supported on single-threaded hosts", .{});
346 }
346347
347 const stderr: std.fs.File = .stderr();348 const stderr: std.fs.File = .stderr();
348 const ttyconf = get_tty_conf(color, stderr);349 const ttyconf = get_tty_conf(color, stderr);
...@@ -449,16 +450,19 @@ pub fn main() !void {...@@ -449,16 +450,19 @@ pub fn main() !void {
449 try run.thread_pool.init(thread_pool_options);450 try run.thread_pool.init(thread_pool_options);
450 defer run.thread_pool.deinit();451 defer run.thread_pool.deinit();
451452
452 run.web_server = if (webui_listen) |listen_address| .init(.{453 run.web_server = if (webui_listen) |listen_address| ws: {
453 .gpa = gpa,454 if (builtin.single_threaded) unreachable; // `fatal` above
454 .thread_pool = &run.thread_pool,455 break :ws .init(.{
455 .graph = &graph,456 .gpa = gpa,
456 .all_steps = run.step_stack.keys(),457 .thread_pool = &run.thread_pool,
457 .ttyconf = run.ttyconf,458 .graph = &graph,
458 .root_prog_node = main_progress_node,459 .all_steps = run.step_stack.keys(),
459 .watch = watch,460 .ttyconf = run.ttyconf,
460 .listen_address = listen_address,461 .root_prog_node = main_progress_node,
461 }) else null;462 .watch = watch,
463 .listen_address = listen_address,
464 });
465 } else null;
462466
463 if (run.web_server) |*ws| {467 if (run.web_server) |*ws| {
464 ws.start() catch |err| fatal("failed to start web server: {s}", .{@errorName(err)});468 ws.start() catch |err| fatal("failed to start web server: {s}", .{@errorName(err)});
...@@ -562,7 +566,7 @@ const Run = struct {...@@ -562,7 +566,7 @@ const Run = struct {
562 max_rss_mutex: std.Thread.Mutex,566 max_rss_mutex: std.Thread.Mutex,
563 skip_oom_steps: bool,567 skip_oom_steps: bool,
564 watch: bool,568 watch: bool,
565 web_server: ?WebServer,569 web_server: if (!builtin.single_threaded) ?WebServer else ?noreturn,
566 /// Allocated into `gpa`.570 /// Allocated into `gpa`.
567 memory_blocked_steps: std.ArrayListUnmanaged(*Step),571 memory_blocked_steps: std.ArrayListUnmanaged(*Step),
568 /// Allocated into `gpa`.572 /// Allocated into `gpa`.
lib/std/Build/WebServer.zig+3-5
...@@ -59,11 +59,9 @@ pub const Options = struct {...@@ -59,11 +59,9 @@ pub const Options = struct {
59 listen_address: std.net.Address,59 listen_address: std.net.Address,
60};60};
61pub fn init(opts: Options) WebServer {61pub fn init(opts: Options) WebServer {
62 if (builtin.single_threaded) {62 // The upcoming `std.Io` interface should allow us to use `Io.async` and `Io.concurrent`
63 // The upcoming `std.Io` interface should allow us to use `Io.async` and `Io.concurrent`63 // instead of threads, so that the web server can function in single-threaded builds.
64 // instead of threads, so that the web server can function in single-threaded builds.64 comptime assert(!builtin.single_threaded);
65 std.process.fatal("--webui not yet implemented for single-threaded builds", .{});
66 }
6765
68 const all_steps = opts.all_steps;66 const all_steps = opts.all_steps;
6967