aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
Diffstat (limited to 'src/link')
-rw-r--r--src/link/C.zig4
-rw-r--r--src/link/Coff.zig6
-rw-r--r--src/link/Elf.zig4
-rw-r--r--src/link/Lld.zig4
-rw-r--r--src/link/MachO.zig14
-rw-r--r--src/link/MachO/CodeSignature.zig2
-rw-r--r--src/link/SpirV.zig3
-rw-r--r--src/link/Wasm.zig4
8 files changed, 25 insertions, 16 deletions
diff --git a/src/link/C.zig b/src/link/C.zig
index 04c92443e5..a001f8fdd9 100644
--- a/src/link/C.zig
+++ b/src/link/C.zig
@@ -136,7 +136,7 @@ pub fn createEmpty(
assert(!use_lld);
assert(!use_llvm);
- const file = try emit.root_dir.handle.createFile(emit.sub_path, .{
+ const file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{
// Truncation is done on `flush`.
.truncate = false,
});
@@ -792,7 +792,7 @@ pub fn flushEmitH(zcu: *Zcu) !void {
}
const directory = emit_h.loc.directory orelse zcu.comp.local_cache_directory;
- const file = try directory.handle.createFile(emit_h.loc.basename, .{
+ const file = try directory.handle.createFile(io, emit_h.loc.basename, .{
// We set the end position explicitly below; by not truncating the file, we possibly
// make it easier on the file system by doing 1 reallocation instead of two.
.truncate = false,
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index e1d52fb7c4..009e59ed0d 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -631,12 +631,14 @@ fn create(
else => return error.UnsupportedCOFFArchitecture,
};
+ const io = comp.io;
+
const coff = try arena.create(Coff);
- const file = try path.root_dir.handle.createFile(comp.io, path.sub_path, .{
+ const file = try path.root_dir.handle.createFile(io, path.sub_path, .{
.read = true,
.mode = link.File.determineMode(comp.config.output_mode, comp.config.link_mode),
});
- errdefer file.close(comp.io);
+ errdefer file.close(io);
coff.* = .{
.base = .{
.tag = .coff2,
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 584a50c7f2..53812a37ec 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -313,9 +313,11 @@ pub fn createEmpty(
const is_obj = output_mode == .Obj;
const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static);
+ const io = comp.io;
+
// What path should this ELF linker code output to?
const sub_path = emit.sub_path;
- self.base.file = try emit.root_dir.handle.createFile(sub_path, .{
+ self.base.file = try emit.root_dir.handle.createFile(io, sub_path, .{
.truncate = true,
.read = true,
.mode = link.File.determineMode(output_mode, link_mode),
diff --git a/src/link/Lld.zig b/src/link/Lld.zig
index 49f6d3f7c7..b25b9da9d9 100644
--- a/src/link/Lld.zig
+++ b/src/link/Lld.zig
@@ -1572,7 +1572,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void {
// report a nice error here with the file path if it fails instead of
// just returning the error code.
// chmod does not interact with umask, so we use a conservative -rwxr--r-- here.
- std.posix.fchmodat(fs.cwd().fd, full_out_path, 0o744, 0) catch |err| switch (err) {
+ std.posix.fchmodat(Io.Dir.cwd().handle, full_out_path, 0o744, 0) catch |err| switch (err) {
error.OperationNotSupported => unreachable, // Not a symlink.
else => |e| return e,
};
@@ -1624,7 +1624,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi
const rand_int = std.crypto.random.int(u64);
const rsp_path = "tmp" ++ s ++ std.fmt.hex(rand_int) ++ ".rsp";
- const rsp_file = try comp.dirs.local_cache.handle.createFile(rsp_path, .{});
+ const rsp_file = try comp.dirs.local_cache.handle.createFile(io, rsp_path, .{});
defer comp.dirs.local_cache.handle.deleteFileZ(rsp_path) catch |err|
log.warn("failed to delete response file {s}: {s}", .{ rsp_path, @errorName(err) });
{
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index e837cc853a..0f6127e10e 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -219,7 +219,9 @@ pub fn createEmpty(
};
errdefer self.base.destroy();
- self.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{
+ const io = comp.io;
+
+ self.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{
.truncate = true,
.read = true,
.mode = link.File.determineMode(output_mode, link_mode),
@@ -1082,7 +1084,7 @@ fn accessLibPath(
test_path.clearRetainingCapacity();
try test_path.print("{s}" ++ sep ++ "lib{s}{s}", .{ search_dir, name, ext });
try checked_paths.append(try arena.dupe(u8, test_path.items));
- fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
+ Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
@@ -1110,7 +1112,7 @@ fn accessFrameworkPath(
ext,
});
try checked_paths.append(try arena.dupe(u8, test_path.items));
- fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
+ Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
@@ -1191,7 +1193,7 @@ fn parseDependentDylibs(self: *MachO) !void {
try test_path.print("{s}{s}", .{ path, ext });
}
try checked_paths.append(try arena.dupe(u8, test_path.items));
- fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
+ Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
@@ -3289,7 +3291,7 @@ pub fn reopenDebugInfo(self: *MachO) !void {
var d_sym_bundle = try self.base.emit.root_dir.handle.makeOpenPath(d_sym_path, .{});
defer d_sym_bundle.close(io);
- self.d_sym.?.file = try d_sym_bundle.createFile(fs.path.basename(self.base.emit.sub_path), .{
+ self.d_sym.?.file = try d_sym_bundle.createFile(io, fs.path.basename(self.base.emit.sub_path), .{
.truncate = false,
.read = true,
});
@@ -4370,7 +4372,7 @@ fn inferSdkVersion(comp: *Compilation, sdk_layout: SdkLayout) ?std.SemanticVersi
// The file/property is also available with vendored libc.
fn readSdkVersionFromSettings(arena: Allocator, dir: []const u8) ![]const u8 {
const sdk_path = try fs.path.join(arena, &.{ dir, "SDKSettings.json" });
- const contents = try fs.cwd().readFileAlloc(sdk_path, arena, .limited(std.math.maxInt(u16)));
+ const contents = try Io.Dir.cwd().readFileAlloc(sdk_path, arena, .limited(std.math.maxInt(u16)));
const parsed = try std.json.parseFromSlice(std.json.Value, arena, contents, .{});
if (parsed.value.object.get("MinimalDisplayName")) |ver| return ver.string;
return error.SdkVersionFailure;
diff --git a/src/link/MachO/CodeSignature.zig b/src/link/MachO/CodeSignature.zig
index 5f9a9ecac9..814faf234a 100644
--- a/src/link/MachO/CodeSignature.zig
+++ b/src/link/MachO/CodeSignature.zig
@@ -247,7 +247,7 @@ pub fn deinit(self: *CodeSignature, allocator: Allocator) void {
}
pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, path: []const u8) !void {
- const inner = try fs.cwd().readFileAlloc(path, allocator, .limited(std.math.maxInt(u32)));
+ const inner = try Io.Dir.cwd().readFileAlloc(path, allocator, .limited(std.math.maxInt(u32)));
self.entitlements = .{ .inner = inner };
}
diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig
index 7e28dc0a8b..d13caaa315 100644
--- a/src/link/SpirV.zig
+++ b/src/link/SpirV.zig
@@ -33,6 +33,7 @@ pub fn createEmpty(
options: link.File.OpenOptions,
) !*Linker {
const gpa = comp.gpa;
+ const io = comp.io;
const target = &comp.root_mod.resolved_target.result;
assert(!comp.config.use_lld); // Caught by Compilation.Config.resolve
@@ -78,7 +79,7 @@ pub fn createEmpty(
};
errdefer linker.deinit();
- linker.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{
+ linker.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{
.truncate = true,
.read = true,
});
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 7ab1e0eb4b..5f89625d56 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -2997,7 +2997,9 @@ pub fn createEmpty(
.named => |name| (try wasm.internString(name)).toOptional(),
};
- wasm.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{
+ const io = comp.io;
+
+ wasm.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{
.truncate = true,
.read = true,
.mode = if (fs.has_executable_bit)