authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-26 09:54:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-26 09:54:03-07:00
loge966d0c385a1557e5e56f042943770d1a0aeb9f9
tree460fd0c0b77336e160a63cc969c8d40f9e9993d9
parent0ff175b69ef806f421820d33dade7a8163fe3f16
parentfd63f57cd86ebcf1261b10d1a17e62d523e70981

Merge PR 'Fix build script compilation when usize is u32' (#32060)

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/32060 Reviewed-by: Andrew Kelley <andrew@ziglang.org>

14 files changed, 33 insertions(+), 24 deletions(-)

doc/langref/test_peer_type_resolution.zig+2-2
......@@ -96,8 +96,8 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
9696}
9797
9898test "peer type resolution: *const T and ?*T" {
99 const a: *const usize = @ptrFromInt(0x123456780);
100 const b: ?*usize = @ptrFromInt(0x123456780);
99 const a: *const usize = @ptrFromInt(0x12345678);
100 const b: ?*usize = @ptrFromInt(0x12345678);
101101 try expectEqual(a, b);
102102 try expectEqual(b, a);
103103}
lib/compiler/Maker.zig+2-2
......@@ -38,7 +38,7 @@ steps: []Step,
3838generated_files: []Path,
3939run_args: ?[]const []const u8,
4040
41available_rss: usize,
41available_rss: u64,
4242max_rss_is_default: bool,
4343max_rss_mutex: Io.Mutex,
4444skip_oom_steps: bool,
......@@ -740,7 +740,7 @@ fn prepare(maker: *Maker, step_names: []const []const u8) !void {
740740 {
741741 // Check that we have enough memory to complete the build.
742742 var any_problems = false;
743 var max_needed: usize = 0;
743 var max_needed: u64 = 0;
744744 for (step_stack.keys()) |step_index| {
745745 const make_step = maker.stepByIndex(step_index);
746746 const conf_step = step_index.ptr(c);
lib/compiler/Maker/Step/Run.zig+2-2
......@@ -1460,7 +1460,7 @@ fn evalGeneric(
14601460 stderr_bytes = try multi_reader.toOwnedSlice(1);
14611461 } else {
14621462 var stdout_reader = stdout.readerStreaming(io, &.{});
1463 const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited(x) else .unlimited;
1463 const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited64(x) else .unlimited;
14641464 stdout_bytes = stdout_reader.interface.allocRemaining(arena, stdio_limit) catch |err| switch (err) {
14651465 error.OutOfMemory => |e| return e,
14661466 error.ReadFailed => return stdout_reader.err.?,
......@@ -1469,7 +1469,7 @@ fn evalGeneric(
14691469 }
14701470 } else if (child.stderr) |stderr| {
14711471 var stderr_reader = stderr.readerStreaming(io, &.{});
1472 const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited(x) else .unlimited;
1472 const stdio_limit: Io.Limit = if (conf_run.stdio_limit.value) |x| .limited64(x) else .unlimited;
14731473 stderr_bytes = stderr_reader.interface.allocRemaining(arena, stdio_limit) catch |err| switch (err) {
14741474 error.OutOfMemory => |e| return e,
14751475 error.ReadFailed => return stderr_reader.err.?,
lib/compiler/Maker/WebServer.zig+2-2
......@@ -876,8 +876,8 @@ pub fn updateTimeReportRunTest(
876876 assert(tests.names.len == ns_per_test.len);
877877 const tests_len: u32 = @intCast(tests.names.len);
878878
879 const new_len: u64 = len: {
880 var names_len: u64 = 0;
879 const new_len: usize = len: {
880 var names_len: usize = 0;
881881 for (0..tests_len) |i| {
882882 names_len += tests.testName(@intCast(i)).len + 1;
883883 }
lib/compiler/configurer.zig+1-1
......@@ -1074,7 +1074,7 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void {
10741074 } else null },
10751075 .environ_map = .{ .value = try s.addEnvironMap(run.environ_map) },
10761076 .expect_term_value = .{ .value = if (expect_term) |t| t.value else null },
1077 .stdio_limit = .{ .value = run.stdio_limit.toInt() },
1077 .stdio_limit = .{ .value = run.stdio_limit.toInt64() },
10781078 .producer = .{ .value = if (run.producer) |cs| s.stepIndex(&cs.step) else null },
10791079 .expect_stderr_exact = .{ .value = if (expect_stderr_exact) |bytes| bytes else null },
10801080 .expect_stdout_exact = .{ .value = if (expect_stdout_exact) |bytes| bytes else null },
lib/std/Build.zig+5-5
......@@ -692,7 +692,7 @@ pub const ExecutableOptions = struct {
692692 root_module: *Module,
693693 version: ?std.SemanticVersion = null,
694694 linkage: ?std.builtin.LinkMode = null,
695 max_rss: usize = 0,
695 max_rss: u64 = 0,
696696 use_llvm: ?bool = null,
697697 use_lld: ?bool = null,
698698 zig_lib_dir: ?LazyPath = null,
......@@ -722,7 +722,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile {
722722pub const ObjectOptions = struct {
723723 name: []const u8,
724724 root_module: *Module,
725 max_rss: usize = 0,
725 max_rss: u64 = 0,
726726 use_llvm: ?bool = null,
727727 use_lld: ?bool = null,
728728 zig_lib_dir: ?LazyPath = null,
......@@ -745,7 +745,7 @@ pub const LibraryOptions = struct {
745745 name: []const u8,
746746 root_module: *Module,
747747 version: ?std.SemanticVersion = null,
748 max_rss: usize = 0,
748 max_rss: u64 = 0,
749749 use_llvm: ?bool = null,
750750 use_lld: ?bool = null,
751751 zig_lib_dir: ?LazyPath = null,
......@@ -778,7 +778,7 @@ pub fn addLibrary(b: *Build, options: LibraryOptions) *Step.Compile {
778778pub const TestOptions = struct {
779779 name: []const u8 = "test",
780780 root_module: *Module,
781 max_rss: usize = 0,
781 max_rss: u64 = 0,
782782 filters: []const []const u8 = &.{},
783783 test_runner: ?Step.Compile.TestRunner = null,
784784 use_llvm: ?bool = null,
......@@ -819,7 +819,7 @@ pub const AssemblyOptions = struct {
819819 /// `host` field of the package's `Build` instance.
820820 target: ResolvedTarget,
821821 optimize: std.builtin.OptimizeMode,
822 max_rss: usize = 0,
822 max_rss: u64 = 0,
823823 zig_lib_dir: ?LazyPath = null,
824824};
825825
lib/std/Build/Configuration.zig+2-2
......@@ -1458,12 +1458,12 @@ pub const MaxRss = enum(u32) {
14581458 none = 0,
14591459 _,
14601460
1461 pub fn toBytes(mr: MaxRss) usize {
1461 pub fn toBytes(mr: MaxRss) u64 {
14621462 const x: usize = @intFromEnum(mr);
14631463 return x << 8;
14641464 }
14651465
1466 pub fn fromBytes(bytes: usize) MaxRss {
1466 pub fn fromBytes(bytes: u64) MaxRss {
14671467 return @enumFromInt(bytes >> 8);
14681468 }
14691469};
lib/std/Build/Step.zig+2-2
......@@ -30,7 +30,7 @@ dependencies: std.ArrayList(*Step),
3030/// max_rss value that does not exceed the `max_total_rss` value of the build
3131/// runner. This value is configurable on the command line, and defaults to the
3232/// total system memory available.
33max_rss: usize,
33max_rss: u64,
3434
3535/// The return address associated with creation of this step that can be useful
3636/// to print along with debugging messages.
......@@ -87,7 +87,7 @@ pub const StepOptions = struct {
8787 name: []const u8,
8888 owner: *Build,
8989 first_ret_addr: ?usize = null,
90 max_rss: usize = 0,
90 max_rss: u64 = 0,
9191};
9292
9393pub fn init(options: StepOptions) Step {
lib/std/Build/Step/Compile.zig+1-1
......@@ -269,7 +269,7 @@ pub const Options = struct {
269269 kind: Kind,
270270 linkage: ?std.builtin.LinkMode = null,
271271 version: ?std.SemanticVersion = null,
272 max_rss: usize = 0,
272 max_rss: u64 = 0,
273273 filters: []const []const u8 = &.{},
274274 test_runner: ?TestRunner = null,
275275 use_llvm: ?bool = null,
lib/std/Io.zig+7
......@@ -689,6 +689,13 @@ pub const Limit = enum(usize) {
689689 };
690690 }
691691
692 pub fn toInt64(l: Limit) ?u64 {
693 return switch (l) {
694 else => @intFromEnum(l),
695 .unlimited => null,
696 };
697 }
698
692699 /// Reduces a slice to account for the limit, leaving room for one extra
693700 /// byte above the limit, allowing for the use case of differentiating
694701 /// between end-of-stream and reaching the limit.
lib/std/elf.zig+2-2
......@@ -873,8 +873,8 @@ pub const ProgramHeaderBufferIterator = struct {
873873 if (it.index >= it.phnum) return null;
874874 defer it.index += 1;
875875
876 const size: u64 = if (it.is_64) @sizeOf(Elf64_Phdr) else @sizeOf(Elf32_Phdr);
877 const offset = it.phoff + size * it.index;
876 const size: usize = if (it.is_64) @sizeOf(Elf64_Phdr) else @sizeOf(Elf32_Phdr);
877 const offset = @as(usize, @intCast(it.phoff)) + size * it.index;
878878 var reader = Io.Reader.fixed(it.buf[offset..]);
879879
880880 return try takeProgramHeader(&reader, it.is_64, it.endian);
src/main.zig+2
......@@ -5133,6 +5133,7 @@ fn cmdBuild(
51335133 } else {
51345134 warn("Zig was compiled without debug extensions. --debug-target has no effect.", .{});
51355135 }
5136 continue;
51365137 } else if (mem.eql(u8, arg, "--debug-libc")) {
51375138 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
51385139 i += 1;
......@@ -5141,6 +5142,7 @@ fn cmdBuild(
51415142 } else {
51425143 warn("Zig was compiled without debug extensions. --debug-libc has no effect.", .{});
51435144 }
5145 continue;
51445146 } else if (mem.eql(u8, arg, "--verbose-link")) {
51455147 verbose_link = true;
51465148 } else if (mem.eql(u8, arg, "--verbose-cc")) {
test/src/Libc.zig+1-1
......@@ -11,7 +11,7 @@ pub const Options = struct {
1111 test_filters: []const []const u8,
1212 test_target_filters: []const []const u8,
1313 skip_wasm: bool,
14 max_rss: usize,
14 max_rss: u64,
1515};
1616
1717const TestCase = struct {
test/tests.zig+2-2
......@@ -2467,7 +2467,7 @@ pub const ModuleTestOptions = struct {
24672467 skip_linux: bool,
24682468 skip_llvm: bool,
24692469 skip_libc: bool,
2470 max_rss: usize = 0,
2470 max_rss: u64 = 0,
24712471 no_builtin: bool = false,
24722472 sanitize_thread: ?bool = null,
24732473 build_options: ?*Step.Options = null,
......@@ -2795,7 +2795,7 @@ const CAbiTestOptions = struct {
27952795 skip_darwin: bool,
27962796 skip_linux: bool,
27972797 skip_llvm: bool,
2798 max_rss: usize = 0,
2798 max_rss: u64 = 0,
27992799};
28002800
28012801pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {