mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
Compilation: close the linker output file before writing whole cache manifest
Otherwise a different process may get a cache hit on the file while we still have a writable fd open for it. This isn't actually a real problem in the sense that running the file should just work as expected if the OS allows it. But until very recently[0], the Linux kernel would give ETXTBSY in this case. So make sure we close the file before letting other processes know that it's usable. closes https://codeberg.org/ziglang/zig/issues/31563 [0] https://github.com/torvalds/linux/commit/2a010c41285345da60cece35575b4e0af7e7bf44
This commit is contained in:
+5
-5
@@ -3230,16 +3230,16 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
|
||||
// cache manifest must not be written.
|
||||
if (anyErrors(comp)) return;
|
||||
|
||||
// Failure here only means an unnecessary cache miss.
|
||||
man.writeManifest() catch |err| {
|
||||
log.warn("failed to write cache manifest: {s}", .{@errorName(err)});
|
||||
};
|
||||
|
||||
if (comp.bin_file) |lf| {
|
||||
lf.destroy();
|
||||
comp.bin_file = null;
|
||||
}
|
||||
|
||||
// Failure here only means an unnecessary cache miss.
|
||||
man.writeManifest() catch |err| {
|
||||
log.warn("failed to write cache manifest: {s}", .{@errorName(err)});
|
||||
};
|
||||
|
||||
assert(whole.lock == null);
|
||||
whole.lock = man.toOwnedLock();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user