kubkon review changes: 4

- fix `darwin_sdk_layout.?` with null checks
This commit is contained in:
Michael Dusan 2023-09-26 07:51:32 -04:00
parent ebd0776b28
commit 0c8bf405eb
No known key found for this signature in database
GPG Key ID: ED4C5BA849FA1B74
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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");
}