authorgravatar for pentuppup@noreply.codeberg.orgpentuppup <pentuppup@noreply.codeberg.org> 2026-05-26 17:45:25-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-27 02:18:25+02:00
loge4512531d53d9a43a7cabbc793e618454c35aba3
treecc11512160f7b085c8bf6449bd249aeb39588b2e
parent4d56c6636251a90926467dfe65c99adf5ff7222a

fix some missed errors from build system rework


8 files changed, 35 insertions(+), 82 deletions(-)

lib/std/Build.zig+1-1
......@@ -945,7 +945,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
945945/// * `addSystemCommand`
946946/// * `addRunArtifact`
947947pub fn addRunFile(b: *Build, executable: LazyPath) *Step.Run {
948 const run_step = Step.Run.create(b, b.fmt("run {f}", .{executable.fmt(b.graph)}));
948 const run_step = Step.Run.create(b, b.fmt("run {f}", .{executable}));
949949 run_step.addFileArg(executable);
950950 return run_step;
951951}
lib/std/Build/Cache.zig+1
......@@ -982,6 +982,7 @@ pub const Manifest = struct {
982982 .stat = undefined,
983983 .bin_digest = undefined,
984984 .contents = null,
985 .handle = null,
985986 };
986987
987988 self.files.lockPointers();
lib/std/Build/Cache/Path.zig+27-28
......@@ -2,7 +2,6 @@ const Path = @This();
22
33const std = @import("../../std.zig");
44const Io = std.Io;
5const fs = std.fs;
65const assert = std.debug.assert;
76const Allocator = std.mem.Allocator;
87const Cache = std.Build.Cache;
......@@ -33,13 +32,13 @@ pub fn join(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Pat
3332 if (p.sub_path.len == 0) &.{sub_path} else &.{ p.sub_path, sub_path };
3433 return .{
3534 .root_dir = p.root_dir,
36 .sub_path = try fs.path.join(arena, parts),
35 .sub_path = try Io.Dir.path.join(arena, parts),
3736 };
3837}
3938
4039pub fn resolvePosix(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Path {
4140 if (sub_path.len == 0) return p;
42 const new_sub_path = try fs.path.resolvePosix(arena, &.{ p.sub_path, sub_path });
41 const new_sub_path = try Io.Dir.path.resolvePosix(arena, &.{ p.sub_path, sub_path });
4342 return .{
4443 .root_dir = p.root_dir,
4544 // Use "" instead of "." to represent `root_dir` itself.
......@@ -60,9 +59,9 @@ pub fn joinStringZ(p: Path, gpa: Allocator, sub_path: []const u8) Allocator.Erro
6059}
6160
6261pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.OpenFileOptions) !Io.File {
63 var buf: [fs.max_path_bytes]u8 = undefined;
62 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
6463 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
65 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
64 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
6665 p.sub_path, sub_path,
6766 }) catch return error.NameTooLong;
6867 };
......@@ -75,19 +74,19 @@ pub fn openDir(
7574 sub_path: []const u8,
7675 args: Io.Dir.OpenOptions,
7776) Io.Dir.OpenError!Io.Dir {
78 var buf: [fs.max_path_bytes]u8 = undefined;
77 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
7978 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
80 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
79 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
8180 p.sub_path, sub_path,
8281 }) catch return error.NameTooLong;
8382 };
8483 return p.root_dir.handle.openDir(io, joined_path, args);
8584}
8685
87pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.OpenOptions) !Io.Dir {
88 var buf: [fs.max_path_bytes]u8 = undefined;
86pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.CreateDirPathOpenOptions) !Io.Dir {
87 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
8988 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
90 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
89 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
9190 p.sub_path, sub_path,
9291 }) catch return error.NameTooLong;
9392 };
......@@ -95,9 +94,9 @@ pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.Ope
9594}
9695
9796pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat {
98 var buf: [fs.max_path_bytes]u8 = undefined;
97 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
9998 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
100 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
99 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
101100 p.sub_path, sub_path,
102101 }) catch return error.NameTooLong;
103102 };
......@@ -108,21 +107,21 @@ pub fn atomicFile(
108107 p: Path,
109108 io: Io,
110109 sub_path: []const u8,
111 options: Io.Dir.AtomicFileOptions,
112 buf: *[fs.max_path_bytes]u8,
113) !fs.AtomicFile {
110 options: Io.Dir.CreateFileAtomicOptions,
111 buf: *[Io.Dir.max_path_bytes]u8,
112) !Io.File.Atomic {
114113 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
115 break :p std.fmt.bufPrint(buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
114 break :p std.fmt.bufPrint(buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
116115 p.sub_path, sub_path,
117116 }) catch return error.NameTooLong;
118117 };
119 return p.root_dir.handle.atomicFile(io, joined_path, options);
118 return p.root_dir.handle.createFileAtomic(io, joined_path, options);
120119}
121120
122121pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void {
123 var buf: [fs.max_path_bytes]u8 = undefined;
122 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
124123 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
125 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
124 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
126125 p.sub_path, sub_path,
127126 }) catch return error.NameTooLong;
128127 };
......@@ -130,9 +129,9 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions
130129}
131130
132131pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void {
133 var buf: [fs.max_path_bytes]u8 = undefined;
132 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
134133 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
135 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
134 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
136135 p.sub_path, sub_path,
137136 }) catch return error.NameTooLong;
138137 };
......@@ -154,7 +153,7 @@ pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) {
154153pub fn formatEscapeString(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
155154 if (path.root_dir.path) |p| {
156155 try std.zig.stringEscape(p, writer);
157 if (path.sub_path.len > 0) try std.zig.stringEscape(fs.path.sep_str, writer);
156 if (path.sub_path.len > 0) try std.zig.stringEscape(Io.Dir.path.sep_str, writer);
158157 }
159158 if (path.sub_path.len > 0) {
160159 try std.zig.stringEscape(path.sub_path, writer);
......@@ -170,7 +169,7 @@ pub fn fmtEscapeChar(path: Path) std.fmt.Alt(Path, formatEscapeChar) {
170169pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
171170 if (path.root_dir.path) |p| {
172171 for (p) |byte| try std.zig.charEscape(byte, writer);
173 if (path.sub_path.len > 0) try writer.writeByte(fs.path.sep);
172 if (path.sub_path.len > 0) try writer.writeByte(Io.Dir.path.sep);
174173 }
175174 if (path.sub_path.len > 0) {
176175 for (path.sub_path) |byte| try std.zig.charEscape(byte, writer);
......@@ -178,14 +177,14 @@ pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
178177}
179178
180179pub fn format(self: Path, writer: *Io.Writer) Io.Writer.Error!void {
181 if (fs.path.isAbsolute(self.sub_path)) {
180 if (Io.Dir.path.isAbsolute(self.sub_path)) {
182181 try writer.writeAll(self.sub_path);
183182 return;
184183 }
185184 if (self.root_dir.path) |p| {
186185 try writer.writeAll(p);
187186 if (self.sub_path.len > 0) {
188 try writer.writeAll(fs.path.sep_str);
187 try writer.writeAll(Io.Dir.path.sep_str);
189188 try writer.writeAll(self.sub_path);
190189 }
191190 return;
......@@ -210,18 +209,18 @@ pub fn subPathOrDot(self: Path) []const u8 {
210209}
211210
212211pub fn stem(p: Path) []const u8 {
213 return fs.path.stem(p.sub_path);
212 return Io.Dir.path.stem(p.sub_path);
214213}
215214
216215pub fn dirname(p: Path) ?Path {
217216 return .{
218217 .root_dir = p.root_dir,
219 .sub_path = fs.path.dirname(p.subPathOpt() orelse return null) orelse "",
218 .sub_path = Io.Dir.path.dirname(p.subPathOpt() orelse return null) orelse "",
220219 };
221220}
222221
223222pub fn basename(p: Path) []const u8 {
224 return fs.path.basename(p.sub_path);
223 return Io.Dir.path.basename(p.sub_path);
225224}
226225
227226/// Useful to make `Path` a key in `std.ArrayHashMap`.
lib/std/Build/Configuration.zig-8
......@@ -2219,14 +2219,6 @@ pub const TargetQuery = struct {
22192219 windows: std.Target.Os.WindowsVersion,
22202220 default: void,
22212221
2222 pub fn init(x: ?std.Target.Query.OsVersion) @This() {
2223 return switch (x orelse return .default) {
2224 .none => .none,
2225 .semver => .semver,
2226 .windows => .windows,
2227 };
2228 }
2229
22302222 pub fn unwrap(this: @This(), c: *const Configuration) ?std.Target.Query.OsVersion {
22312223 return switch (this) {
22322224 .none => .none,
lib/std/Build/Step/Compile.zig+2-8
......@@ -573,7 +573,7 @@ pub fn setVersionScript(compile: *Compile, source: LazyPath) void {
573573
574574pub fn forceUndefinedSymbol(compile: *Compile, symbol_name: []const u8) void {
575575 const graph = compile.step.owner.graph;
576 const arena = graph.allocator;
576 const arena = graph.arena;
577577 compile.force_undefined_symbols.put(arena, graph.dupeString(symbol_name), {}) catch @panic("OOM");
578578}
579579
......@@ -710,12 +710,6 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath {
710710 return compile.getEmittedFileGeneric(&compile.generated_pdb);
711711}
712712
713/// Returns the generated compiler_rt dynamic library.
714/// This is a hack for stage2_x86_64 + coff.
715pub fn getEmittedCompilerRtDynLib(compile: *Compile) ?LazyPath {
716 return compile.getEmittedFileGeneric(&compile.generated_compiler_rt_dyn_lib);
717}
718
719713/// Returns the path to the generated documentation directory.
720714pub fn getEmittedDocs(compile: *Compile) LazyPath {
721715 return compile.getEmittedFileGeneric(&compile.generated_docs);
......@@ -740,7 +734,7 @@ pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {
740734 const graph = compile.step.owner.graph;
741735 const arena = graph.arena;
742736 assert(compile.kind == .@"test");
743 const duped_args = arena.alloc(?[]u8, args.len) catch @panic("OOM");
737 const duped_args = arena.alloc(?[]const u8, args.len) catch @panic("OOM");
744738 for (args, 0..) |arg, i| {
745739 duped_args[i] = if (arg) |a| graph.dupeString(a) else null;
746740 }
lib/std/Build/Step/ObjCopy.zig+2-2
......@@ -89,7 +89,7 @@ pub const UpdateSectionOptions = struct {
8989};
9090
9191pub fn updateSection(oc: *ObjCopy, section_name: []const u8, options: UpdateSectionOptions) void {
92 const graph = oc.owner.graph;
92 const graph = oc.step.owner.graph;
9393 const arena = graph.arena;
9494 const wc = &graph.wip_configuration;
9595 oc.update_sections.append(arena, .{
......@@ -106,7 +106,7 @@ pub const AddSectionOptions = struct {
106106};
107107
108108pub fn addSection(oc: *ObjCopy, section_name: []const u8, options: AddSectionOptions) void {
109 const graph = oc.owner.graph;
109 const graph = oc.step.owner.graph;
110110 const arena = graph.arena;
111111 const wc = &graph.wip_configuration;
112112 oc.add_sections.append(arena, .{
lib/std/Build/Step/Options.zig+2-2
......@@ -421,8 +421,8 @@ pub fn addOptionPath(options: *Options, name: []const u8, path: LazyPath) void {
421421 const wc = &graph.wip_configuration;
422422
423423 options.args.append(arena, .{
424 .name = try wc.addString(name),
425 .path = path.dupe(options.step.owner),
424 .name = wc.addString(name) catch @panic("OOM"),
425 .path = path.dupe(options.step.owner.graph),
426426 }) catch @panic("OOM");
427427 path.addStepDependencies(&options.step);
428428}
lib/std/Build/Step/Run.zig-33
......@@ -556,39 +556,6 @@ pub fn clearEnvironment(run: *Run) void {
556556 run.environ_map = new_env_map;
557557}
558558
559pub fn addPathDir(run: *Run, search_path: []const u8) void {
560 const b = run.step.owner;
561 const environ_map = getEnvMapInternal(run);
562
563 const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) {
564 .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows,
565 .lazy_path => |p| {
566 switch (p.lazy_path) {
567 .generated => |g| if (g.file.step.cast(Step.Compile)) |cs| break :use_wine cs.rootModuleTarget().os.tag == .windows,
568 else => {},
569 }
570 break :use_wine std.mem.endsWith(u8, p.lazy_path.basename(b, &run.step), ".exe");
571 },
572 .decorated_directory => false,
573 .file_content => unreachable, // not allowed as first arg
574 .bytes => |bytes| std.mem.endsWith(u8, bytes, ".exe"),
575 .output_file, .output_file_dep, .output_directory => false,
576 };
577 const key = if (use_wine) "WINEPATH" else "PATH";
578 const prev_path = environ_map.get(key);
579
580 if (prev_path) |pp| {
581 const new_path = b.fmt("{s}{c}{s}", .{
582 pp,
583 if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter,
584 search_path,
585 });
586 environ_map.put(key, new_path) catch @panic("OOM");
587 } else {
588 environ_map.put(key, b.dupePath(search_path)) catch @panic("OOM");
589 }
590}
591
592559pub fn getEnvMap(run: *Run) *EnvMap {
593560 return getEnvMapInternal(run);
594561}