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 {...@@ -1557,7 +1557,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1557 .link_libc = link_libc,1557 .link_libc = link_libc,
1558 .link_libcpp = link_libcpp,1558 .link_libcpp = link_libcpp,
1559 .link_libunwind = link_libunwind,1559 .link_libunwind = link_libunwind,
1560 .darwinSdkLayout = libc_dirs.darwinSdkLayout,1560 .darwin_sdk_layout = libc_dirs.darwin_sdk_layout,
1561 .objects = options.link_objects,1561 .objects = options.link_objects,
1562 .frameworks = options.frameworks,1562 .frameworks = options.frameworks,
1563 .framework_dirs = options.framework_dirs,1563 .framework_dirs = options.framework_dirs,
...@@ -5287,7 +5287,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD...@@ -5287,7 +5287,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD
5287 .libc_installation = null,5287 .libc_installation = null,
5288 .libc_framework_dir_list = &.{},5288 .libc_framework_dir_list = &.{},
5289 .sysroot = null,5289 .sysroot = null,
5290 .darwinSdkLayout = .none,5290 .darwin_sdk_layout = null,
5291 },5291 },
5292 }5292 }
5293 }5293 }
...@@ -5656,7 +5656,7 @@ const LibCDirs = struct {...@@ -5656,7 +5656,7 @@ const LibCDirs = struct {
5656 libc_installation: ?*const LibCInstallation,5656 libc_installation: ?*const LibCInstallation,
5657 libc_framework_dir_list: []const []const u8,5657 libc_framework_dir_list: []const []const u8,
5658 sysroot: ?[]const u8,5658 sysroot: ?[]const u8,
5659 darwinSdkLayout: link.DarwinSdkLayout,5659 darwin_sdk_layout: ?link.DarwinSdkLayout,
5660};5660};
56615661
5662fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs {5662fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs {
...@@ -5672,7 +5672,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8)...@@ -5672,7 +5672,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8)
5672 .libc_installation = null,5672 .libc_installation = null,
5673 .libc_framework_dir_list = &.{},5673 .libc_framework_dir_list = &.{},
5674 .sysroot = null,5674 .sysroot = null,
5675 .darwinSdkLayout = .vendored,5675 .darwin_sdk_layout = .vendored,
5676 };5676 };
5677}5677}
56785678
...@@ -5690,7 +5690,7 @@ pub fn detectLibCIncludeDirs(...@@ -5690,7 +5690,7 @@ pub fn detectLibCIncludeDirs(
5690 .libc_installation = null,5690 .libc_installation = null,
5691 .libc_framework_dir_list = &.{},5691 .libc_framework_dir_list = &.{},
5692 .sysroot = null,5692 .sysroot = null,
5693 .darwinSdkLayout = .none,5693 .darwin_sdk_layout = null,
5694 };5694 };
5695 }5695 }
56965696
...@@ -5748,7 +5748,7 @@ pub fn detectLibCIncludeDirs(...@@ -5748,7 +5748,7 @@ pub fn detectLibCIncludeDirs(
5748 .libc_installation = null,5748 .libc_installation = null,
5749 .libc_framework_dir_list = &.{},5749 .libc_framework_dir_list = &.{},
5750 .sysroot = null,5750 .sysroot = null,
5751 .darwinSdkLayout = .none,5751 .darwin_sdk_layout = null,
5752 };5752 };
5753}5753}
57545754
...@@ -5803,7 +5803,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const...@@ -5803,7 +5803,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const
5803 .libc_installation = lci,5803 .libc_installation = lci,
5804 .libc_framework_dir_list = framework_list.items,5804 .libc_framework_dir_list = framework_list.items,
5805 .sysroot = sysroot,5805 .sysroot = sysroot,
5806 .darwinSdkLayout = if (sysroot == null) .none else .sdk,5806 .darwin_sdk_layout = if (sysroot == null) null else .sdk,
5807 };5807 };
5808}5808}
58095809
...@@ -5865,7 +5865,7 @@ fn detectLibCFromBuilding(...@@ -5865,7 +5865,7 @@ fn detectLibCFromBuilding(
5865 .libc_installation = null,5865 .libc_installation = null,
5866 .libc_framework_dir_list = &.{},5866 .libc_framework_dir_list = &.{},
5867 .sysroot = null,5867 .sysroot = null,
5868 .darwinSdkLayout = .vendored,5868 .darwin_sdk_layout = .vendored,
5869 };5869 };
5870}5870}
58715871
src/link.zig+1-3
...@@ -137,7 +137,7 @@ pub const Options = struct {...@@ -137,7 +137,7 @@ pub const Options = struct {
137 link_libc: bool,137 link_libc: bool,
138 link_libcpp: bool,138 link_libcpp: bool,
139 link_libunwind: bool,139 link_libunwind: bool,
140 darwinSdkLayout: DarwinSdkLayout,140 darwin_sdk_layout: ?DarwinSdkLayout,
141 function_sections: bool,141 function_sections: bool,
142 no_builtin: bool,142 no_builtin: bool,
143 eh_frame_hdr: bool,143 eh_frame_hdr: bool,
...@@ -285,8 +285,6 @@ pub const CompressDebugSections = enum { none, zlib };...@@ -285,8 +285,6 @@ pub const CompressDebugSections = enum { none, zlib };
285285
286/// The filesystem layout of darwin SDK elements.286/// The filesystem layout of darwin SDK elements.
287pub const DarwinSdkLayout = enum {287pub const DarwinSdkLayout = enum {
288 /// Does not apply to the target.
289 none,
290 /// macOS SDK layout: TOP { /usr/include, /usr/lib, /System/Library/Frameworks }.288 /// macOS SDK layout: TOP { /usr/include, /usr/lib, /System/Library/Frameworks }.
291 sdk,289 sdk,
292 /// Shipped libc layout: TOP { /lib/libc/include, /lib/libc/darwin, <NONE> }.290 /// Shipped libc layout: TOP { /lib/libc/include, /lib/libc/darwin, <NONE> }.
src/link/MachO.zig+1-2
...@@ -652,8 +652,7 @@ pub fn resolveLibSystem(...@@ -652,8 +652,7 @@ pub fn resolveLibSystem(
652 "libSystem",652 "libSystem",
653 )) break :success;653 )) break :success;
654654
655 switch (self.base.options.darwinSdkLayout) {655 switch (self.base.options.darwin_sdk_layout.?) {
656 .none => unreachable,
657 .sdk => {656 .sdk => {
658 const dir = try fs.path.join(tmp_arena, &[_][]const u8{ self.base.options.sysroot.?, "usr", "lib" });657 const dir = try fs.path.join(tmp_arena, &[_][]const u8{ self.base.options.sysroot.?, "usr", "lib" });
659 if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;658 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...@@ -474,19 +474,16 @@ pub fn inferSdkVersion(gpa: Allocator, comp: *const Compilation) ?std.SemanticVe
474474
475 const options = comp.bin_file.options;475 const options = comp.bin_file.options;
476476
477 const sdk_dir = switch (options.darwinSdkLayout) {477 const sdk_layout = options.darwin_sdk_layout.?;
478 .none => unreachable,478 const sdk_dir = switch (sdk_layout) {
479 .sdk => options.sysroot.?,479 .sdk => options.sysroot.?,
480 .vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null,480 .vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null,
481 };481 };
482
483 if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| {482 if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| {
484 return parseSdkVersion(ver);483 return parseSdkVersion(ver);
485 } else |_| {484 } else |_| {
486 if (options.darwinSdkLayout == .vendored) {485 // We control vendored and reading settings should always succeed.
487 // vendored layout does not have versioned pathname486 if (sdk_layout == .vendored) @panic("zig installation bug: unable to parse SDK version");
488 return null;
489 }
490 }487 }
491488
492 // infer from pathname489 // infer from pathname