From fd63f57cd86ebcf1261b10d1a17e62d523e70981 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 26 May 2026 09:50:48 -0700 Subject: [PATCH] build system: update more usize to u64 for maxrss makes the build system compile on 32 bit systems bonus, also fix incorrectly passing advanced debug options to the maker process which doesn't care about them --- lib/compiler/Maker.zig | 4 ++-- lib/compiler/Maker/Step/Run.zig | 4 ++-- lib/compiler/configurer.zig | 2 +- lib/std/Build/Configuration.zig | 4 ++-- lib/std/Io.zig | 7 +++++++ src/main.zig | 2 ++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 07ca3d436352ff001131f7dd79074c5d797ce934..5aaf6e9d13f4255f84323b2d8876065ed094057d 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -38,7 +38,7 @@ steps: []Step, generated_files: []Path, run_args: ?[]const []const u8, -available_rss: usize, +available_rss: u64, max_rss_is_default: bool, max_rss_mutex: Io.Mutex, skip_oom_steps: bool, @@ -740,7 +740,7 @@ fn prepare(maker: *Maker, step_names: []const []const u8) !void { { // Check that we have enough memory to complete the build. var any_problems = false; - var max_needed: usize = 0; + var max_needed: u64 = 0; for (step_stack.keys()) |step_index| { const make_step = maker.stepByIndex(step_index); const conf_step = step_index.ptr(c); diff --git a/lib/compiler/Maker/Step/Run.zig b/lib/compiler/Maker/Step/Run.zig index e59fec11efd18b5fd714a27b67e90ba4762e5bf3..e8d8f4f2ba56842a8daf7d4fe4ce0fb8da994bf8 100644 --- a/lib/compiler/Maker/Step/Run.zig +++ b/lib/compiler/Maker/Step/Run.zig @@ -1460,7 +1460,7 @@ fn evalGeneric( stderr_bytes = try multi_reader.toOwnedSlice(1); } else { var stdout_reader = stdout.readerStreaming(io, &.{}); - const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited(x) else .unlimited; + const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited64(x) else .unlimited; stdout_bytes = stdout_reader.interface.allocRemaining(arena, stdio_limit) catch |err| switch (err) { error.OutOfMemory => |e| return e, error.ReadFailed => return stdout_reader.err.?, @@ -1469,7 +1469,7 @@ fn evalGeneric( } } else if (child.stderr) |stderr| { var stderr_reader = stderr.readerStreaming(io, &.{}); - const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited(x) else .unlimited; + const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited64(x) else .unlimited; stderr_bytes = stderr_reader.interface.allocRemaining(arena, stdio_limit) catch |err| switch (err) { error.OutOfMemory => |e| return e, error.ReadFailed => return stderr_reader.err.?, diff --git a/lib/compiler/configurer.zig b/lib/compiler/configurer.zig index 308bf55fe72f4ab881f1168c96b1fc9ae9476bc3..b88c410b22addad55c61a2e26c3ceab17843c28c 100644 --- a/lib/compiler/configurer.zig +++ b/lib/compiler/configurer.zig @@ -1074,7 +1074,7 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { } else null }, .environ_map = .{ .value = try s.addEnvironMap(run.environ_map) }, .expect_term_value = .{ .value = if (expect_term) |t| t.value else null }, - .stdio_limit = .{ .value = run.stdio_limit.toInt() }, + .stdio_limit = .{ .value = run.stdio_limit.toInt64() }, .producer = .{ .value = if (run.producer) |cs| s.stepIndex(&cs.step) else null }, .expect_stderr_exact = .{ .value = if (expect_stderr_exact) |bytes| bytes else null }, .expect_stdout_exact = .{ .value = if (expect_stdout_exact) |bytes| bytes else null }, diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index a8934415755bed46f7c17bd9addd925ffaddde22..26fb7b68e43e358b8cb3bc2991148b8cda4441fc 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -1458,12 +1458,12 @@ pub const MaxRss = enum(u32) { none = 0, _, - pub fn toBytes(mr: MaxRss) usize { + pub fn toBytes(mr: MaxRss) u64 { const x: usize = @intFromEnum(mr); return x << 8; } - pub fn fromBytes(bytes: usize) MaxRss { + pub fn fromBytes(bytes: u64) MaxRss { return @enumFromInt(bytes >> 8); } }; diff --git a/lib/std/Io.zig b/lib/std/Io.zig index f3ef2757acad16f3dc4e548cc25d1172ba47e032..226de91cf7d720d58721f940354490835feba928 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -689,6 +689,13 @@ pub const Limit = enum(usize) { }; } + pub fn toInt64(l: Limit) ?u64 { + return switch (l) { + else => @intFromEnum(l), + .unlimited => null, + }; + } + /// Reduces a slice to account for the limit, leaving room for one extra /// byte above the limit, allowing for the use case of differentiating /// between end-of-stream and reaching the limit. diff --git a/src/main.zig b/src/main.zig index bd73f5a08a4d36cf65517b161d13b548d6ee19d6..80443b5709c9be7364e7f2439667711c4e4b3b30 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5133,6 +5133,7 @@ fn cmdBuild( } else { warn("Zig was compiled without debug extensions. --debug-target has no effect.", .{}); } + continue; } else if (mem.eql(u8, arg, "--debug-libc")) { if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); i += 1; @@ -5141,6 +5142,7 @@ fn cmdBuild( } else { warn("Zig was compiled without debug extensions. --debug-libc has no effect.", .{}); } + continue; } else if (mem.eql(u8, arg, "--verbose-link")) { verbose_link = true; } else if (mem.eql(u8, arg, "--verbose-cc")) { -- 2.54.0