Skip to content

Commit 4ab7715

Browse files
committed
self hosted compiler: avoid Dir.realpathAlloc
The use of Dir-related realpath functions will put std.os.getFdPath in the critical path which makes the compiler less portable.
1 parent 26a0467 commit 4ab7715

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Compilation.zig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,12 +4064,17 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
40644064
);
40654065

40664066
const args_dir = "args";
4067-
try output_dir.handle.makePath(args_dir);
4068-
const args_file = try fs.path.join(allocator, &[_][]const u8{
4069-
args_dir, args_hex_hash[0..],
4070-
});
4071-
try output_dir.handle.writeFile(args_file, args);
4072-
const args_file_path = try output_dir.handle.realpathAlloc(allocator, args_file);
4067+
const args_file_path = args_file_path: {
4068+
if (output_dir.path) |odp| {
4069+
break :args_file_path try fs.path.join(allocator, &[_][]const u8{
4070+
odp, args_dir, args_hex_hash[0..],
4071+
});
4072+
} else {
4073+
break :args_file_path try fs.path.join(allocator, &[_][]const u8{
4074+
args_dir, args_hex_hash[0..],
4075+
});
4076+
}
4077+
};
40734078

40744079
argv.shrinkRetainingCapacity(2);
40754080
try argv.append(try std.mem.concat(allocator, u8, &[_][]const u8{ "@", args_file_path }));

0 commit comments

Comments
 (0)