Skip to content

Commit

Permalink
frontend: add logging to help troubleshoot builtin.zig write failures
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Dec 29, 2023
1 parent 19e9ecc commit 0ca3db0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,25 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {

fn writeFile(file: *File, mod: *Module) !void {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf);
var af = mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf) catch |err| {
std.log.warn("unable to create builtin atomic file '{}{s}'", .{
mod.root, mod.root_src_path,
});
return err;
};
defer af.deinit();
try af.file.writeAll(file.source);
try af.finish();
af.file.writeAll(file.source) catch |err| {
std.log.warn("unable to write builtin file data to '{}{s}'", .{
mod.root, mod.root_src_path,
});
return err;
};
af.finish() catch |err| {
std.log.warn("unable to rename atomic builtin file into '{}{s}'", .{
mod.root, mod.root_src_path,
});
return err;
};

file.stat = .{
.size = file.source.len,
Expand Down

0 comments on commit 0ca3db0

Please sign in to comment.