authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-16 13:15:35+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-07-16 13:15:35+02:00
log89ab6b161d39e0f6338930b2c06dbff891d1f768
tree74b2dfa357e850a7c23ddcfd1e07f0f0347c1ac7
parent9a69aede0e250c136de5f1e1b33f072d4d744ffc
parent11a49868a1d4c3cbfdeab13fe872aa4175759fb1
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #24470 from alexrp/fix-tools

Fix bitrot in tools

10 files changed, 94 insertions(+), 84 deletions(-)

test/standalone/build.zig+19-1
......@@ -38,20 +38,38 @@ pub fn build(b: *std.Build) void {
3838 "../../tools/gen_spirv_spec.zig",
3939 "../../tools/gen_stubs.zig",
4040 "../../tools/generate_c_size_and_align_checks.zig",
41 "../../tools/generate_JSONTestSuite.zig",
4142 "../../tools/generate_linux_syscalls.zig",
4243 "../../tools/process_headers.zig",
44 "../../tools/migrate_langref.zig",
4345 "../../tools/update-linux-headers.zig",
4446 "../../tools/update_clang_options.zig",
4547 "../../tools/update_cpu_features.zig",
48 "../../tools/update_crc_catalog.zig",
4649 "../../tools/update_freebsd_libc.zig",
4750 "../../tools/update_glibc.zig",
51 "../../tools/update_mingw.zig",
4852 "../../tools/update_netbsd_libc.zig",
53 }) |tool_src_path| {
54 if (std.mem.endsWith(u8, tool_src_path, "dump-cov.zig") and tools_target.result.os.tag == .windows) continue;
55
56 const tool = b.addExecutable(.{
57 .name = std.fs.path.stem(tool_src_path),
58 .root_module = b.createModule(.{
59 .root_source_file = b.path(tool_src_path),
60 .target = tools_target,
61 }),
62 });
63 tools_tests_step.dependOn(&tool.step);
64 }
65 for ([_][]const u8{
66 // Alphabetically sorted. Only ones with `test` blocks.
67 "../../tools/doctest.zig",
4968 }) |tool_src_path| {
5069 const tool = b.addTest(.{
5170 .name = std.fs.path.stem(tool_src_path),
5271 .root_module = b.createModule(.{
5372 .root_source_file = b.path(tool_src_path),
54 .optimize = .Debug,
5573 .target = tools_target,
5674 }),
5775 });
tools/fetch_them_macos_headers.zig+5-9
......@@ -87,7 +87,7 @@ pub fn main() anyerror!void {
8787
8888 const sysroot_path = sysroot orelse blk: {
8989 const target = try std.zig.system.resolveTargetQuery(.{});
90 break :blk std.zig.system.darwin.getSdk(allocator, target) orelse
90 break :blk std.zig.system.darwin.getSdk(allocator, &target) orelse
9191 fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{});
9292 };
9393
......@@ -112,7 +112,7 @@ pub fn main() anyerror!void {
112112 15 => .sequoia,
113113 else => unreachable,
114114 };
115 info("found SDK deployment target macOS {} aka '{s}'", .{ version, @tagName(os_ver) });
115 info("found SDK deployment target macOS {f} aka '{s}'", .{ version, @tagName(os_ver) });
116116
117117 var tmp = tmpDir(.{});
118118 defer tmp.cleanup();
......@@ -198,7 +198,7 @@ fn fetchTarget(
198198 var dirs = std.StringHashMap(fs.Dir).init(arena);
199199 try dirs.putNoClobber(".", dest_dir);
200200
201 const headers_list_str = try headers_list_file.reader().readAllAlloc(arena, std.math.maxInt(usize));
201 const headers_list_str = try headers_list_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(usize));
202202 const prefix = "/usr/include";
203203
204204 var it = mem.splitScalar(u8, headers_list_str, '\n');
......@@ -270,12 +270,8 @@ const Version = struct {
270270
271271 pub fn format(
272272 v: Version,
273 comptime unused_fmt_string: []const u8,
274 options: std.fmt.FormatOptions,
275 writer: anytype,
276 ) !void {
277 _ = unused_fmt_string;
278 _ = options;
273 writer: *std.Io.Writer,
274 ) std.Io.Writer.Error!void {
279275 try writer.print("{d}.{d}.{d}", .{ v.major, v.minor, v.patch });
280276 }
281277};
tools/gen_stubs.zig+1-1
......@@ -303,7 +303,7 @@ pub fn main() !void {
303303 libc_so_path,
304304 100 * 1024 * 1024,
305305 1 * 1024 * 1024,
306 @alignOf(elf.Elf64_Ehdr),
306 .of(elf.Elf64_Ehdr),
307307 null,
308308 ) catch |err| {
309309 std.debug.panic("unable to read '{s}/{s}': {s}", .{
tools/generate_linux_syscalls.zig+7-7
......@@ -477,7 +477,7 @@ fn processPreprocessedFile(
477477 const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..];
478478 const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name;
479479
480 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), value });
480 try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), value });
481481 }
482482}
483483
......@@ -510,7 +510,7 @@ fn processTableBasedArch(
510510 }
511511 const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name;
512512
513 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
513 try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
514514 }
515515}
516516
......@@ -543,7 +543,7 @@ fn processMipsBasedArch(
543543 }
544544 const fixed_name = if (filters.fixedName) |fixedNameFn| fixedNameFn(name) else name;
545545
546 try writer.print(" {p} = linux_base + {s},\n", .{ zig.fmtId(fixed_name), number });
546 try writer.print(" {f} = linux_base + {s},\n", .{ zig.fmtId(fixed_name), number });
547547 }
548548}
549549
......@@ -568,12 +568,12 @@ fn processPowerPcBasedArch(
568568 if (mem.eql(u8, abi, "spu")) {
569569 continue;
570570 } else if (mem.eql(u8, abi, "32")) {
571 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
571 try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
572572 } else if (mem.eql(u8, abi, "64")) {
573 try optional_writer.?.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
573 try optional_writer.?.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
574574 } else { // common/nospu
575 try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
576 try optional_writer.?.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number });
575 try writer.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
576 try optional_writer.?.print(" {f} = {s},\n", .{ zig.fmtId(fixed_name), number });
577577 }
578578 }
579579}
tools/migrate_langref.zig+18-18
......@@ -27,9 +27,9 @@ pub fn main() !void {
2727 var out_dir = try fs.cwd().openDir(fs.path.dirname(output_file).?, .{});
2828 defer out_dir.close();
2929
30 const input_file_bytes = try in_file.reader().readAllAlloc(arena, std.math.maxInt(u32));
30 const input_file_bytes = try in_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(u32));
3131
32 var buffered_writer = io.bufferedWriter(out_file.writer());
32 var buffered_writer = io.bufferedWriter(out_file.deprecatedWriter());
3333
3434 var tokenizer = Tokenizer.init(input_file, input_file_bytes);
3535
......@@ -388,39 +388,39 @@ fn walk(arena: Allocator, tokenizer: *Tokenizer, out_dir: std.fs.Dir, w: anytype
388388 try file.writeAll("\n\n");
389389
390390 if (just_check_syntax) {
391 try file.writer().print("// syntax\n", .{});
391 try file.deprecatedWriter().print("// syntax\n", .{});
392392 } else switch (code_kind_id) {
393 .@"test" => try file.writer().print("// test\n", .{}),
394 .lib => try file.writer().print("// lib\n", .{}),
395 .test_error => |s| try file.writer().print("// test_error={s}\n", .{s}),
396 .test_safety => |s| try file.writer().print("// test_safety={s}\n", .{s}),
397 .exe => |s| try file.writer().print("// exe={s}\n", .{@tagName(s)}),
393 .@"test" => try file.deprecatedWriter().print("// test\n", .{}),
394 .lib => try file.deprecatedWriter().print("// lib\n", .{}),
395 .test_error => |s| try file.deprecatedWriter().print("// test_error={s}\n", .{s}),
396 .test_safety => |s| try file.deprecatedWriter().print("// test_safety={s}\n", .{s}),
397 .exe => |s| try file.deprecatedWriter().print("// exe={s}\n", .{@tagName(s)}),
398398 .obj => |opt| if (opt) |s| {
399 try file.writer().print("// obj={s}\n", .{s});
399 try file.deprecatedWriter().print("// obj={s}\n", .{s});
400400 } else {
401 try file.writer().print("// obj\n", .{});
401 try file.deprecatedWriter().print("// obj\n", .{});
402402 },
403403 }
404404
405405 if (mode != .Debug)
406 try file.writer().print("// optimize={s}\n", .{@tagName(mode)});
406 try file.deprecatedWriter().print("// optimize={s}\n", .{@tagName(mode)});
407407
408408 for (link_objects.items) |link_object| {
409 try file.writer().print("// link_object={s}\n", .{link_object});
409 try file.deprecatedWriter().print("// link_object={s}\n", .{link_object});
410410 }
411411
412412 if (target_str) |s|
413 try file.writer().print("// target={s}\n", .{s});
413 try file.deprecatedWriter().print("// target={s}\n", .{s});
414414
415 if (link_libc) try file.writer().print("// link_libc\n", .{});
416 if (disable_cache) try file.writer().print("// disable_cache\n", .{});
417 if (verbose_cimport) try file.writer().print("// verbose_cimport\n", .{});
415 if (link_libc) try file.deprecatedWriter().print("// link_libc\n", .{});
416 if (disable_cache) try file.deprecatedWriter().print("// disable_cache\n", .{});
417 if (verbose_cimport) try file.deprecatedWriter().print("// verbose_cimport\n", .{});
418418
419419 if (link_mode) |m|
420 try file.writer().print("// link_mode={s}\n", .{@tagName(m)});
420 try file.deprecatedWriter().print("// link_mode={s}\n", .{@tagName(m)});
421421
422422 for (additional_options.items) |o| {
423 try file.writer().print("// additional_option={s}\n", .{o});
423 try file.deprecatedWriter().print("// additional_option={s}\n", .{o});
424424 }
425425 try w.print("{{#code|{s}#}}\n", .{basename});
426426 } else {
tools/process_headers.zig+7-7
......@@ -266,10 +266,10 @@ pub fn main() !void {
266266 if (gop.found_existing) {
267267 max_bytes_saved += raw_bytes.len;
268268 gop.value_ptr.hit_count += 1;
269 std.debug.print("duplicate: {s} {s} ({:2})\n", .{
269 std.debug.print("duplicate: {s} {s} ({B})\n", .{
270270 libc_dir,
271271 rel_path,
272 std.fmt.fmtIntSizeDec(raw_bytes.len),
272 raw_bytes.len,
273273 });
274274 } else {
275275 gop.value_ptr.* = Contents{
......@@ -311,9 +311,9 @@ pub fn main() !void {
311311 std.debug.print("warning: libc target not found: {s}\n", .{libc_dir});
312312 }
313313 }
314 std.debug.print("summary: {:2} could be reduced to {:2}\n", .{
315 std.fmt.fmtIntSizeDec(total_bytes),
316 std.fmt.fmtIntSizeDec(total_bytes - max_bytes_saved),
314 std.debug.print("summary: {B} could be reduced to {B}\n", .{
315 total_bytes,
316 total_bytes - max_bytes_saved,
317317 });
318318 try std.fs.cwd().makePath(out_dir);
319319
......@@ -343,8 +343,8 @@ pub fn main() !void {
343343 if (contender.hit_count > 1) {
344344 const this_missed_bytes = contender.hit_count * contender.bytes.len;
345345 missed_opportunity_bytes += this_missed_bytes;
346 std.debug.print("Missed opportunity ({:2}): {s}\n", .{
347 std.fmt.fmtIntSizeDec(this_missed_bytes),
346 std.debug.print("Missed opportunity ({B}): {s}\n", .{
347 this_missed_bytes,
348348 path_kv.key_ptr.*,
349349 });
350350 } else break;
tools/update-linux-headers.zig+7-7
......@@ -218,10 +218,10 @@ pub fn main() !void {
218218 if (gop.found_existing) {
219219 max_bytes_saved += raw_bytes.len;
220220 gop.value_ptr.hit_count += 1;
221 std.debug.print("duplicate: {s} {s} ({:2})\n", .{
221 std.debug.print("duplicate: {s} {s} ({B})\n", .{
222222 linux_target.name,
223223 rel_path,
224 std.fmt.fmtIntSizeDec(raw_bytes.len),
224 raw_bytes.len,
225225 });
226226 } else {
227227 gop.value_ptr.* = Contents{
......@@ -249,9 +249,9 @@ pub fn main() !void {
249249 std.debug.print("warning: libc target not found: {s}\n", .{linux_target.name});
250250 }
251251 }
252 std.debug.print("summary: {:2} could be reduced to {:2}\n", .{
253 std.fmt.fmtIntSizeDec(total_bytes),
254 std.fmt.fmtIntSizeDec(total_bytes - max_bytes_saved),
252 std.debug.print("summary: {B} could be reduced to {B}\n", .{
253 total_bytes,
254 total_bytes - max_bytes_saved,
255255 });
256256 try std.fs.cwd().makePath(out_dir);
257257
......@@ -281,8 +281,8 @@ pub fn main() !void {
281281 if (contender.hit_count > 1) {
282282 const this_missed_bytes = contender.hit_count * contender.bytes.len;
283283 missed_opportunity_bytes += this_missed_bytes;
284 std.debug.print("Missed opportunity ({:2}): {s}\n", .{
285 std.fmt.fmtIntSizeDec(this_missed_bytes),
284 std.debug.print("Missed opportunity ({B}): {s}\n", .{
285 this_missed_bytes,
286286 path_kv.key_ptr.*,
287287 });
288288 } else break;
tools/update_clang_options.zig+6-10
......@@ -635,7 +635,7 @@ pub fn main() anyerror!void {
635635 const args = try std.process.argsAlloc(allocator);
636636
637637 var stdout_buffer: [4000]u8 = undefined;
638 var stdout_writer = fs.stdout().writerStreaming(&stdout_buffer);
638 var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer);
639639 const stdout = &stdout_writer.interface;
640640
641641 if (args.len <= 1) printUsageAndExit(args[0]);
......@@ -767,7 +767,7 @@ pub fn main() anyerror!void {
767767 try stdout.print(
768768 \\.{{
769769 \\ .name = "{s}",
770 \\ .syntax = {s},
770 \\ .syntax = {f},
771771 \\ .zig_equivalent = .{s},
772772 \\ .pd1 = {},
773773 \\ .pd2 = {},
......@@ -797,7 +797,7 @@ pub fn main() anyerror!void {
797797 try stdout.print(
798798 \\.{{
799799 \\ .name = "{s}",
800 \\ .syntax = {s},
800 \\ .syntax = {f},
801801 \\ .zig_equivalent = .other,
802802 \\ .pd1 = {},
803803 \\ .pd2 = {},
......@@ -845,14 +845,10 @@ const Syntax = union(enum) {
845845
846846 pub fn format(
847847 self: Syntax,
848 comptime fmt: []const u8,
849 options: std.fmt.FormatOptions,
850 out_stream: anytype,
851 ) !void {
852 _ = fmt;
853 _ = options;
848 out_stream: *std.Io.Writer,
849 ) std.Io.Writer.Error!void {
854850 switch (self) {
855 .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }),
851 .multi_arg => |n| return out_stream.print(".{{.{t}={d}}}", .{ self, n }),
856852 else => return out_stream.print(".{s}", .{@tagName(self)}),
857853 }
858854 }
tools/update_cpu_features.zig+22-22
......@@ -1906,7 +1906,7 @@ fn processOneTarget(job: Job) void {
19061906 var zig_code_file = try target_dir.createFile(zig_code_basename, .{});
19071907 defer zig_code_file.close();
19081908
1909 var bw = std.io.bufferedWriter(zig_code_file.writer());
1909 var bw = std.io.bufferedWriter(zig_code_file.deprecatedWriter());
19101910 const w = bw.writer();
19111911
19121912 try w.writeAll(
......@@ -1920,7 +1920,7 @@ fn processOneTarget(job: Job) void {
19201920 );
19211921
19221922 for (all_features.items, 0..) |feature, i| {
1923 try w.print("\n {p},", .{std.zig.fmtId(feature.zig_name)});
1923 try w.print("\n {f},", .{std.zig.fmtId(feature.zig_name)});
19241924
19251925 if (i == all_features.items.len - 1) try w.writeAll("\n");
19261926 }
......@@ -1949,27 +1949,27 @@ fn processOneTarget(job: Job) void {
19491949 for (all_features.items) |feature| {
19501950 if (feature.llvm_name) |llvm_name| {
19511951 try w.print(
1952 \\ result[@intFromEnum(Feature.{p_})] = .{{
1953 \\ .llvm_name = "{}",
1954 \\ .description = "{}",
1952 \\ result[@intFromEnum(Feature.{f})] = .{{
1953 \\ .llvm_name = "{f}",
1954 \\ .description = "{f}",
19551955 \\ .dependencies = featureSet(&[_]Feature{{
19561956 ,
19571957 .{
1958 std.zig.fmtId(feature.zig_name),
1959 std.zig.fmtEscapes(llvm_name),
1960 std.zig.fmtEscapes(feature.desc),
1958 std.zig.fmtIdPU(feature.zig_name),
1959 std.zig.fmtString(llvm_name),
1960 std.zig.fmtString(feature.desc),
19611961 },
19621962 );
19631963 } else {
19641964 try w.print(
1965 \\ result[@intFromEnum(Feature.{p_})] = .{{
1965 \\ result[@intFromEnum(Feature.{f})] = .{{
19661966 \\ .llvm_name = null,
1967 \\ .description = "{}",
1967 \\ .description = "{f}",
19681968 \\ .dependencies = featureSet(&[_]Feature{{
19691969 ,
19701970 .{
1971 std.zig.fmtId(feature.zig_name),
1972 std.zig.fmtEscapes(feature.desc),
1971 std.zig.fmtIdPU(feature.zig_name),
1972 std.zig.fmtString(feature.desc),
19731973 },
19741974 );
19751975 }
......@@ -1996,7 +1996,7 @@ fn processOneTarget(job: Job) void {
19961996 } else {
19971997 try w.writeAll("\n");
19981998 for (dependencies.items) |dep| {
1999 try w.print(" .{p_},\n", .{std.zig.fmtId(dep)});
1999 try w.print(" .{f},\n", .{std.zig.fmtIdPU(dep)});
20002000 }
20012001 try w.writeAll(
20022002 \\ }),
......@@ -2033,24 +2033,24 @@ fn processOneTarget(job: Job) void {
20332033 mem.sort([]const u8, cpu_features.items, {}, asciiLessThan);
20342034 if (cpu.llvm_name) |llvm_name| {
20352035 try w.print(
2036 \\ pub const {}: CpuModel = .{{
2037 \\ .name = "{}",
2038 \\ .llvm_name = "{}",
2036 \\ pub const {f}: CpuModel = .{{
2037 \\ .name = "{f}",
2038 \\ .llvm_name = "{f}",
20392039 \\ .features = featureSet(&[_]Feature{{
20402040 , .{
20412041 std.zig.fmtId(cpu.zig_name),
2042 std.zig.fmtEscapes(cpu.zig_name),
2043 std.zig.fmtEscapes(llvm_name),
2042 std.zig.fmtString(cpu.zig_name),
2043 std.zig.fmtString(llvm_name),
20442044 });
20452045 } else {
20462046 try w.print(
2047 \\ pub const {}: CpuModel = .{{
2048 \\ .name = "{}",
2047 \\ pub const {f}: CpuModel = .{{
2048 \\ .name = "{f}",
20492049 \\ .llvm_name = null,
20502050 \\ .features = featureSet(&[_]Feature{{
20512051 , .{
20522052 std.zig.fmtId(cpu.zig_name),
2053 std.zig.fmtEscapes(cpu.zig_name),
2053 std.zig.fmtString(cpu.zig_name),
20542054 });
20552055 }
20562056 if (cpu_features.items.len == 0) {
......@@ -2062,7 +2062,7 @@ fn processOneTarget(job: Job) void {
20622062 } else {
20632063 try w.writeAll("\n");
20642064 for (cpu_features.items) |feature_zig_name| {
2065 try w.print(" .{p_},\n", .{std.zig.fmtId(feature_zig_name)});
2065 try w.print(" .{f},\n", .{std.zig.fmtIdPU(feature_zig_name)});
20662066 }
20672067 try w.writeAll(
20682068 \\ }),
tools/update_crc_catalog.zig+2-2
......@@ -30,7 +30,7 @@ pub fn main() anyerror!void {
3030 var zig_code_file = try hash_target_dir.createFile("crc.zig", .{});
3131 defer zig_code_file.close();
3232
33 var cbw = std.io.bufferedWriter(zig_code_file.writer());
33 var cbw = std.io.bufferedWriter(zig_code_file.deprecatedWriter());
3434 defer cbw.flush() catch unreachable;
3535 const code_writer = cbw.writer();
3636
......@@ -55,7 +55,7 @@ pub fn main() anyerror!void {
5555 var zig_test_file = try crc_target_dir.createFile("test.zig", .{});
5656 defer zig_test_file.close();
5757
58 var tbw = std.io.bufferedWriter(zig_test_file.writer());
58 var tbw = std.io.bufferedWriter(zig_test_file.deprecatedWriter());
5959 defer tbw.flush() catch unreachable;
6060 const test_writer = tbw.writer();
6161