| author | |
| committer | |
| log | 65b8b8b27bb4671443403e3d88534c0238b3c940 |
| tree | 02d8e9227f7e1ff803343ed0cd260bc80f64139c |
| parent | 414641eb95cd006f4f291d259fe912885050bd2c |
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 manifest12 files changed, 75 insertions(+), 97 deletions(-)
lib/std/Build/Cache.zig+3-28| ... | ... | @@ -417,19 +417,8 @@ pub const Manifest = struct { |
| 417 | 417 | return addFileInner(m, prefixed_path, handle, max_file_size); |
| 418 | 418 | } |
| 419 | 419 | |
| 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 | 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 | 422 | const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{}); |
| 434 | 423 | if (gop.found_existing) { |
| 435 | 424 | self.cache.gpa.free(prefixed_path.sub_path); |
| ... | ... | @@ -452,26 +441,12 @@ pub const Manifest = struct { |
| 452 | 441 | return gop.index; |
| 453 | 442 | } |
| 454 | 443 | |
| 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 | 444 | pub fn addOptionalFilePath(self: *Manifest, optional_file_path: ?Path) !void { |
| 463 | 445 | self.hash.add(optional_file_path != null); |
| 464 | 446 | const file_path = optional_file_path orelse return; |
| 465 | 447 | _ = try self.addFilePath(file_path, null); |
| 466 | 448 | } |
| 467 | 449 | |
| 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 | 450 | pub fn addDepFile(self: *Manifest, dir: Io.Dir, dep_file_sub_path: []const u8) !void { |
| 476 | 451 | assert(self.manifest_file == null); |
| 477 | 452 | return self.addDepFileMaybePost(dir, dep_file_sub_path); |
| ... | ... | @@ -1127,13 +1102,13 @@ pub const Manifest = struct { |
| 1127 | 1102 | // Clang is invoked in single-source mode but other programs may not |
| 1128 | 1103 | .target, .target_must_resolve => {}, |
| 1129 | 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 | 1106 | } else try self.addFilePost(file_path), |
| 1132 | 1107 | .prereq_must_resolve => { |
| 1133 | 1108 | resolve_buf.clearRetainingCapacity(); |
| 1134 | 1109 | try token.resolve(gpa, &resolve_buf); |
| 1135 | 1110 | if (self.manifest_file == null) { |
| 1136 | _ = try self.addFile(resolve_buf.items, null); | |
| 1111 | _ = try self.addFilePath(.initCwd(resolve_buf.items), null); | |
| 1137 | 1112 | } else try self.addFilePost(resolve_buf.items); |
| 1138 | 1113 | }, |
| 1139 | 1114 | else => |err| { |
src/Compilation.zig+17-15| ... | ... | @@ -1278,7 +1278,7 @@ pub const cache_helpers = struct { |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 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 | 1282 | // Hash the extra flags, with special care to call addFile for file parameters. |
| 1283 | 1283 | // TODO this logic can likely be improved by utilizing clang_options_data.zig. |
| 1284 | 1284 | const file_args = [_][]const u8{"-include"}; |
| ... | ... | @@ -1289,7 +1289,7 @@ pub const cache_helpers = struct { |
| 1289 | 1289 | for (file_args) |file_arg| { |
| 1290 | 1290 | if (mem.eql(u8, file_arg, arg) and arg_i + 1 < c_source.extra_flags.len) { |
| 1291 | 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 | 1466 | stack_report: bool = false, |
| 1467 | 1467 | link_eh_frame_hdr: bool = false, |
| 1468 | 1468 | link_emit_relocs: bool = false, |
| 1469 | linker_script: ?[]const u8 = null, | |
| 1470 | version_script: ?[]const u8 = null, | |
| 1469 | linker_script: ?Cache.Path = null, | |
| 1470 | version_script: ?Cache.Path = null, | |
| 1471 | 1471 | linker_allow_undefined_version: bool = false, |
| 1472 | 1472 | linker_enable_new_dtags: ?bool = null, |
| 1473 | 1473 | soname: ?[]const u8 = null, |
| ... | ... | @@ -1546,7 +1546,7 @@ pub const CreateOptions = struct { |
| 1546 | 1546 | /// (Darwin) Install name of the dylib |
| 1547 | 1547 | install_name: ?[]const u8 = null, |
| 1548 | 1548 | /// (Darwin) Path to entitlements file |
| 1549 | entitlements: ?[]const u8 = null, | |
| 1549 | entitlements: ?Cache.Path = null, | |
| 1550 | 1550 | /// (Darwin) size of the __PAGEZERO segment |
| 1551 | 1551 | pagezero_size: ?u64 = null, |
| 1552 | 1552 | /// (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 | 2741 | |
| 2742 | 2742 | // If using the whole caching strategy, we check for *everything* up front, including |
| 2743 | 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 | 2745 | switch (comp.cache_use) { |
| 2746 | 2746 | .none => |none| { |
| 2747 | 2747 | assert(none.tmp_artifact_directory == null); |
| ... | ... | @@ -2750,7 +2750,9 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 2750 | 2750 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int); |
| 2751 | 2751 | const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path}); |
| 2752 | 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 | 2757 | break :d .{ .path = path, .handle = handle }; |
| 2756 | 2758 | }; |
| ... | ... | @@ -3336,7 +3338,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 3336 | 3338 | try link.hashInputs(man, comp.link_inputs); |
| 3337 | 3339 | |
| 3338 | 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 | 3342 | man.hash.addOptional(c_object.src.ext); |
| 3341 | 3343 | man.hash.addListOfBytes(c_object.src.extra_flags); |
| 3342 | 3344 | } |
| ... | ... | @@ -3344,11 +3346,11 @@ fn addNonIncrementalStuffToCacheManifest( |
| 3344 | 3346 | for (comp.win32_resources.items) |win32_resource| { |
| 3345 | 3347 | switch (win32_resource.src) { |
| 3346 | 3348 | .rc => |rc_src| { |
| 3347 | _ = try man.addFile(rc_src.src_path, null); | |
| 3349 | _ = try man.addFilePath(.initCwd(rc_src.src_path), null); | |
| 3348 | 3350 | man.hash.addListOfBytes(rc_src.extra_flags); |
| 3349 | 3351 | }, |
| 3350 | 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 | 3382 | |
| 3381 | 3383 | const opts = comp.cache_use.whole.lf_open_opts; |
| 3382 | 3384 | |
| 3383 | try man.addOptionalFile(opts.linker_script); | |
| 3384 | try man.addOptionalFile(opts.version_script); | |
| 3385 | try man.addOptionalFilePath(opts.linker_script); | |
| 3386 | try man.addOptionalFilePath(opts.version_script); | |
| 3385 | 3387 | man.hash.add(opts.allow_undefined_version); |
| 3386 | 3388 | man.hash.addOptional(opts.enable_new_dtags); |
| 3387 | 3389 | |
| ... | ... | @@ -3440,7 +3442,7 @@ fn addNonIncrementalStuffToCacheManifest( |
| 3440 | 3442 | |
| 3441 | 3443 | // Mach-O specific stuff |
| 3442 | 3444 | try link.File.MachO.hashAddFrameworks(man, opts.frameworks); |
| 3443 | try man.addOptionalFile(opts.entitlements); | |
| 3445 | try man.addOptionalFilePath(opts.entitlements); | |
| 3444 | 3446 | man.hash.addOptional(opts.pagezero_size); |
| 3445 | 3447 | man.hash.addOptional(opts.headerpad_size); |
| 3446 | 3448 | man.hash.add(opts.headerpad_max_install_names); |
| ... | ... | @@ -5818,7 +5820,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 5818 | 5820 | // the XML data as a RT_MANIFEST resource. This means we can skip preprocessing, |
| 5819 | 5821 | // include paths, CLI options, etc. |
| 5820 | 5822 | if (win32_resource.src == .manifest) { |
| 5821 | _ = try man.addFile(src_path, null); | |
| 5823 | _ = try man.addFilePath(.initCwd(src_path), null); | |
| 5822 | 5824 | |
| 5823 | 5825 | const rc_basename = try std.fmt.allocPrint(arena, "{s}.rc", .{src_basename}); |
| 5824 | 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 | 5913 | // We now know that we're compiling an .rc file |
| 5912 | 5914 | const rc_src = win32_resource.src.rc; |
| 5913 | 5915 | |
| 5914 | _ = try man.addFile(rc_src.src_path, null); | |
| 5916 | _ = try man.addFilePath(.initCwd(rc_src.src_path), null); | |
| 5915 | 5917 | man.hash.addListOfBytes(rc_src.extra_flags); |
| 5916 | 5918 | |
| 5917 | 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 | 458 | man.hash.add(target.abi); |
| 459 | 459 | man.hash.add(target_os_version); |
| 460 | 460 | |
| 461 | const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path}); | |
| 462 | const abilists_index = try man.addFile(full_abilists_path, abilists_max_size); | |
| 461 | const abilists_index = try man.addFilePath(.{ | |
| 462 | .root_dir = comp.dirs.zig_lib, | |
| 463 | .sub_path = abilists_path, | |
| 464 | }, abilists_max_size); | |
| 463 | 465 | |
| 464 | 466 | if (try man.hit(prog_node)) { |
| 465 | 467 | const digest = man.final(); |
| ... | ... | @@ -1044,7 +1046,6 @@ fn buildSharedLib( |
| 1044 | 1046 | const version: Version = .{ .major = sover, .minor = 0, .patch = 0 }; |
| 1045 | 1047 | const ld_basename = path.basename(target.standardDynamicLinkerPath().get().?); |
| 1046 | 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 }); | |
| 1048 | 1049 | |
| 1049 | 1050 | const optimize_mode = comp.compilerRtOptMode(); |
| 1050 | 1051 | const strip = comp.compilerRtStrip(); |
| ... | ... | @@ -1113,7 +1114,10 @@ fn buildSharedLib( |
| 1113 | 1114 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 1114 | 1115 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 1115 | 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 | 1121 | .soname = soname, |
| 1118 | 1122 | .c_source_files = &c_source_files, |
| 1119 | 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 | 698 | man.hash.add(target.abi); |
| 699 | 699 | man.hash.add(target_version); |
| 700 | 700 | |
| 701 | const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path}); | |
| 702 | const abilists_index = try man.addFile(full_abilists_path, abilists_max_size); | |
| 701 | const abilists_index = try man.addFilePath(.{ | |
| 702 | .root_dir = comp.dirs.zig_lib, | |
| 703 | .sub_path = abilists_path, | |
| 704 | }, abilists_max_size); | |
| 703 | 705 | |
| 704 | 706 | if (try man.hit(prog_node)) { |
| 705 | 707 | const digest = man.final(); |
| ... | ... | @@ -1188,7 +1190,6 @@ fn buildSharedLib( |
| 1188 | 1190 | const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 }; |
| 1189 | 1191 | const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?); |
| 1190 | 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 }); | |
| 1192 | 1193 | |
| 1193 | 1194 | const optimize_mode = comp.compilerRtOptMode(); |
| 1194 | 1195 | const strip = comp.compilerRtStrip(); |
| ... | ... | @@ -1257,7 +1258,10 @@ fn buildSharedLib( |
| 1257 | 1258 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 1258 | 1259 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 1259 | 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 | 1265 | .soname = soname, |
| 1262 | 1266 | .c_source_files = &c_source_files, |
| 1263 | 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 | 243 | var man = cache.obtain(); |
| 244 | 244 | defer man.deinit(); |
| 245 | 245 | |
| 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); | |
| 247 | 250 | |
| 248 | 251 | const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name}); |
| 249 | 252 | errdefer gpa.free(final_lib_basename); |
| ... | ... | @@ -384,7 +387,7 @@ pub fn libExists( |
| 384 | 387 | /// This function body is verbose but all it does is test 3 different paths and |
| 385 | 388 | /// see if a .def file exists. |
| 386 | 389 | fn findDef( |
| 387 | allocator: Allocator, | |
| 390 | gpa: Allocator, | |
| 388 | 391 | io: Io, |
| 389 | 392 | target: *const std.Target, |
| 390 | 393 | zig_lib_directory: Cache.Directory, |
| ... | ... | @@ -398,21 +401,17 @@ fn findDef( |
| 398 | 401 | else => unreachable, |
| 399 | 402 | }; |
| 400 | 403 | |
| 401 | var override_path = std.array_list.Managed(u8).init(allocator); | |
| 402 | defer override_path.deinit(); | |
| 404 | var override_path: std.ArrayList(u8) = .empty; | |
| 405 | defer override_path.deinit(gpa); | |
| 403 | 406 | |
| 404 | 407 | const s = path.sep_str; |
| 405 | 408 | |
| 406 | 409 | { |
| 407 | 410 | // Try the archtecture-specific path first. |
| 408 | const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def"; | |
| 409 | if (zig_lib_directory.path) |p| { | |
| 410 | try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name }); | |
| 411 | } else { | |
| 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(); | |
| 411 | override_path.shrinkRetainingCapacity(0); | |
| 412 | try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def", .{ lib_path, lib_name }); | |
| 413 | if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| { | |
| 414 | return override_path.toOwnedSlice(gpa); | |
| 416 | 415 | } else |err| switch (err) { |
| 417 | 416 | error.FileNotFound => {}, |
| 418 | 417 | else => |e| return e, |
| ... | ... | @@ -422,14 +421,9 @@ fn findDef( |
| 422 | 421 | { |
| 423 | 422 | // Try the generic version. |
| 424 | 423 | override_path.shrinkRetainingCapacity(0); |
| 425 | const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def"; | |
| 426 | if (zig_lib_directory.path) |p| { | |
| 427 | try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_name }); | |
| 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(); | |
| 424 | try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def", .{lib_name}); | |
| 425 | if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| { | |
| 426 | return override_path.toOwnedSlice(gpa); | |
| 433 | 427 | } else |err| switch (err) { |
| 434 | 428 | error.FileNotFound => {}, |
| 435 | 429 | else => |e| return e, |
| ... | ... | @@ -439,14 +433,9 @@ fn findDef( |
| 439 | 433 | { |
| 440 | 434 | // Try the generic version and preprocess it. |
| 441 | 435 | override_path.shrinkRetainingCapacity(0); |
| 442 | const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in"; | |
| 443 | if (zig_lib_directory.path) |p| { | |
| 444 | try override_path.print("{s}" ++ s ++ fmt_path, .{ p, lib_name }); | |
| 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(); | |
| 436 | try override_path.print(gpa, "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in", .{lib_name}); | |
| 437 | if (zig_lib_directory.handle.access(io, override_path.items, .{})) |_| { | |
| 438 | return override_path.toOwnedSlice(gpa); | |
| 450 | 439 | } else |err| switch (err) { |
| 451 | 440 | error.FileNotFound => {}, |
| 452 | 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 | 406 | man.hash.add(target.abi); |
| 407 | 407 | man.hash.add(target_version); |
| 408 | 408 | |
| 409 | const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path}); | |
| 410 | const abilists_index = try man.addFile(full_abilists_path, abilists_max_size); | |
| 409 | const abilists_index = try man.addFilePath(.{ | |
| 410 | .root_dir = comp.dirs.zig_lib, | |
| 411 | .sub_path = abilists_path, | |
| 412 | }, abilists_max_size); | |
| 411 | 413 | |
| 412 | 414 | if (try man.hit(prog_node)) { |
| 413 | 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 | 327 | man.hash.add(target.abi); |
| 328 | 328 | man.hash.add(target_version); |
| 329 | 329 | |
| 330 | const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path}); | |
| 331 | const abilists_index = try man.addFile(full_abilists_path, abilists_max_size); | |
| 330 | const abilists_index = try man.addFilePath(.{ | |
| 331 | .root_dir = comp.dirs.zig_lib, | |
| 332 | .sub_path = abilists_path, | |
| 333 | }, abilists_max_size); | |
| 332 | 334 | |
| 333 | 335 | if (try man.hit(prog_node)) { |
| 334 | 336 | const digest = man.final(); |
src/link.zig+3-3| ... | ... | @@ -461,8 +461,8 @@ pub const File = struct { |
| 461 | 461 | allow_undefined_version: bool, |
| 462 | 462 | enable_new_dtags: ?bool, |
| 463 | 463 | subsystem: ?std.zig.Subsystem, |
| 464 | linker_script: ?[]const u8, | |
| 465 | version_script: ?[]const u8, | |
| 464 | linker_script: ?Path, | |
| 465 | version_script: ?Path, | |
| 466 | 466 | soname: ?[]const u8, |
| 467 | 467 | print_gc_sections: bool, |
| 468 | 468 | print_icf_sections: bool, |
| ... | ... | @@ -493,7 +493,7 @@ pub const File = struct { |
| 493 | 493 | /// Install name for the dylib |
| 494 | 494 | install_name: ?[]const u8, |
| 495 | 495 | /// Path to entitlements file |
| 496 | entitlements: ?[]const u8, | |
| 496 | entitlements: ?Path, | |
| 497 | 497 | /// size of the __PAGEZERO segment |
| 498 | 498 | pagezero_size: ?u64, |
| 499 | 499 | /// 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 | 75 | entry_name: ?[]const u8, |
| 76 | 76 | hash_style: HashStyle, |
| 77 | 77 | image_base: u64, |
| 78 | linker_script: ?[]const u8, | |
| 79 | version_script: ?[]const u8, | |
| 78 | linker_script: ?Cache.Path, | |
| 79 | version_script: ?Cache.Path, | |
| 80 | 80 | sort_section: ?SortSection, |
| 81 | 81 | print_icf_sections: bool, |
| 82 | 82 | print_map: bool, |
| ... | ... | @@ -930,7 +930,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 930 | 930 | |
| 931 | 931 | if (elf.linker_script) |linker_script| { |
| 932 | 932 | try argv.append("-T"); |
| 933 | try argv.append(linker_script); | |
| 933 | try argv.append(try linker_script.toString(arena)); | |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | if (elf.sort_section) |how| { |
| ... | ... | @@ -1086,7 +1086,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 1086 | 1086 | } |
| 1087 | 1087 | if (elf.version_script) |version_script| { |
| 1088 | 1088 | try argv.append("-version-script"); |
| 1089 | try argv.append(version_script); | |
| 1089 | try argv.append(try version_script.toString(arena)); | |
| 1090 | 1090 | } |
| 1091 | 1091 | if (elf.allow_undefined_version) { |
| 1092 | 1092 | try argv.append("--undefined-version"); |
src/link/MachO.zig+2-2| ... | ... | @@ -127,7 +127,7 @@ frameworks: []const Framework, |
| 127 | 127 | /// TODO: unify with soname |
| 128 | 128 | install_name: ?[]const u8, |
| 129 | 129 | /// Path to entitlements file. |
| 130 | entitlements: ?[]const u8, | |
| 130 | entitlements: ?Path, | |
| 131 | 131 | compatibility_version: ?std.SemanticVersion, |
| 132 | 132 | /// Entry name |
| 133 | 133 | entry_name: ?[]const u8, |
| ... | ... | @@ -580,7 +580,7 @@ pub fn flush( |
| 580 | 580 | var codesig = CodeSignature.init(self.getPageSize()); |
| 581 | 581 | codesig.code_directory.ident = fs.path.basename(self.base.emit.sub_path); |
| 582 | 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 | 584 | try self.writeCodeSignaturePadding(&codesig); |
| 585 | 585 | break :blk codesig; |
| 586 | 586 | } else null; |
src/link/MachO/CodeSignature.zig+2-2| ... | ... | @@ -246,8 +246,8 @@ pub fn deinit(self: *CodeSignature, allocator: Allocator) void { |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, io: Io, path: []const u8) !void { | |
| 250 | const inner = try Io.Dir.cwd().readFileAlloc(io, path, allocator, .limited(std.math.maxInt(u32))); | |
| 249 | pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, io: Io, path: std.Build.Cache.Path) !void { | |
| 250 | const inner = try path.root_dir.handle.readFileAlloc(io, path.sub_path, allocator, .limited(std.math.maxInt(u32))); | |
| 251 | 251 | self.entitlements = .{ .inner = inner }; |
| 252 | 252 | } |
| 253 | 253 |
src/main.zig+3-3| ... | ... | @@ -3666,8 +3666,8 @@ fn buildOutputType( |
| 3666 | 3666 | .want_compiler_rt = if (zig_cc_explicitly_link_compiler_rt) true else want_compiler_rt, |
| 3667 | 3667 | .want_ubsan_rt = want_ubsan_rt, |
| 3668 | 3668 | .hash_style = hash_style, |
| 3669 | .linker_script = linker_script, | |
| 3670 | .version_script = version_script, | |
| 3669 | .linker_script = if (linker_script) |p| .initCwd(p) else null, | |
| 3670 | .version_script = if (version_script) |p| .initCwd(p) else null, | |
| 3671 | 3671 | .linker_allow_undefined_version = linker_allow_undefined_version, |
| 3672 | 3672 | .linker_enable_new_dtags = linker_enable_new_dtags, |
| 3673 | 3673 | .disable_c_depfile = disable_c_depfile, |
| ... | ... | @@ -3740,7 +3740,7 @@ fn buildOutputType( |
| 3740 | 3740 | .debug_incremental = debug_incremental, |
| 3741 | 3741 | .enable_link_snapshots = enable_link_snapshots, |
| 3742 | 3742 | .install_name = install_name, |
| 3743 | .entitlements = entitlements, | |
| 3743 | .entitlements = if (entitlements) |p| .initCwd(p) else null, | |
| 3744 | 3744 | .pagezero_size = pagezero_size, |
| 3745 | 3745 | .headerpad_size = headerpad_size, |
| 3746 | 3746 | .headerpad_max_install_names = headerpad_max_install_names, |