@@ -3681,13 +3681,15 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
36813681 break :digest digest ;
36823682 } else man .final ();
36833683
3684- // Write the updated manifest. This is a no-op if the manifest is not dirty. Note that it is
3685- // possible we had a hit and the manifest is dirty, for example if the file mtime changed but
3686- // the contents were the same, we hit the cache but the manifest is dirty and we need to update
3687- // it to prevent doing a full file content comparison the next time around.
3688- man .writeManifest () catch | err | {
3689- log .warn ("failed to write cache manifest for C import: {s}" , .{@errorName (err )});
3690- };
3684+ if (man .have_exclusive_lock ) {
3685+ // Write the updated manifest. This is a no-op if the manifest is not dirty. Note that it is
3686+ // possible we had a hit and the manifest is dirty, for example if the file mtime changed but
3687+ // the contents were the same, we hit the cache but the manifest is dirty and we need to update
3688+ // it to prevent doing a full file content comparison the next time around.
3689+ man .writeManifest () catch | err | {
3690+ log .warn ("failed to write cache manifest for C import: {s}" , .{@errorName (err )});
3691+ };
3692+ }
36913693
36923694 const out_zig_path = try comp .local_cache_directory .join (comp .gpa , &[_ ][]const u8 {
36933695 "o" , & digest , cimport_zig_basename ,
@@ -4086,13 +4088,15 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
40864088 break :blk digest ;
40874089 };
40884090
4089- // Write the updated manifest. This is a no-op if the manifest is not dirty. Note that it is
4090- // possible we had a hit and the manifest is dirty, for example if the file mtime changed but
4091- // the contents were the same, we hit the cache but the manifest is dirty and we need to update
4092- // it to prevent doing a full file content comparison the next time around.
4093- man .writeManifest () catch | err | {
4094- log .warn ("failed to write cache manifest when compiling '{s}': {s}" , .{ c_object .src .src_path , @errorName (err ) });
4095- };
4091+ if (man .have_exclusive_lock ) {
4092+ // Write the updated manifest. This is a no-op if the manifest is not dirty. Note that it is
4093+ // possible we had a hit and the manifest is dirty, for example if the file mtime changed but
4094+ // the contents were the same, we hit the cache but the manifest is dirty and we need to update
4095+ // it to prevent doing a full file content comparison the next time around.
4096+ man .writeManifest () catch | err | {
4097+ log .warn ("failed to write cache manifest when compiling '{s}': {s}" , .{ c_object .src .src_path , @errorName (err ) });
4098+ };
4099+ }
40964100
40974101 const o_basename = try std .fmt .allocPrint (arena , "{s}{s}" , .{ o_basename_noext , o_ext });
40984102
0 commit comments