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