| ... | ... | @@ -452,6 +452,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 452 | 452 | const allow_undef = is_dyn_lib and (self.base.options.allow_shlib_undefined orelse false); |
| 453 | 453 | |
| 454 | 454 | const id_symlink_basename = "zld.id"; |
| 455 | const cache_dir_handle = blk: { |
| 456 | if (use_stage1) { |
| 457 | break :blk directory.handle; |
| 458 | } |
| 459 | if (self.base.options.module) |module| { |
| 460 | break :blk module.zig_cache_artifact_directory.handle; |
| 461 | } |
| 462 | break :blk directory.handle; |
| 463 | }; |
| 455 | 464 | |
| 456 | 465 | var man: Cache.Manifest = undefined; |
| 457 | 466 | defer if (!self.base.options.disable_lld_caching) man.deinit(); |
| ... | ... | @@ -495,7 +504,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 495 | 504 | |
| 496 | 505 | var prev_digest_buf: [digest.len]u8 = undefined; |
| 497 | 506 | const prev_digest: []u8 = Cache.readSmallFile( |
| 498 | | directory.handle, |
| 507 | cache_dir_handle, |
| 499 | 508 | id_symlink_basename, |
| 500 | 509 | &prev_digest_buf, |
| 501 | 510 | ) catch |err| blk: { |
| ... | ... | @@ -531,7 +540,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 531 | 540 | }); |
| 532 | 541 | |
| 533 | 542 | // We are about to change the output file to be different, so we invalidate the build hash now. |
| 534 | | directory.handle.deleteFile(id_symlink_basename) catch |err| switch (err) { |
| 543 | cache_dir_handle.deleteFile(id_symlink_basename) catch |err| switch (err) { |
| 535 | 544 | error.FileNotFound => {}, |
| 536 | 545 | else => |e| return e, |
| 537 | 546 | }; |
| ... | ... | @@ -565,7 +574,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 565 | 574 | } else { |
| 566 | 575 | if (use_stage1) { |
| 567 | 576 | const sub_path = self.base.options.emit.?.sub_path; |
| 568 | | self.base.file = try directory.handle.createFile(sub_path, .{ |
| 577 | self.base.file = try cache_dir_handle.createFile(sub_path, .{ |
| 569 | 578 | .truncate = true, |
| 570 | 579 | .read = true, |
| 571 | 580 | .mode = link.determineMode(self.base.options), |
| ... | ... | @@ -1025,7 +1034,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 1025 | 1034 | if (use_stage1 and self.base.options.disable_lld_caching) break :cache; |
| 1026 | 1035 | // Update the file with the digest. If it fails we can continue; it only |
| 1027 | 1036 | // means that the next invocation will have an unnecessary cache miss. |
| 1028 | | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { |
| 1037 | Cache.writeSmallFile(cache_dir_handle, id_symlink_basename, &digest) catch |err| { |
| 1029 | 1038 | log.debug("failed to save linking hash digest file: {s}", .{@errorName(err)}); |
| 1030 | 1039 | }; |
| 1031 | 1040 | // Again failure here only means an unnecessary cache miss. |