diff options
Diffstat (limited to 'src/link/MachO.zig')
| -rw-r--r-- | src/link/MachO.zig | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index cc488b7541..6731f88e43 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -258,7 +258,7 @@ pub fn createEmpty( const index: File.Index = @intCast(try self.files.addOne(gpa)); self.files.set(index, .{ .zig_object = .{ .index = index, - .path = try std.fmt.allocPrint(arena, "{s}.o", .{std.fs.path.stem( + .path = try std.fmt.allocPrint(arena, "{s}.o", .{fs.path.stem( zcu.main_mod.root_src_path, )}), } }); @@ -843,7 +843,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { } for (self.frameworks) |framework| { - const name = std.fs.path.stem(framework.path); + const name = fs.path.stem(framework.path); const arg = if (framework.needed) try std.fmt.allocPrint(arena, "-needed_framework {s}", .{name}) else if (framework.weak) @@ -917,7 +917,7 @@ pub const ParseError = error{ NotSupported, Unhandled, UnknownFileType, -} || std.os.SeekError || std.fs.File.OpenError || std.fs.File.ReadError || tapi.TapiError; +} || fs.File.SeekError || fs.File.OpenError || fs.File.ReadError || tapi.TapiError; pub fn parsePositional(self: *MachO, path: []const u8, must_link: bool) ParseError!void { const tracy = trace(@src()); @@ -956,7 +956,7 @@ fn parseObject(self: *MachO, path: []const u8) ParseError!void { defer tracy.end(); const gpa = self.base.comp.gpa; - const file = try std.fs.cwd().openFile(path, .{}); + const file = try fs.cwd().openFile(path, .{}); const handle = try self.addFileHandle(file); const mtime: u64 = mtime: { const stat = file.stat() catch break :mtime 0; @@ -992,7 +992,7 @@ fn parseArchive(self: *MachO, lib: SystemLib, must_link: bool, fat_arch: ?fat.Ar const gpa = self.base.comp.gpa; - const file = try std.fs.cwd().openFile(lib.path, .{}); + const file = try fs.cwd().openFile(lib.path, .{}); const handle = try self.addFileHandle(file); var archive = Archive{}; @@ -1029,7 +1029,7 @@ fn parseDylib(self: *MachO, lib: SystemLib, explicit: bool, fat_arch: ?fat.Arch) const gpa = self.base.comp.gpa; - const file = try std.fs.cwd().openFile(lib.path, .{}); + const file = try fs.cwd().openFile(lib.path, .{}); defer file.close(); const index = @as(File.Index, @intCast(try self.files.addOne(gpa))); @@ -1054,7 +1054,7 @@ fn parseTbd(self: *MachO, lib: SystemLib, explicit: bool) ParseError!File.Index defer tracy.end(); const gpa = self.base.comp.gpa; - const file = try std.fs.cwd().openFile(lib.path, .{}); + const file = try fs.cwd().openFile(lib.path, .{}); defer file.close(); var lib_stub = LibStub.loadFromFile(gpa, file) catch return error.MalformedTbd; // TODO actually handle different errors @@ -1080,10 +1080,10 @@ fn parseTbd(self: *MachO, lib: SystemLib, explicit: bool) ParseError!File.Index /// image unless overriden by -no_implicit_dylibs. fn isHoisted(self: *MachO, install_name: []const u8) bool { if (self.no_implicit_dylibs) return true; - if (std.fs.path.dirname(install_name)) |dirname| { + if (fs.path.dirname(install_name)) |dirname| { if (mem.startsWith(u8, dirname, "/usr/lib")) return true; if (eatPrefix(dirname, "/System/Library/Frameworks/")) |path| { - const basename = std.fs.path.basename(install_name); + const basename = fs.path.basename(install_name); if (mem.indexOfScalar(u8, path, '.')) |index| { if (mem.eql(u8, basename, path[0..index])) return true; } @@ -1105,7 +1105,7 @@ fn accessLibPath( test_path.clearRetainingCapacity(); try test_path.writer().print("{s}" ++ sep ++ "lib{s}{s}", .{ search_dir, name, ext }); try checked_paths.append(try arena.dupe(u8, test_path.items)); - std.fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { + fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { error.FileNotFound => continue, else => |e| return e, }; @@ -1133,7 +1133,7 @@ fn accessFrameworkPath( ext, }); try checked_paths.append(try arena.dupe(u8, test_path.items)); - std.fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { + fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { error.FileNotFound => continue, else => |e| return e, }; @@ -1181,7 +1181,7 @@ fn parseDependentDylibs(self: *MachO) !void { const full_path = full_path: { { - const stem = std.fs.path.stem(id.name); + const stem = fs.path.stem(id.name); // Framework for (framework_dirs) |dir| { @@ -1197,18 +1197,18 @@ fn parseDependentDylibs(self: *MachO) !void { } } - if (std.fs.path.isAbsolute(id.name)) { - const existing_ext = std.fs.path.extension(id.name); + if (fs.path.isAbsolute(id.name)) { + const existing_ext = fs.path.extension(id.name); const path = if (existing_ext.len > 0) id.name[0 .. id.name.len - existing_ext.len] else id.name; for (&[_][]const u8{ ".tbd", ".dylib", "" }) |ext| { test_path.clearRetainingCapacity(); if (self.base.comp.sysroot) |root| { - try test_path.writer().print("{s}" ++ std.fs.path.sep_str ++ "{s}{s}", .{ root, path, ext }); + try test_path.writer().print("{s}" ++ fs.path.sep_str ++ "{s}{s}", .{ root, path, ext }); } else { try test_path.writer().print("{s}{s}", .{ path, ext }); } try checked_paths.append(try arena.dupe(u8, test_path.items)); - std.fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { + fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { error.FileNotFound => continue, else => |e| return e, }; @@ -1220,10 +1220,10 @@ fn parseDependentDylibs(self: *MachO) !void { const dylib = self.getFile(dylib_index).?.dylib; for (self.getFile(dylib.umbrella).?.dylib.rpaths.keys()) |rpath| { const prefix = eatPrefix(rpath, "@loader_path/") orelse rpath; - const rel_path = try std.fs.path.join(arena, &.{ prefix, path }); + const rel_path = try fs.path.join(arena, &.{ prefix, path }); try checked_paths.append(rel_path); - var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; - const full_path = std.fs.realpath(rel_path, &buffer) catch continue; + var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; + const full_path = fs.realpath(rel_path, &buffer) catch continue; break :full_path try arena.dupe(u8, full_path); } } else if (eatPrefix(id.name, "@loader_path/")) |_| { @@ -1235,8 +1235,8 @@ fn parseDependentDylibs(self: *MachO) !void { } try checked_paths.append(try arena.dupe(u8, id.name)); - var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; - if (std.fs.realpath(id.name, &buffer)) |full_path| { + var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; + if (fs.realpath(id.name, &buffer)) |full_path| { break :full_path try arena.dupe(u8, full_path); } else |_| { try self.reportMissingDependencyError( @@ -3651,7 +3651,7 @@ pub fn getTarget(self: MachO) std.Target { /// into a new inode, remove the original file, and rename the copy to match /// the original file. This is super messy, but there doesn't seem any other /// way to please the XNU. -pub fn invalidateKernelCache(dir: std.fs.Dir, sub_path: []const u8) !void { +pub fn invalidateKernelCache(dir: fs.Dir, sub_path: []const u8) !void { if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) { try dir.copyFile(sub_path, dir, sub_path, .{}); } @@ -3839,7 +3839,7 @@ pub fn getInternalObject(self: *MachO) ?*InternalObject { return self.getFile(index).?.internal; } -pub fn addFileHandle(self: *MachO, file: std.fs.File) !File.HandleIndex { +pub fn addFileHandle(self: *MachO, file: fs.File) !File.HandleIndex { const gpa = self.base.comp.gpa; const index: File.HandleIndex = @intCast(self.file_handles.items.len); const fh = try self.file_handles.addOne(gpa); @@ -4530,7 +4530,7 @@ fn inferSdkVersion(comp: *Compilation, sdk_layout: SdkLayout) ?std.SemanticVersi const sdk_dir = switch (sdk_layout) { .sdk => comp.sysroot.?, - .vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null, + .vendored => fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null, }; if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| { return parseSdkVersion(ver); @@ -4541,7 +4541,7 @@ fn inferSdkVersion(comp: *Compilation, sdk_layout: SdkLayout) ?std.SemanticVersi } // infer from pathname - const stem = std.fs.path.stem(sdk_dir); + const stem = fs.path.stem(sdk_dir); const start = for (stem, 0..) |c, i| { if (std.ascii.isDigit(c)) break i; } else stem.len; @@ -4556,8 +4556,8 @@ fn inferSdkVersion(comp: *Compilation, sdk_layout: SdkLayout) ?std.SemanticVersi // Use property `MinimalDisplayName` to determine version. // The file/property is also available with vendored libc. fn readSdkVersionFromSettings(arena: Allocator, dir: []const u8) ![]const u8 { - const sdk_path = try std.fs.path.join(arena, &.{ dir, "SDKSettings.json" }); - const contents = try std.fs.cwd().readFileAlloc(arena, sdk_path, std.math.maxInt(u16)); + const sdk_path = try fs.path.join(arena, &.{ dir, "SDKSettings.json" }); + const contents = try fs.cwd().readFileAlloc(arena, sdk_path, 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; |
