| author | |
| committer | |
| log | ebd0776b28c50169936b58f8ba05be70e854fd35 |
| tree | edaccbd6332b18897db92748ec7d3c2a20baf808 |
| parent | f6877fbc4905b1bcd582415baebf3329725a1a43 |
| signature |
- make vendored settings failure unreachable
- rename field `darwinSdkLayout` → `darwin_sdk_layout`
- make `darwin_sdk_layout` optional4 files changed, 14 insertions(+), 20 deletions(-)
src/Compilation.zig+8-8| ... | ... | @@ -1557,7 +1557,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1557 | 1557 | .link_libc = link_libc, |
| 1558 | 1558 | .link_libcpp = link_libcpp, |
| 1559 | 1559 | .link_libunwind = link_libunwind, |
| 1560 | .darwinSdkLayout = libc_dirs.darwinSdkLayout, | |
| 1560 | .darwin_sdk_layout = libc_dirs.darwin_sdk_layout, | |
| 1561 | 1561 | .objects = options.link_objects, |
| 1562 | 1562 | .frameworks = options.frameworks, |
| 1563 | 1563 | .framework_dirs = options.framework_dirs, |
| ... | ... | @@ -5287,7 +5287,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD |
| 5287 | 5287 | .libc_installation = null, |
| 5288 | 5288 | .libc_framework_dir_list = &.{}, |
| 5289 | 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 | 5656 | libc_installation: ?*const LibCInstallation, |
| 5657 | 5657 | libc_framework_dir_list: []const []const u8, |
| 5658 | 5658 | sysroot: ?[]const u8, |
| 5659 | darwinSdkLayout: link.DarwinSdkLayout, | |
| 5659 | darwin_sdk_layout: ?link.DarwinSdkLayout, | |
| 5660 | 5660 | }; |
| 5661 | 5661 | |
| 5662 | 5662 | fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs { |
| ... | ... | @@ -5672,7 +5672,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) |
| 5672 | 5672 | .libc_installation = null, |
| 5673 | 5673 | .libc_framework_dir_list = &.{}, |
| 5674 | 5674 | .sysroot = null, |
| 5675 | .darwinSdkLayout = .vendored, | |
| 5675 | .darwin_sdk_layout = .vendored, | |
| 5676 | 5676 | }; |
| 5677 | 5677 | } |
| 5678 | 5678 | |
| ... | ... | @@ -5690,7 +5690,7 @@ pub fn detectLibCIncludeDirs( |
| 5690 | 5690 | .libc_installation = null, |
| 5691 | 5691 | .libc_framework_dir_list = &.{}, |
| 5692 | 5692 | .sysroot = null, |
| 5693 | .darwinSdkLayout = .none, | |
| 5693 | .darwin_sdk_layout = null, | |
| 5694 | 5694 | }; |
| 5695 | 5695 | } |
| 5696 | 5696 | |
| ... | ... | @@ -5748,7 +5748,7 @@ pub fn detectLibCIncludeDirs( |
| 5748 | 5748 | .libc_installation = null, |
| 5749 | 5749 | .libc_framework_dir_list = &.{}, |
| 5750 | 5750 | .sysroot = null, |
| 5751 | .darwinSdkLayout = .none, | |
| 5751 | .darwin_sdk_layout = null, | |
| 5752 | 5752 | }; |
| 5753 | 5753 | } |
| 5754 | 5754 | |
| ... | ... | @@ -5803,7 +5803,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const |
| 5803 | 5803 | .libc_installation = lci, |
| 5804 | 5804 | .libc_framework_dir_list = framework_list.items, |
| 5805 | 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 | } |
| 5809 | 5809 | |
| ... | ... | @@ -5865,7 +5865,7 @@ fn detectLibCFromBuilding( |
| 5865 | 5865 | .libc_installation = null, |
| 5866 | 5866 | .libc_framework_dir_list = &.{}, |
| 5867 | 5867 | .sysroot = null, |
| 5868 | .darwinSdkLayout = .vendored, | |
| 5868 | .darwin_sdk_layout = .vendored, | |
| 5869 | 5869 | }; |
| 5870 | 5870 | } |
| 5871 | 5871 |
src/link.zig+1-3| ... | ... | @@ -137,7 +137,7 @@ pub const Options = struct { |
| 137 | 137 | link_libc: bool, |
| 138 | 138 | link_libcpp: bool, |
| 139 | 139 | link_libunwind: bool, |
| 140 | darwinSdkLayout: DarwinSdkLayout, | |
| 140 | darwin_sdk_layout: ?DarwinSdkLayout, | |
| 141 | 141 | function_sections: bool, |
| 142 | 142 | no_builtin: bool, |
| 143 | 143 | eh_frame_hdr: bool, |
| ... | ... | @@ -285,8 +285,6 @@ pub const CompressDebugSections = enum { none, zlib }; |
| 285 | 285 | |
| 286 | 286 | /// The filesystem layout of darwin SDK elements. |
| 287 | 287 | pub const DarwinSdkLayout = enum { |
| 288 | /// Does not apply to the target. | |
| 289 | none, | |
| 290 | 288 | /// macOS SDK layout: TOP { /usr/include, /usr/lib, /System/Library/Frameworks }. |
| 291 | 289 | sdk, |
| 292 | 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 | 652 | "libSystem", |
| 653 | 653 | )) break :success; |
| 654 | 654 | |
| 655 | switch (self.base.options.darwinSdkLayout) { | |
| 656 | .none => unreachable, | |
| 655 | switch (self.base.options.darwin_sdk_layout.?) { | |
| 657 | 656 | .sdk => { |
| 658 | 657 | const dir = try fs.path.join(tmp_arena, &[_][]const u8{ self.base.options.sysroot.?, "usr", "lib" }); |
| 659 | 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 | 474 | |
| 475 | 475 | const options = comp.bin_file.options; |
| 476 | 476 | |
| 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) { | |
| 479 | 479 | .sdk => options.sysroot.?, |
| 480 | 480 | .vendored => std.fs.path.join(arena, &.{ comp.zig_lib_directory.path.?, "libc", "darwin" }) catch return null, |
| 481 | 481 | }; |
| 482 | ||
| 483 | 482 | if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| { |
| 484 | 483 | return parseSdkVersion(ver); |
| 485 | 484 | } 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"); | |
| 490 | 487 | } |
| 491 | 488 | |
| 492 | 489 | // infer from pathname |