| ... | @@ -507,6 +507,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -507,6 +507,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 507 | const allow_undef = is_dyn_lib and (self.base.options.allow_shlib_undefined orelse false); | 507 | const allow_undef = is_dyn_lib and (self.base.options.allow_shlib_undefined orelse false); |
| 508 | | 508 | |
| 509 | const id_symlink_basename = "zld.id"; | 509 | const id_symlink_basename = "zld.id"; |
| | 510 | const cache_dir_handle = blk: { |
| | 511 | if (use_stage1) { |
| | 512 | break :blk directory.handle; |
| | 513 | } |
| | 514 | if (self.base.options.module) |module| { |
| | 515 | break :blk module.zig_cache_artifact_directory.handle; |
| | 516 | } |
| | 517 | break :blk directory.handle; |
| | 518 | }; |
| 510 | | 519 | |
| 511 | var man: Cache.Manifest = undefined; | 520 | var man: Cache.Manifest = undefined; |
| 512 | defer if (!self.base.options.disable_lld_caching) man.deinit(); | 521 | defer if (!self.base.options.disable_lld_caching) man.deinit(); |
| ... | @@ -552,7 +561,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -552,7 +561,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 552 | | 561 | |
| 553 | var prev_digest_buf: [digest.len]u8 = undefined; | 562 | var prev_digest_buf: [digest.len]u8 = undefined; |
| 554 | const prev_digest: []u8 = Cache.readSmallFile( | 563 | const prev_digest: []u8 = Cache.readSmallFile( |
| 555 | directory.handle, | 564 | cache_dir_handle, |
| 556 | id_symlink_basename, | 565 | id_symlink_basename, |
| 557 | &prev_digest_buf, | 566 | &prev_digest_buf, |
| 558 | ) catch |err| blk: { | 567 | ) catch |err| blk: { |
| ... | @@ -588,7 +597,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -588,7 +597,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 588 | }); | 597 | }); |
| 589 | | 598 | |
| 590 | // We are about to change the output file to be different, so we invalidate the build hash now. | 599 | // We are about to change the output file to be different, so we invalidate the build hash now. |
| 591 | directory.handle.deleteFile(id_symlink_basename) catch |err| switch (err) { | 600 | cache_dir_handle.deleteFile(id_symlink_basename) catch |err| switch (err) { |
| 592 | error.FileNotFound => {}, | 601 | error.FileNotFound => {}, |
| 593 | else => |e| return e, | 602 | else => |e| return e, |
| 594 | }; | 603 | }; |
| ... | @@ -621,7 +630,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -621,7 +630,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 621 | } else { | 630 | } else { |
| 622 | if (use_stage1) { | 631 | if (use_stage1) { |
| 623 | const sub_path = self.base.options.emit.?.sub_path; | 632 | const sub_path = self.base.options.emit.?.sub_path; |
| 624 | self.base.file = try directory.handle.createFile(sub_path, .{ | 633 | self.base.file = try cache_dir_handle.createFile(sub_path, .{ |
| 625 | .truncate = true, | 634 | .truncate = true, |
| 626 | .read = true, | 635 | .read = true, |
| 627 | .mode = link.determineMode(self.base.options), | 636 | .mode = link.determineMode(self.base.options), |
| ... | @@ -1080,7 +1089,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -1080,7 +1089,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 1080 | if (use_stage1 and self.base.options.disable_lld_caching) break :cache; | 1089 | if (use_stage1 and self.base.options.disable_lld_caching) break :cache; |
| 1081 | // Update the file with the digest. If it fails we can continue; it only | 1090 | // Update the file with the digest. If it fails we can continue; it only |
| 1082 | // means that the next invocation will have an unnecessary cache miss. | 1091 | // means that the next invocation will have an unnecessary cache miss. |
| 1083 | Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| { | 1092 | Cache.writeSmallFile(cache_dir_handle, id_symlink_basename, &digest) catch |err| { |
| 1084 | log.debug("failed to save linking hash digest file: {s}", .{@errorName(err)}); | 1093 | log.debug("failed to save linking hash digest file: {s}", .{@errorName(err)}); |
| 1085 | }; | 1094 | }; |
| 1086 | // Again failure here only means an unnecessary cache miss. | 1095 | // Again failure here only means an unnecessary cache miss. |