commit 0c8bf405ebeab9b1c72ca31b4f066189d74048d0 (tree)
parent ebd0776b28c50169936b58f8ba05be70e854fd35
Author: Michael Dusan <michael.dusan@gmail.com>
Date: Tue, 26 Sep 2023 07:51:32 -0400
kubkon review changes: 4
- fix `darwin_sdk_layout.?` with null checks
Diffstat:
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
@@ -652,7 +652,7 @@ pub fn resolveLibSystem(
"libSystem",
)) break :success;
- switch (self.base.options.darwin_sdk_layout.?) {
+ if (self.base.options.darwin_sdk_layout) |sdk_layout| switch (sdk_layout) {
.sdk => {
const dir = try fs.path.join(tmp_arena, &[_][]const u8{ self.base.options.sysroot.?, "usr", "lib" });
if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;
@@ -661,7 +661,7 @@ pub fn resolveLibSystem(
const dir = try comp.zig_lib_directory.join(tmp_arena, &[_][]const u8{ "libc", "darwin" });
if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;
},
- }
+ };
try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});
return;
diff --git a/src/link/MachO/load_commands.zig b/src/link/MachO/load_commands.zig
@@ -474,7 +474,7 @@ pub fn inferSdkVersion(gpa: Allocator, comp: *const Compilation) ?std.SemanticVe
const options = comp.bin_file.options;
- const sdk_layout = options.darwin_sdk_layout.?;
+ const sdk_layout = options.darwin_sdk_layout orelse return null;
const sdk_dir = switch (sdk_layout) {
.sdk => options.sysroot.?,
.vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null,
@@ -482,7 +482,7 @@ pub fn inferSdkVersion(gpa: Allocator, comp: *const Compilation) ?std.SemanticVe
if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| {
return parseSdkVersion(ver);
} else |_| {
- // We control vendored and reading settings should always succeed.
+ // Read from settings should always succeed when vendored.
if (sdk_layout == .vendored) @panic("zig installation bug: unable to parse SDK version");
}