authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-14 18:27:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-19 12:39:36-07:00
log65b8b8b27bb4671443403e3d88534c0238b3c940
tree02d8e9227f7e1ff803343ed0cd260bc80f64139c
parent414641eb95cd006f4f291d259fe912885050bd2c

std.Build.Cache: remove deprecated APIs

improves Path hygiene in the compiler in some places also includes an assertion that will probably nede to be removed regarding absolute paths making it into the cache manifest

12 files changed, 75 insertions(+), 97 deletions(-)

lib/std/Build/Cache.zig+3-28
...@@ -417,19 +417,8 @@ pub const Manifest = struct {...@@ -417,19 +417,8 @@ pub const Manifest = struct {
417 return addFileInner(m, prefixed_path, handle, max_file_size);417 return addFileInner(m, prefixed_path, handle, max_file_size);
418 }418 }
419419
420 /// Deprecated; use `addFilePath`.
421 pub fn addFile(self: *Manifest, file_path: []const u8, max_file_size: ?usize) !usize {
422 assert(self.manifest_file == null);
423
424 const gpa = self.cache.gpa;
425 try self.files.ensureUnusedCapacity(gpa, 1);
426 const prefixed_path = try self.cache.findPrefix(file_path);
427 errdefer gpa.free(prefixed_path.sub_path);
428
429 return addFileInner(self, prefixed_path, null, max_file_size);
430 }
431
432 fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?Io.File, max_file_size: ?usize) usize {420 fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?Io.File, max_file_size: ?usize) usize {
421 assert(!std.fs.path.isAbsolute(prefixed_path.sub_path));
433 const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{});422 const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{});
434 if (gop.found_existing) {423 if (gop.found_existing) {
435 self.cache.gpa.free(prefixed_path.sub_path);424 self.cache.gpa.free(prefixed_path.sub_path);
...@@ -452,26 +441,12 @@ pub const Manifest = struct {...@@ -452,26 +441,12 @@ pub const Manifest = struct {
452 return gop.index;441 return gop.index;
453 }442 }
454443
455 /// Deprecated, use `addOptionalFilePath`.
456 pub fn addOptionalFile(self: *Manifest, optional_file_path: ?[]const u8) !void {
457 self.hash.add(optional_file_path != null);
458 const file_path = optional_file_path orelse return;
459 _ = try self.addFile(file_path, null);
460 }
461
462 pub fn addOptionalFilePath(self: *Manifest, optional_file_path: ?Path) !void {444 pub fn addOptionalFilePath(self: *Manifest, optional_file_path: ?Path) !void {
463 self.hash.add(optional_file_path != null);445 self.hash.add(optional_file_path != null);
464 const file_path = optional_file_path orelse return;446 const file_path = optional_file_path orelse return;
465 _ = try self.addFilePath(file_path, null);447 _ = try self.addFilePath(file_path, null);
466 }448 }
467449
468 pub fn addListOfFiles(self: *Manifest, list_of_files: []const []const u8) !void {
469 self.hash.add(list_of_files.len);
470 for (list_of_files) |file_path| {
471 _ = try self.addFile(file_path, null);
472 }
473 }
474
475 pub fn addDepFile(self: *Manifest, dir: Io.Dir, dep_file_sub_path: []const u8) !void {450 pub fn addDepFile(self: *Manifest, dir: Io.Dir, dep_file_sub_path: []const u8) !void {
476 assert(self.manifest_file == null);451 assert(self.manifest_file == null);
477 return self.addDepFileMaybePost(dir, dep_file_sub_path);452 return self.addDepFileMaybePost(dir, dep_file_sub_path);
...@@ -1127,13 +1102,13 @@ pub const Manifest = struct {...@@ -1127,13 +1102,13 @@ pub const Manifest = struct {
1127 // Clang is invoked in single-source mode but other programs may not1102 // Clang is invoked in single-source mode but other programs may not
1128 .target, .target_must_resolve => {},1103 .target, .target_must_resolve => {},
1129 .prereq => |file_path| if (self.manifest_file == null) {1104 .prereq => |file_path| if (self.manifest_file == null) {
1130 _ = try self.addFile(file_path, null);1105 _ = try self.addFilePath(.initCwd(file_path), null);
1131 } else try self.addFilePost(file_path),1106 } else try self.addFilePost(file_path),
1132 .prereq_must_resolve => {1107 .prereq_must_resolve => {
1133 resolve_buf.clearRetainingCapacity();1108 resolve_buf.clearRetainingCapacity();
1134 try token.resolve(gpa, &resolve_buf);1109 try token.resolve(gpa, &resolve_buf);
1135 if (self.manifest_file == null) {1110 if (self.manifest_file == null) {
1136 _ = try self.addFile(resolve_buf.items, null);1111 _ = try self.addFilePath(.initCwd(resolve_buf.items), null);
1137 } else try self.addFilePost(resolve_buf.items);1112 } else try self.addFilePost(resolve_buf.items);
1138 },1113 },
1139 else => |err| {1114 else => |err| {
src/Compilation.zig+17-15
...@@ -1278,7 +1278,7 @@ pub const cache_helpers = struct {...@@ -1278,7 +1278,7 @@ pub const cache_helpers = struct {
1278 }1278 }
12791279
1280 pub fn hashCSource(self: *Cache.Manifest, c_source: CSourceFile) !void {1280 pub fn hashCSource(self: *Cache.Manifest, c_source: CSourceFile) !void {
1281 _ = try self.addFile(c_source.src_path, null);1281 _ = try self.addFilePath(.initCwd(c_source.src_path), null);
1282 // Hash the extra flags, with special care to call addFile for file parameters.1282 // Hash the extra flags, with special care to call addFile for file parameters.
1283 // TODO this logic can likely be improved by utilizing clang_options_data.zig.1283 // TODO this logic can likely be improved by utilizing clang_options_data.zig.
1284 const file_args = [_][]const u8{"-include"};1284 const file_args = [_][]const u8{"-include"};
...@@ -1289,7 +1289,7 @@ pub const cache_helpers = struct {...@@ -1289,7 +1289,7 @@ pub const cache_helpers = struct {
1289 for (file_args) |file_arg| {1289 for (file_args) |file_arg| {
1290 if (mem.eql(u8, file_arg, arg) and arg_i + 1 < c_source.extra_flags.len) {1290 if (mem.eql(u8, file_arg, arg) and arg_i + 1 < c_source.extra_flags.len) {
1291 arg_i += 1;1291 arg_i += 1;
1292 _ = try self.addFile(c_source.extra_flags[arg_i], null);1292 _ = try self.addFilePath(.initCwd(c_source.extra_flags[arg_i]), null);
1293 }1293 }
1294 }1294 }
1295 }1295 }
...@@ -1466,8 +1466,8 @@ pub const CreateOptions = struct {...@@ -1466,8 +1466,8 @@ pub const CreateOptions = struct {
1466 stack_report: bool = false,1466 stack_report: bool = false,
1467 link_eh_frame_hdr: bool = false,1467 link_eh_frame_hdr: bool = false,
1468 link_emit_relocs: bool = false,1468 link_emit_relocs: bool = false,
1469 linker_script: ?[]const u8 = null,1469 linker_script: ?Cache.Path = null,
1470 version_script: ?[]const u8 = null,1470 version_script: ?Cache.Path = null,
1471 linker_allow_undefined_version: bool = false,1471 linker_allow_undefined_version: bool = false,
1472 linker_enable_new_dtags: ?bool = null,1472 linker_enable_new_dtags: ?bool = null,
1473 soname: ?[]const u8 = null,1473 soname: ?[]const u8 = null,
...@@ -1546,7 +1546,7 @@ pub const CreateOptions = struct {...@@ -1546,7 +1546,7 @@ pub const CreateOptions = struct {
1546 /// (Darwin) Install name of the dylib1546 /// (Darwin) Install name of the dylib
1547 install_name: ?[]const u8 = null,1547 install_name: ?[]const u8 = null,
1548 /// (Darwin) Path to entitlements file1548 /// (Darwin) Path to entitlements file
1549 entitlements: ?[]const u8 = null,1549 entitlements: ?Cache.Path = null,
1550 /// (Darwin) size of the __PAGEZERO segment1550 /// (Darwin) size of the __PAGEZERO segment
1551 pagezero_size: ?u64 = null,1551 pagezero_size: ?u64 = null,
1552 /// (Darwin) set minimum space for future expansion of the load commands1552 /// (Darwin) set minimum space for future expansion of the load commands
...@@ -2741,7 +2741,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE...@@ -2741,7 +2741,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
27412741
2742 // If using the whole caching strategy, we check for *everything* up front, including2742 // If using the whole caching strategy, we check for *everything* up front, including
2743 // C source files.2743 // C source files.
2744 log.debug("Compilation.update for {s}, CacheMode.{s}", .{ comp.root_name, @tagName(comp.cache_use) });2744 log.debug("Compilation.update for {s}, CacheMode.{t}", .{ comp.root_name, comp.cache_use });
2745 switch (comp.cache_use) {2745 switch (comp.cache_use) {
2746 .none => |none| {2746 .none => |none| {
2747 assert(none.tmp_artifact_directory == null);2747 assert(none.tmp_artifact_directory == null);
...@@ -2750,7 +2750,9 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE...@@ -2750,7 +2750,9 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
2750 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2750 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2751 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});2751 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});
2752 const handle = comp.dirs.local_cache.handle.createDirPathOpen(io, tmp_dir_sub_path, .{}) catch |err| {2752 const handle = comp.dirs.local_cache.handle.createDirPathOpen(io, tmp_dir_sub_path, .{}) catch |err| {
2753 return comp.setMiscFailure(.open_output, "failed to create output directory '{s}': {t}", .{ path, err });2753 return comp.setMiscFailure(.open_output, "failed to create output directory {q}: {t}", .{
2754 path, err,
2755 });
2754 };2756 };
2755 break :d .{ .path = path, .handle = handle };2757 break :d .{ .path = path, .handle = handle };
2756 };2758 };
...@@ -3336,7 +3338,7 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -3336,7 +3338,7 @@ fn addNonIncrementalStuffToCacheManifest(
3336 try link.hashInputs(man, comp.link_inputs);3338 try link.hashInputs(man, comp.link_inputs);
33373339
3338 for (comp.c_objects.items) |c_object| {3340 for (comp.c_objects.items) |c_object| {
3339 _ = try man.addFile(c_object.src.src_path, null);3341 _ = try man.addFilePath(.initCwd(c_object.src.src_path), null);
3340 man.hash.addOptional(c_object.src.ext);3342 man.hash.addOptional(c_object.src.ext);
3341 man.hash.addListOfBytes(c_object.src.extra_flags);3343 man.hash.addListOfBytes(c_object.src.extra_flags);
3342 }3344 }
...@@ -3344,11 +3346,11 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -3344,11 +3346,11 @@ fn addNonIncrementalStuffToCacheManifest(
3344 for (comp.win32_resources.items) |win32_resource| {3346 for (comp.win32_resources.items) |win32_resource| {
3345 switch (win32_resource.src) {3347 switch (win32_resource.src) {
3346 .rc => |rc_src| {3348 .rc => |rc_src| {
3347 _ = try man.addFile(rc_src.src_path, null);3349 _ = try man.addFilePath(.initCwd(rc_src.src_path), null);
3348 man.hash.addListOfBytes(rc_src.extra_flags);3350 man.hash.addListOfBytes(rc_src.extra_flags);
3349 },3351 },
3350 .manifest => |manifest_path| {3352 .manifest => |manifest_path| {
3351 _ = try man.addFile(manifest_path, null);3353 _ = try man.addFilePath(.initCwd(manifest_path), null);
3352 },3354 },
3353 }3355 }
3354 }3356 }
...@@ -3380,8 +3382,8 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -3380,8 +3382,8 @@ fn addNonIncrementalStuffToCacheManifest(
33803382
3381 const opts = comp.cache_use.whole.lf_open_opts;3383 const opts = comp.cache_use.whole.lf_open_opts;
33823384
3383 try man.addOptionalFile(opts.linker_script);3385 try man.addOptionalFilePath(opts.linker_script);
3384 try man.addOptionalFile(opts.version_script);3386 try man.addOptionalFilePath(opts.version_script);
3385 man.hash.add(opts.allow_undefined_version);3387 man.hash.add(opts.allow_undefined_version);
3386 man.hash.addOptional(opts.enable_new_dtags);3388 man.hash.addOptional(opts.enable_new_dtags);
33873389
...@@ -3440,7 +3442,7 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -3440,7 +3442,7 @@ fn addNonIncrementalStuffToCacheManifest(
34403442
3441 // Mach-O specific stuff3443 // Mach-O specific stuff
3442 try link.File.MachO.hashAddFrameworks(man, opts.frameworks);3444 try link.File.MachO.hashAddFrameworks(man, opts.frameworks);
3443 try man.addOptionalFile(opts.entitlements);3445 try man.addOptionalFilePath(opts.entitlements);
3444 man.hash.addOptional(opts.pagezero_size);3446 man.hash.addOptional(opts.pagezero_size);
3445 man.hash.addOptional(opts.headerpad_size);3447 man.hash.addOptional(opts.headerpad_size);
3446 man.hash.add(opts.headerpad_max_install_names);3448 man.hash.add(opts.headerpad_max_install_names);
...@@ -5818,7 +5820,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5818,7 +5820,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5818 // the XML data as a RT_MANIFEST resource. This means we can skip preprocessing,5820 // the XML data as a RT_MANIFEST resource. This means we can skip preprocessing,
5819 // include paths, CLI options, etc.5821 // include paths, CLI options, etc.
5820 if (win32_resource.src == .manifest) {5822 if (win32_resource.src == .manifest) {
5821 _ = try man.addFile(src_path, null);5823 _ = try man.addFilePath(.initCwd(src_path), null);
58225824
5823 const rc_basename = try std.fmt.allocPrint(arena, "{s}.rc", .{src_basename});5825 const rc_basename = try std.fmt.allocPrint(arena, "{s}.rc", .{src_basename});
5824 const res_basename = try std.fmt.allocPrint(arena, "{s}.res", .{src_basename});5826 const res_basename = try std.fmt.allocPrint(arena, "{s}.res", .{src_basename});
...@@ -5911,7 +5913,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5911,7 +5913,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5911 // We now know that we're compiling an .rc file5913 // We now know that we're compiling an .rc file
5912 const rc_src = win32_resource.src.rc;5914 const rc_src = win32_resource.src.rc;
59135915
5914 _ = try man.addFile(rc_src.src_path, null);5916 _ = try man.addFilePath(.initCwd(rc_src.src_path), null);
5915 man.hash.addListOfBytes(rc_src.extra_flags);5917 man.hash.addListOfBytes(rc_src.extra_flags);
59165918
5917 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];5919 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];
src/libs/freebsd.zig+8-4
...@@ -458,8 +458,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -458,8 +458,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
458 man.hash.add(target.abi);458 man.hash.add(target.abi);
459 man.hash.add(target_os_version);459 man.hash.add(target_os_version);
460460
461 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});461 const abilists_index = try man.addFilePath(.{
462 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);462 .root_dir = comp.dirs.zig_lib,
463 .sub_path = abilists_path,
464 }, abilists_max_size);
463465
464 if (try man.hit(prog_node)) {466 if (try man.hit(prog_node)) {
465 const digest = man.final();467 const digest = man.final();
...@@ -1044,7 +1046,6 @@ fn buildSharedLib(...@@ -1044,7 +1046,6 @@ fn buildSharedLib(
1044 const version: Version = .{ .major = sover, .minor = 0, .patch = 0 };1046 const version: Version = .{ .major = sover, .minor = 0, .patch = 0 };
1045 const ld_basename = path.basename(target.standardDynamicLinkerPath().get().?);1047 const ld_basename = path.basename(target.standardDynamicLinkerPath().get().?);
1046 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;1048 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
1047 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
10481049
1049 const optimize_mode = comp.compilerRtOptMode();1050 const optimize_mode = comp.compilerRtOptMode();
1050 const strip = comp.compilerRtStrip();1051 const strip = comp.compilerRtStrip();
...@@ -1113,7 +1114,10 @@ fn buildSharedLib(...@@ -1113,7 +1114,10 @@ fn buildSharedLib(
1113 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,1114 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
1114 .clang_passthrough_mode = comp.clang_passthrough_mode,1115 .clang_passthrough_mode = comp.clang_passthrough_mode,
1115 .version = version,1116 .version = version,
1116 .version_script = map_file_path,1117 .version_script = .{
1118 .root_dir = bin_directory,
1119 .sub_path = all_map_basename,
1120 },
1117 .soname = soname,1121 .soname = soname,
1118 .c_source_files = &c_source_files,1122 .c_source_files = &c_source_files,
1119 .skip_linker_dependencies = true,1123 .skip_linker_dependencies = true,
src/libs/glibc.zig+8-4
...@@ -698,8 +698,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -698,8 +698,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
698 man.hash.add(target.abi);698 man.hash.add(target.abi);
699 man.hash.add(target_version);699 man.hash.add(target_version);
700700
701 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});701 const abilists_index = try man.addFilePath(.{
702 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);702 .root_dir = comp.dirs.zig_lib,
703 .sub_path = abilists_path,
704 }, abilists_max_size);
703705
704 if (try man.hit(prog_node)) {706 if (try man.hit(prog_node)) {
705 const digest = man.final();707 const digest = man.final();
...@@ -1188,7 +1190,6 @@ fn buildSharedLib(...@@ -1188,7 +1190,6 @@ fn buildSharedLib(
1188 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };1190 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };
1189 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);1191 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);
1190 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;1192 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
1191 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
11921193
1193 const optimize_mode = comp.compilerRtOptMode();1194 const optimize_mode = comp.compilerRtOptMode();
1194 const strip = comp.compilerRtStrip();1195 const strip = comp.compilerRtStrip();
...@@ -1257,7 +1258,10 @@ fn buildSharedLib(...@@ -1257,7 +1258,10 @@ fn buildSharedLib(
1257 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,1258 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
1258 .clang_passthrough_mode = comp.clang_passthrough_mode,1259 .clang_passthrough_mode = comp.clang_passthrough_mode,
1259 .version = version,1260 .version = version,
1260 .version_script = map_file_path,1261 .version_script = .{
1262 .root_dir = bin_directory,
1263 .sub_path = all_map_basename,
1264 },
1261 .soname = soname,1265 .soname = soname,
1262 .c_source_files = &c_source_files,1266 .c_source_files = &c_source_files,
1263 .skip_linker_dependencies = true,1267 .skip_linker_dependencies = true,
src/libs/mingw.zig+17-28
...@@ -243,7 +243,10 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P...@@ -243,7 +243,10 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8, prog_node: std.P
243 var man = cache.obtain();243 var man = cache.obtain();
244 defer man.deinit();244 defer man.deinit();
245245
246 _ = try man.addFile(def_file_path, null);246 _ = try man.addFilePath(.{
247 .root_dir = comp.dirs.zig_lib,
248 .sub_path = def_file_path,
249 }, null);
247250
248 const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name});251 const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name});
249 errdefer gpa.free(final_lib_basename);252 errdefer gpa.free(final_lib_basename);
...@@ -384,7 +387,7 @@ pub fn libExists(...@@ -384,7 +387,7 @@ pub fn libExists(
384/// This function body is verbose but all it does is test 3 different paths and387/// This function body is verbose but all it does is test 3 different paths and
385/// see if a .def file exists.388/// see if a .def file exists.
386fn findDef(389fn findDef(
387 allocator: Allocator,390 gpa: Allocator,
388 io: Io,391 io: Io,
389 target: *const std.Target,392 target: *const std.Target,
390 zig_lib_directory: Cache.Directory,393 zig_lib_directory: Cache.Directory,
...@@ -398,21 +401,17 @@ fn findDef(...@@ -398,21 +401,17 @@ fn findDef(
398 else => unreachable,401 else => unreachable,
399 };402 };
400403
401 var override_path = std.array_list.Managed(u8).init(allocator);404 var override_path: std.ArrayList(u8) = .empty;
402 defer override_path.deinit();405 defer override_path.deinit(gpa);
403406
404 const s = path.sep_str;407 const s = path.sep_str;
405408
406 {409 {
407 // Try the archtecture-specific path first.410 // Try the archtecture-specific path first.
408 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";411 override_path.shrinkRetainingCapacity(0);
409 if (zig_lib_directory.path) |p| {412 try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def", .{ lib_path, lib_name });
410 try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });413 if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| {
411 } else {414 return override_path.toOwnedSlice(gpa);
412 try override_path.print(fmt_path, .{ lib_path, lib_name });
413 }
414 if (Io.Dir.cwd().access(io, override_path.items, .{})) |_| {
415 return override_path.toOwnedSlice();
416 } else |err| switch (err) {415 } else |err| switch (err) {
417 error.FileNotFound => {},416 error.FileNotFound => {},
418 else => |e| return e,417 else => |e| return e,
...@@ -422,14 +421,9 @@ fn findDef(...@@ -422,14 +421,9 @@ fn findDef(
422 {421 {
423 // Try the generic version.422 // Try the generic version.
424 override_path.shrinkRetainingCapacity(0);423 override_path.shrinkRetainingCapacity(0);
425 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def";424 try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def", .{lib_name});
426 if (zig_lib_directory.path) |p| {425 if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| {
427 try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_name });426 return override_path.toOwnedSlice(gpa);
428 } else {
429 try override_path.print(fmt_path, .{lib_name});
430 }
431 if (Io.Dir.cwd().access(io, override_path.items, .{})) |_| {
432 return override_path.toOwnedSlice();
433 } else |err| switch (err) {427 } else |err| switch (err) {
434 error.FileNotFound => {},428 error.FileNotFound => {},
435 else => |e| return e,429 else => |e| return e,
...@@ -439,14 +433,9 @@ fn findDef(...@@ -439,14 +433,9 @@ fn findDef(
439 {433 {
440 // Try the generic version and preprocess it.434 // Try the generic version and preprocess it.
441 override_path.shrinkRetainingCapacity(0);435 override_path.shrinkRetainingCapacity(0);
442 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";436 try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in", .{lib_name});
443 if (zig_lib_directory.path) |p| {437 if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| {
444 try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_name });438 return override_path.toOwnedSlice(gpa);
445 } else {
446 try override_path.print(fmt_path, .{lib_name});
447 }
448 if (Io.Dir.cwd().access(io, override_path.items, .{})) |_| {
449 return override_path.toOwnedSlice();
450 } else |err| switch (err) {439 } else |err| switch (err) {
451 error.FileNotFound => {},440 error.FileNotFound => {},
452 else => |e| return e,441 else => |e| return e,
src/libs/netbsd.zig+4-2
...@@ -406,8 +406,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -406,8 +406,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
406 man.hash.add(target.abi);406 man.hash.add(target.abi);
407 man.hash.add(target_version);407 man.hash.add(target_version);
408408
409 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});409 const abilists_index = try man.addFilePath(.{
410 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);410 .root_dir = comp.dirs.zig_lib,
411 .sub_path = abilists_path,
412 }, abilists_max_size);
411413
412 if (try man.hit(prog_node)) {414 if (try man.hit(prog_node)) {
413 const digest = man.final();415 const digest = man.final();
src/libs/openbsd.zig+4-2
...@@ -327,8 +327,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -327,8 +327,10 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
327 man.hash.add(target.abi);327 man.hash.add(target.abi);
328 man.hash.add(target_version);328 man.hash.add(target_version);
329329
330 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});330 const abilists_index = try man.addFilePath(.{
331 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);331 .root_dir = comp.dirs.zig_lib,
332 .sub_path = abilists_path,
333 }, abilists_max_size);
332334
333 if (try man.hit(prog_node)) {335 if (try man.hit(prog_node)) {
334 const digest = man.final();336 const digest = man.final();
src/link.zig+3-3
...@@ -461,8 +461,8 @@ pub const File = struct {...@@ -461,8 +461,8 @@ pub const File = struct {
461 allow_undefined_version: bool,461 allow_undefined_version: bool,
462 enable_new_dtags: ?bool,462 enable_new_dtags: ?bool,
463 subsystem: ?std.zig.Subsystem,463 subsystem: ?std.zig.Subsystem,
464 linker_script: ?[]const u8,464 linker_script: ?Path,
465 version_script: ?[]const u8,465 version_script: ?Path,
466 soname: ?[]const u8,466 soname: ?[]const u8,
467 print_gc_sections: bool,467 print_gc_sections: bool,
468 print_icf_sections: bool,468 print_icf_sections: bool,
...@@ -493,7 +493,7 @@ pub const File = struct {...@@ -493,7 +493,7 @@ pub const File = struct {
493 /// Install name for the dylib493 /// Install name for the dylib
494 install_name: ?[]const u8,494 install_name: ?[]const u8,
495 /// Path to entitlements file495 /// Path to entitlements file
496 entitlements: ?[]const u8,496 entitlements: ?Path,
497 /// size of the __PAGEZERO segment497 /// size of the __PAGEZERO segment
498 pagezero_size: ?u64,498 pagezero_size: ?u64,
499 /// Set minimum space for future expansion of the load commands499 /// Set minimum space for future expansion of the load commands
src/link/Lld.zig+4-4
...@@ -75,8 +75,8 @@ pub const Elf = struct {...@@ -75,8 +75,8 @@ pub const Elf = struct {
75 entry_name: ?[]const u8,75 entry_name: ?[]const u8,
76 hash_style: HashStyle,76 hash_style: HashStyle,
77 image_base: u64,77 image_base: u64,
78 linker_script: ?[]const u8,78 linker_script: ?Cache.Path,
79 version_script: ?[]const u8,79 version_script: ?Cache.Path,
80 sort_section: ?SortSection,80 sort_section: ?SortSection,
81 print_icf_sections: bool,81 print_icf_sections: bool,
82 print_map: bool,82 print_map: bool,
...@@ -930,7 +930,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {...@@ -930,7 +930,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
930930
931 if (elf.linker_script) |linker_script| {931 if (elf.linker_script) |linker_script| {
932 try argv.append("-T");932 try argv.append("-T");
933 try argv.append(linker_script);933 try argv.append(try linker_script.toString(arena));
934 }934 }
935935
936 if (elf.sort_section) |how| {936 if (elf.sort_section) |how| {
...@@ -1086,7 +1086,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {...@@ -1086,7 +1086,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
1086 }1086 }
1087 if (elf.version_script) |version_script| {1087 if (elf.version_script) |version_script| {
1088 try argv.append("-version-script");1088 try argv.append("-version-script");
1089 try argv.append(version_script);1089 try argv.append(try version_script.toString(arena));
1090 }1090 }
1091 if (elf.allow_undefined_version) {1091 if (elf.allow_undefined_version) {
1092 try argv.append("--undefined-version");1092 try argv.append("--undefined-version");
src/link/MachO.zig+2-2
...@@ -127,7 +127,7 @@ frameworks: []const Framework,...@@ -127,7 +127,7 @@ frameworks: []const Framework,
127/// TODO: unify with soname127/// TODO: unify with soname
128install_name: ?[]const u8,128install_name: ?[]const u8,
129/// Path to entitlements file.129/// Path to entitlements file.
130entitlements: ?[]const u8,130entitlements: ?Path,
131compatibility_version: ?std.SemanticVersion,131compatibility_version: ?std.SemanticVersion,
132/// Entry name132/// Entry name
133entry_name: ?[]const u8,133entry_name: ?[]const u8,
...@@ -580,7 +580,7 @@ pub fn flush(...@@ -580,7 +580,7 @@ pub fn flush(
580 var codesig = CodeSignature.init(self.getPageSize());580 var codesig = CodeSignature.init(self.getPageSize());
581 codesig.code_directory.ident = fs.path.basename(self.base.emit.sub_path);581 codesig.code_directory.ident = fs.path.basename(self.base.emit.sub_path);
582 if (self.entitlements) |path| codesig.addEntitlements(gpa, io, path) catch |err|582 if (self.entitlements) |path| codesig.addEntitlements(gpa, io, path) catch |err|
583 return diags.fail("failed to add entitlements from {s}: {t}", .{ path, err });583 return diags.fail("failed to add entitlements from {f}: {t}", .{ path, err });
584 try self.writeCodeSignaturePadding(&codesig);584 try self.writeCodeSignaturePadding(&codesig);
585 break :blk codesig;585 break :blk codesig;
586 } else null;586 } else null;
src/link/MachO/CodeSignature.zig+2-2
...@@ -246,8 +246,8 @@ pub fn deinit(self: *CodeSignature, allocator: Allocator) void {...@@ -246,8 +246,8 @@ pub fn deinit(self: *CodeSignature, allocator: Allocator) void {
246 }246 }
247}247}
248248
249pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, io: Io, path: []const u8) !void {249pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, io: Io, path: std.Build.Cache.Path) !void {
250 const inner = try Io.Dir.cwd().readFileAlloc(io, path, allocator, .limited(std.math.maxInt(u32)));250 const inner = try path.root_dir.handle.readFileAlloc(io, path.sub_path, allocator, .limited(std.math.maxInt(u32)));
251 self.entitlements = .{ .inner = inner };251 self.entitlements = .{ .inner = inner };
252}252}
253253
src/main.zig+3-3
...@@ -3666,8 +3666,8 @@ fn buildOutputType(...@@ -3666,8 +3666,8 @@ fn buildOutputType(
3666 .want_compiler_rt = if (zig_cc_explicitly_link_compiler_rt) true else want_compiler_rt,3666 .want_compiler_rt = if (zig_cc_explicitly_link_compiler_rt) true else want_compiler_rt,
3667 .want_ubsan_rt = want_ubsan_rt,3667 .want_ubsan_rt = want_ubsan_rt,
3668 .hash_style = hash_style,3668 .hash_style = hash_style,
3669 .linker_script = linker_script,3669 .linker_script = if (linker_script) |p| .initCwd(p) else null,
3670 .version_script = version_script,3670 .version_script = if (version_script) |p| .initCwd(p) else null,
3671 .linker_allow_undefined_version = linker_allow_undefined_version,3671 .linker_allow_undefined_version = linker_allow_undefined_version,
3672 .linker_enable_new_dtags = linker_enable_new_dtags,3672 .linker_enable_new_dtags = linker_enable_new_dtags,
3673 .disable_c_depfile = disable_c_depfile,3673 .disable_c_depfile = disable_c_depfile,
...@@ -3740,7 +3740,7 @@ fn buildOutputType(...@@ -3740,7 +3740,7 @@ fn buildOutputType(
3740 .debug_incremental = debug_incremental,3740 .debug_incremental = debug_incremental,
3741 .enable_link_snapshots = enable_link_snapshots,3741 .enable_link_snapshots = enable_link_snapshots,
3742 .install_name = install_name,3742 .install_name = install_name,
3743 .entitlements = entitlements,3743 .entitlements = if (entitlements) |p| .initCwd(p) else null,
3744 .pagezero_size = pagezero_size,3744 .pagezero_size = pagezero_size,
3745 .headerpad_size = headerpad_size,3745 .headerpad_size = headerpad_size,
3746 .headerpad_max_install_names = headerpad_max_install_names,3746 .headerpad_max_install_names = headerpad_max_install_names,