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 {
340340 }
341341 }
342342
343 if (webui_listen != null and watch) fatal(
344 \\the build system does not yet support combining '--webui' and '--watch'; consider omitting '--watch' in favour of the web UI "Rebuild" button
345 , .{});
343 if (webui_listen != null) {
344 if (watch) fatal("using '--webui' and '--watch' together is not yet supported; consider omitting '--watch' in favour of the web UI \"Rebuild\" button", .{});
345 if (builtin.single_threaded) fatal("'--webui' is not yet supported on single-threaded hosts", .{});
346 }
346347
347348 const stderr: std.fs.File = .stderr();
348349 const ttyconf = get_tty_conf(color, stderr);
......@@ -449,16 +450,19 @@ pub fn main() !void {
449450 try run.thread_pool.init(thread_pool_options);
450451 defer run.thread_pool.deinit();
451452
452 run.web_server = if (webui_listen) |listen_address| .init(.{
453 .gpa = gpa,
454 .thread_pool = &run.thread_pool,
455 .graph = &graph,
456 .all_steps = run.step_stack.keys(),
457 .ttyconf = run.ttyconf,
458 .root_prog_node = main_progress_node,
459 .watch = watch,
460 .listen_address = listen_address,
461 }) else null;
453 run.web_server = if (webui_listen) |listen_address| ws: {
454 if (builtin.single_threaded) unreachable; // `fatal` above
455 break :ws .init(.{
456 .gpa = gpa,
457 .thread_pool = &run.thread_pool,
458 .graph = &graph,
459 .all_steps = run.step_stack.keys(),
460 .ttyconf = run.ttyconf,
461 .root_prog_node = main_progress_node,
462 .watch = watch,
463 .listen_address = listen_address,
464 });
465 } else null;
462466
463467 if (run.web_server) |*ws| {
464468 ws.start() catch |err| fatal("failed to start web server: {s}", .{@errorName(err)});
......@@ -562,7 +566,7 @@ const Run = struct {
562566 max_rss_mutex: std.Thread.Mutex,
563567 skip_oom_steps: bool,
564568 watch: bool,
565 web_server: ?WebServer,
569 web_server: if (!builtin.single_threaded) ?WebServer else ?noreturn,
566570 /// Allocated into `gpa`.
567571 memory_blocked_steps: std.ArrayListUnmanaged(*Step),
568572 /// Allocated into `gpa`.
lib/std/Build/WebServer.zig+3-5
......@@ -59,11 +59,9 @@ pub const Options = struct {
5959 listen_address: std.net.Address,
6060};
6161pub fn init(opts: Options) WebServer {
62 if (builtin.single_threaded) {
63 // The upcoming `std.Io` interface should allow us to use `Io.async` and `Io.concurrent`
64 // instead of threads, so that the web server can function in single-threaded builds.
65 std.process.fatal("--webui not yet implemented for single-threaded builds", .{});
66 }
62 // 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 comptime assert(!builtin.single_threaded);
6765
6866 const all_steps = opts.all_steps;
6967