authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-24 12:19:41-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-24 12:22:00-08:00
log3e174ee1ac8f43fa612da6630267990569b48480
tree580c9e95d09c2e92d24250030375b964ed0cfe07
parentd3f4e9d4ac9772d0916fc6c33145789054532ea4

frontend: fix data race with mingw crt files


1 files changed, 7 insertions(+), 1 deletions(-)

src/mingw.zig+7-1
...@@ -266,12 +266,16 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -266,12 +266,16 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
266266
267 if (try man.hit()) {267 if (try man.hit()) {
268 const digest = man.final();268 const digest = man.final();
269 const sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
270 errdefer gpa.free(sub_path);
269271
272 comp.mutex.lock();
273 defer comp.mutex.unlock();
270 try comp.crt_files.ensureUnusedCapacity(gpa, 1);274 try comp.crt_files.ensureUnusedCapacity(gpa, 1);
271 comp.crt_files.putAssumeCapacityNoClobber(final_lib_basename, .{275 comp.crt_files.putAssumeCapacityNoClobber(final_lib_basename, .{
272 .full_object_path = .{276 .full_object_path = .{
273 .root_dir = comp.global_cache_directory,277 .root_dir = comp.global_cache_directory,
274 .sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename }),278 .sub_path = sub_path,
275 },279 },
276 .lock = man.toOwnedLock(),280 .lock = man.toOwnedLock(),
277 });281 });
...@@ -360,6 +364,8 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -360,6 +364,8 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
360 log.warn("failed to write cache manifest for DLL import {s}.lib: {s}", .{ lib_name, @errorName(err) });364 log.warn("failed to write cache manifest for DLL import {s}.lib: {s}", .{ lib_name, @errorName(err) });
361 };365 };
362366
367 comp.mutex.lock();
368 defer comp.mutex.unlock();
363 try comp.crt_files.putNoClobber(gpa, final_lib_basename, .{369 try comp.crt_files.putNoClobber(gpa, final_lib_basename, .{
364 .full_object_path = .{370 .full_object_path = .{
365 .root_dir = comp.global_cache_directory,371 .root_dir = comp.global_cache_directory,