authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-09-25 15:51:57-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-09-25 17:07:41-04:00
logebd0776b28c50169936b58f8ba05be70e854fd35
treeedaccbd6332b18897db92748ec7d3c2a20baf808
parentf6877fbc4905b1bcd582415baebf3329725a1a43
signaturelock-open Commit is signed but in an unrecognized format.

kubkon review changes: 3

- make vendored settings failure unreachable - rename field `darwinSdkLayout` → `darwin_sdk_layout` - make `darwin_sdk_layout` optional

4 files changed, 14 insertions(+), 20 deletions(-)

src/Compilation.zig+8-8
......@@ -1557,7 +1557,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
15571557 .link_libc = link_libc,
15581558 .link_libcpp = link_libcpp,
15591559 .link_libunwind = link_libunwind,
1560 .darwinSdkLayout = libc_dirs.darwinSdkLayout,
1560 .darwin_sdk_layout = libc_dirs.darwin_sdk_layout,
15611561 .objects = options.link_objects,
15621562 .frameworks = options.frameworks,
15631563 .framework_dirs = options.framework_dirs,
......@@ -5287,7 +5287,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD
52875287 .libc_installation = null,
52885288 .libc_framework_dir_list = &.{},
52895289 .sysroot = null,
5290 .darwinSdkLayout = .none,
5290 .darwin_sdk_layout = null,
52915291 },
52925292 }
52935293 }
......@@ -5656,7 +5656,7 @@ const LibCDirs = struct {
56565656 libc_installation: ?*const LibCInstallation,
56575657 libc_framework_dir_list: []const []const u8,
56585658 sysroot: ?[]const u8,
5659 darwinSdkLayout: link.DarwinSdkLayout,
5659 darwin_sdk_layout: ?link.DarwinSdkLayout,
56605660};
56615661
56625662fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs {
......@@ -5672,7 +5672,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8)
56725672 .libc_installation = null,
56735673 .libc_framework_dir_list = &.{},
56745674 .sysroot = null,
5675 .darwinSdkLayout = .vendored,
5675 .darwin_sdk_layout = .vendored,
56765676 };
56775677}
56785678
......@@ -5690,7 +5690,7 @@ pub fn detectLibCIncludeDirs(
56905690 .libc_installation = null,
56915691 .libc_framework_dir_list = &.{},
56925692 .sysroot = null,
5693 .darwinSdkLayout = .none,
5693 .darwin_sdk_layout = null,
56945694 };
56955695 }
56965696
......@@ -5748,7 +5748,7 @@ pub fn detectLibCIncludeDirs(
57485748 .libc_installation = null,
57495749 .libc_framework_dir_list = &.{},
57505750 .sysroot = null,
5751 .darwinSdkLayout = .none,
5751 .darwin_sdk_layout = null,
57525752 };
57535753}
57545754
......@@ -5803,7 +5803,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const
58035803 .libc_installation = lci,
58045804 .libc_framework_dir_list = framework_list.items,
58055805 .sysroot = sysroot,
5806 .darwinSdkLayout = if (sysroot == null) .none else .sdk,
5806 .darwin_sdk_layout = if (sysroot == null) null else .sdk,
58075807 };
58085808}
58095809
......@@ -5865,7 +5865,7 @@ fn detectLibCFromBuilding(
58655865 .libc_installation = null,
58665866 .libc_framework_dir_list = &.{},
58675867 .sysroot = null,
5868 .darwinSdkLayout = .vendored,
5868 .darwin_sdk_layout = .vendored,
58695869 };
58705870}
58715871
src/link.zig+1-3
......@@ -137,7 +137,7 @@ pub const Options = struct {
137137 link_libc: bool,
138138 link_libcpp: bool,
139139 link_libunwind: bool,
140 darwinSdkLayout: DarwinSdkLayout,
140 darwin_sdk_layout: ?DarwinSdkLayout,
141141 function_sections: bool,
142142 no_builtin: bool,
143143 eh_frame_hdr: bool,
......@@ -285,8 +285,6 @@ pub const CompressDebugSections = enum { none, zlib };
285285
286286/// The filesystem layout of darwin SDK elements.
287287pub const DarwinSdkLayout = enum {
288 /// Does not apply to the target.
289 none,
290288 /// macOS SDK layout: TOP { /usr/include, /usr/lib, /System/Library/Frameworks }.
291289 sdk,
292290 /// Shipped libc layout: TOP { /lib/libc/include, /lib/libc/darwin, <NONE> }.
src/link/MachO.zig+1-2
......@@ -652,8 +652,7 @@ pub fn resolveLibSystem(
652652 "libSystem",
653653 )) break :success;
654654
655 switch (self.base.options.darwinSdkLayout) {
656 .none => unreachable,
655 switch (self.base.options.darwin_sdk_layout.?) {
657656 .sdk => {
658657 const dir = try fs.path.join(tmp_arena, &[_][]const u8{ self.base.options.sysroot.?, "usr", "lib" });
659658 if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;
src/link/MachO/load_commands.zig+4-7
......@@ -474,19 +474,16 @@ pub fn inferSdkVersion(gpa: Allocator, comp: *const Compilation) ?std.SemanticVe
474474
475475 const options = comp.bin_file.options;
476476
477 const sdk_dir = switch (options.darwinSdkLayout) {
478 .none => unreachable,
477 const sdk_layout = options.darwin_sdk_layout.?;
478 const sdk_dir = switch (sdk_layout) {
479479 .sdk => options.sysroot.?,
480480 .vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null,
481481 };
482
483482 if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| {
484483 return parseSdkVersion(ver);
485484 } else |_| {
486 if (options.darwinSdkLayout == .vendored) {
487 // vendored layout does not have versioned pathname
488 return null;
489 }
485 // We control vendored and reading settings should always succeed.
486 if (sdk_layout == .vendored) @panic("zig installation bug: unable to parse SDK version");
490487 }
491488
492489 // infer from pathname