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 {...@@ -945,7 +945,7 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
945/// * `addSystemCommand`945/// * `addSystemCommand`
946/// * `addRunArtifact`946/// * `addRunArtifact`
947pub fn addRunFile(b: *Build, executable: LazyPath) *Step.Run {947pub 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}));
949 run_step.addFileArg(executable);949 run_step.addFileArg(executable);
950 return run_step;950 return run_step;
951}951}
lib/std/Build/Cache.zig+1
...@@ -982,6 +982,7 @@ pub const Manifest = struct {...@@ -982,6 +982,7 @@ pub const Manifest = struct {
982 .stat = undefined,982 .stat = undefined,
983 .bin_digest = undefined,983 .bin_digest = undefined,
984 .contents = null,984 .contents = null,
985 .handle = null,
985 };986 };
986987
987 self.files.lockPointers();988 self.files.lockPointers();
lib/std/Build/Cache/Path.zig+27-28
...@@ -2,7 +2,6 @@ const Path = @This();...@@ -2,7 +2,6 @@ const Path = @This();
22
3const std = @import("../../std.zig");3const std = @import("../../std.zig");
4const Io = std.Io;4const Io = std.Io;
5const fs = std.fs;
6const assert = std.debug.assert;5const assert = std.debug.assert;
7const Allocator = std.mem.Allocator;6const Allocator = std.mem.Allocator;
8const Cache = std.Build.Cache;7const Cache = std.Build.Cache;
...@@ -33,13 +32,13 @@ pub fn join(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Pat...@@ -33,13 +32,13 @@ pub fn join(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Pat
33 if (p.sub_path.len == 0) &.{sub_path} else &.{ p.sub_path, sub_path };32 if (p.sub_path.len == 0) &.{sub_path} else &.{ p.sub_path, sub_path };
34 return .{33 return .{
35 .root_dir = p.root_dir,34 .root_dir = p.root_dir,
36 .sub_path = try fs.path.join(arena, parts),35 .sub_path = try Io.Dir.path.join(arena, parts),
37 };36 };
38}37}
3938
40pub fn resolvePosix(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Path {39pub fn resolvePosix(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Path {
41 if (sub_path.len == 0) return p;40 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 });
43 return .{42 return .{
44 .root_dir = p.root_dir,43 .root_dir = p.root_dir,
45 // Use "" instead of "." to represent `root_dir` itself.44 // 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...@@ -60,9 +59,9 @@ pub fn joinStringZ(p: Path, gpa: Allocator, sub_path: []const u8) Allocator.Erro
60}59}
6160
62pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.OpenFileOptions) !Io.File {61pub 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;
64 const joined_path = if (p.sub_path.len == 0) sub_path else p: {63 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}", .{
66 p.sub_path, sub_path,65 p.sub_path, sub_path,
67 }) catch return error.NameTooLong;66 }) catch return error.NameTooLong;
68 };67 };
...@@ -75,19 +74,19 @@ pub fn openDir(...@@ -75,19 +74,19 @@ pub fn openDir(
75 sub_path: []const u8,74 sub_path: []const u8,
76 args: Io.Dir.OpenOptions,75 args: Io.Dir.OpenOptions,
77) Io.Dir.OpenError!Io.Dir {76) Io.Dir.OpenError!Io.Dir {
78 var buf: [fs.max_path_bytes]u8 = undefined;77 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
79 const joined_path = if (p.sub_path.len == 0) sub_path else p: {78 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}", .{
81 p.sub_path, sub_path,80 p.sub_path, sub_path,
82 }) catch return error.NameTooLong;81 }) catch return error.NameTooLong;
83 };82 };
84 return p.root_dir.handle.openDir(io, joined_path, args);83 return p.root_dir.handle.openDir(io, joined_path, args);
85}84}
8685
87pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.OpenOptions) !Io.Dir {86pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.CreateDirPathOpenOptions) !Io.Dir {
88 var buf: [fs.max_path_bytes]u8 = undefined;87 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
89 const joined_path = if (p.sub_path.len == 0) sub_path else p: {88 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}", .{
91 p.sub_path, sub_path,90 p.sub_path, sub_path,
92 }) catch return error.NameTooLong;91 }) catch return error.NameTooLong;
93 };92 };
...@@ -95,9 +94,9 @@ pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.Ope...@@ -95,9 +94,9 @@ pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.Ope
95}94}
9695
97pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat {96pub 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;
99 const joined_path = if (p.sub_path.len == 0) sub_path else p: {98 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}", .{
101 p.sub_path, sub_path,100 p.sub_path, sub_path,
102 }) catch return error.NameTooLong;101 }) catch return error.NameTooLong;
103 };102 };
...@@ -108,21 +107,21 @@ pub fn atomicFile(...@@ -108,21 +107,21 @@ pub fn atomicFile(
108 p: Path,107 p: Path,
109 io: Io,108 io: Io,
110 sub_path: []const u8,109 sub_path: []const u8,
111 options: Io.Dir.AtomicFileOptions,110 options: Io.Dir.CreateFileAtomicOptions,
112 buf: *[fs.max_path_bytes]u8,111 buf: *[Io.Dir.max_path_bytes]u8,
113) !fs.AtomicFile {112) !Io.File.Atomic {
114 const joined_path = if (p.sub_path.len == 0) sub_path else p: {113 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}", .{
116 p.sub_path, sub_path,115 p.sub_path, sub_path,
117 }) catch return error.NameTooLong;116 }) catch return error.NameTooLong;
118 };117 };
119 return p.root_dir.handle.atomicFile(io, joined_path, options);118 return p.root_dir.handle.createFileAtomic(io, joined_path, options);
120}119}
121120
122pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void {121pub 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;
124 const joined_path = if (p.sub_path.len == 0) sub_path else p: {123 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}", .{
126 p.sub_path, sub_path,125 p.sub_path, sub_path,
127 }) catch return error.NameTooLong;126 }) catch return error.NameTooLong;
128 };127 };
...@@ -130,9 +129,9 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions...@@ -130,9 +129,9 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions
130}129}
131130
132pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void {131pub 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;
134 const joined_path = if (p.sub_path.len == 0) sub_path else p: {133 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}", .{
136 p.sub_path, sub_path,135 p.sub_path, sub_path,
137 }) catch return error.NameTooLong;136 }) catch return error.NameTooLong;
138 };137 };
...@@ -154,7 +153,7 @@ pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) {...@@ -154,7 +153,7 @@ pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) {
154pub fn formatEscapeString(path: Path, writer: *Io.Writer) Io.Writer.Error!void {153pub fn formatEscapeString(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
155 if (path.root_dir.path) |p| {154 if (path.root_dir.path) |p| {
156 try std.zig.stringEscape(p, writer);155 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);
158 }157 }
159 if (path.sub_path.len > 0) {158 if (path.sub_path.len > 0) {
160 try std.zig.stringEscape(path.sub_path, writer);159 try std.zig.stringEscape(path.sub_path, writer);
...@@ -170,7 +169,7 @@ pub fn fmtEscapeChar(path: Path) std.fmt.Alt(Path, formatEscapeChar) {...@@ -170,7 +169,7 @@ pub fn fmtEscapeChar(path: Path) std.fmt.Alt(Path, formatEscapeChar) {
170pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void {169pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
171 if (path.root_dir.path) |p| {170 if (path.root_dir.path) |p| {
172 for (p) |byte| try std.zig.charEscape(byte, writer);171 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);
174 }173 }
175 if (path.sub_path.len > 0) {174 if (path.sub_path.len > 0) {
176 for (path.sub_path) |byte| try std.zig.charEscape(byte, writer);175 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 {...@@ -178,14 +177,14 @@ pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void {
178}177}
179178
180pub fn format(self: Path, writer: *Io.Writer) Io.Writer.Error!void {179pub 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)) {
182 try writer.writeAll(self.sub_path);181 try writer.writeAll(self.sub_path);
183 return;182 return;
184 }183 }
185 if (self.root_dir.path) |p| {184 if (self.root_dir.path) |p| {
186 try writer.writeAll(p);185 try writer.writeAll(p);
187 if (self.sub_path.len > 0) {186 if (self.sub_path.len > 0) {
188 try writer.writeAll(fs.path.sep_str);187 try writer.writeAll(Io.Dir.path.sep_str);
189 try writer.writeAll(self.sub_path);188 try writer.writeAll(self.sub_path);
190 }189 }
191 return;190 return;
...@@ -210,18 +209,18 @@ pub fn subPathOrDot(self: Path) []const u8 {...@@ -210,18 +209,18 @@ pub fn subPathOrDot(self: Path) []const u8 {
210}209}
211210
212pub fn stem(p: Path) []const u8 {211pub fn stem(p: Path) []const u8 {
213 return fs.path.stem(p.sub_path);212 return Io.Dir.path.stem(p.sub_path);
214}213}
215214
216pub fn dirname(p: Path) ?Path {215pub fn dirname(p: Path) ?Path {
217 return .{216 return .{
218 .root_dir = p.root_dir,217 .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 "",
220 };219 };
221}220}
222221
223pub fn basename(p: Path) []const u8 {222pub fn basename(p: Path) []const u8 {
224 return fs.path.basename(p.sub_path);223 return Io.Dir.path.basename(p.sub_path);
225}224}
226225
227/// Useful to make `Path` a key in `std.ArrayHashMap`.226/// Useful to make `Path` a key in `std.ArrayHashMap`.
lib/std/Build/Configuration.zig-8
...@@ -2219,14 +2219,6 @@ pub const TargetQuery = struct {...@@ -2219,14 +2219,6 @@ pub const TargetQuery = struct {
2219 windows: std.Target.Os.WindowsVersion,2219 windows: std.Target.Os.WindowsVersion,
2220 default: void,2220 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
2230 pub fn unwrap(this: @This(), c: *const Configuration) ?std.Target.Query.OsVersion {2222 pub fn unwrap(this: @This(), c: *const Configuration) ?std.Target.Query.OsVersion {
2231 return switch (this) {2223 return switch (this) {
2232 .none => .none,2224 .none => .none,
lib/std/Build/Step/Compile.zig+2-8
...@@ -573,7 +573,7 @@ pub fn setVersionScript(compile: *Compile, source: LazyPath) void {...@@ -573,7 +573,7 @@ pub fn setVersionScript(compile: *Compile, source: LazyPath) void {
573573
574pub fn forceUndefinedSymbol(compile: *Compile, symbol_name: []const u8) void {574pub fn forceUndefinedSymbol(compile: *Compile, symbol_name: []const u8) void {
575 const graph = compile.step.owner.graph;575 const graph = compile.step.owner.graph;
576 const arena = graph.allocator;576 const arena = graph.arena;
577 compile.force_undefined_symbols.put(arena, graph.dupeString(symbol_name), {}) catch @panic("OOM");577 compile.force_undefined_symbols.put(arena, graph.dupeString(symbol_name), {}) catch @panic("OOM");
578}578}
579579
...@@ -710,12 +710,6 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath {...@@ -710,12 +710,6 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath {
710 return compile.getEmittedFileGeneric(&compile.generated_pdb);710 return compile.getEmittedFileGeneric(&compile.generated_pdb);
711}711}
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
719/// Returns the path to the generated documentation directory.713/// Returns the path to the generated documentation directory.
720pub fn getEmittedDocs(compile: *Compile) LazyPath {714pub fn getEmittedDocs(compile: *Compile) LazyPath {
721 return compile.getEmittedFileGeneric(&compile.generated_docs);715 return compile.getEmittedFileGeneric(&compile.generated_docs);
...@@ -740,7 +734,7 @@ pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {...@@ -740,7 +734,7 @@ pub fn setExecCmd(compile: *Compile, args: []const ?[]const u8) void {
740 const graph = compile.step.owner.graph;734 const graph = compile.step.owner.graph;
741 const arena = graph.arena;735 const arena = graph.arena;
742 assert(compile.kind == .@"test");736 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");
744 for (args, 0..) |arg, i| {738 for (args, 0..) |arg, i| {
745 duped_args[i] = if (arg) |a| graph.dupeString(a) else null;739 duped_args[i] = if (arg) |a| graph.dupeString(a) else null;
746 }740 }
lib/std/Build/Step/ObjCopy.zig+2-2
...@@ -89,7 +89,7 @@ pub const UpdateSectionOptions = struct {...@@ -89,7 +89,7 @@ pub const UpdateSectionOptions = struct {
89};89};
9090
91pub fn updateSection(oc: *ObjCopy, section_name: []const u8, options: UpdateSectionOptions) void {91pub fn updateSection(oc: *ObjCopy, section_name: []const u8, options: UpdateSectionOptions) void {
92 const graph = oc.owner.graph;92 const graph = oc.step.owner.graph;
93 const arena = graph.arena;93 const arena = graph.arena;
94 const wc = &graph.wip_configuration;94 const wc = &graph.wip_configuration;
95 oc.update_sections.append(arena, .{95 oc.update_sections.append(arena, .{
...@@ -106,7 +106,7 @@ pub const AddSectionOptions = struct {...@@ -106,7 +106,7 @@ pub const AddSectionOptions = struct {
106};106};
107107
108pub fn addSection(oc: *ObjCopy, section_name: []const u8, options: AddSectionOptions) void {108pub fn addSection(oc: *ObjCopy, section_name: []const u8, options: AddSectionOptions) void {
109 const graph = oc.owner.graph;109 const graph = oc.step.owner.graph;
110 const arena = graph.arena;110 const arena = graph.arena;
111 const wc = &graph.wip_configuration;111 const wc = &graph.wip_configuration;
112 oc.add_sections.append(arena, .{112 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 {...@@ -421,8 +421,8 @@ pub fn addOptionPath(options: *Options, name: []const u8, path: LazyPath) void {
421 const wc = &graph.wip_configuration;421 const wc = &graph.wip_configuration;
422422
423 options.args.append(arena, .{423 options.args.append(arena, .{
424 .name = try wc.addString(name),424 .name = wc.addString(name) catch @panic("OOM"),
425 .path = path.dupe(options.step.owner),425 .path = path.dupe(options.step.owner.graph),
426 }) catch @panic("OOM");426 }) catch @panic("OOM");
427 path.addStepDependencies(&options.step);427 path.addStepDependencies(&options.step);
428}428}
lib/std/Build/Step/Run.zig-33
...@@ -556,39 +556,6 @@ pub fn clearEnvironment(run: *Run) void {...@@ -556,39 +556,6 @@ pub fn clearEnvironment(run: *Run) void {
556 run.environ_map = new_env_map;556 run.environ_map = new_env_map;
557}557}
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
592pub fn getEnvMap(run: *Run) *EnvMap {559pub fn getEnvMap(run: *Run) *EnvMap {
593 return getEnvMapInternal(run);560 return getEnvMapInternal(run);
594}561}