Commit d0f675827c

Andrew Kelley <andrew@ziglang.org>
2023-03-02 06:55:47
link: only write manifest if we have the exclusive lock
Fixes assertion tripping when racing multiple processes that will create the same static archive.
1 parent b465dc1
Changed files (1)
src/link.zig
@@ -1078,9 +1078,11 @@ pub const File = struct {
                 log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)});
             };
 
-            man.writeManifest() catch |err| {
-                log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
-            };
+            if (man.have_exclusive_lock) {
+                man.writeManifest() catch |err| {
+                    log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
+                };
+            }
 
             base.lock = man.toOwnedLock();
         }