diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2023-09-25 15:51:57 -0400 |
|---|---|---|
| committer | Michael Dusan <michael.dusan@gmail.com> | 2023-09-25 17:07:41 -0400 |
| commit | ebd0776b28c50169936b58f8ba05be70e854fd35 (patch) | |
| tree | edaccbd6332b18897db92748ec7d3c2a20baf808 /src | |
| parent | f6877fbc4905b1bcd582415baebf3329725a1a43 (diff) | |
| download | zig-ebd0776b28c50169936b58f8ba05be70e854fd35.tar.gz zig-ebd0776b28c50169936b58f8ba05be70e854fd35.zip | |
kubkon review changes: 3
- make vendored settings failure unreachable
- rename field `darwinSdkLayout` → `darwin_sdk_layout`
- make `darwin_sdk_layout` optional
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 16 | ||||
| -rw-r--r-- | src/link.zig | 4 | ||||
| -rw-r--r-- | src/link/MachO.zig | 3 | ||||
| -rw-r--r-- | src/link/MachO/load_commands.zig | 11 |
4 files changed, 14 insertions, 20 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 65e433627f..395a399801 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1557,7 +1557,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .link_libc = link_libc, .link_libcpp = link_libcpp, .link_libunwind = link_libunwind, - .darwinSdkLayout = libc_dirs.darwinSdkLayout, + .darwin_sdk_layout = libc_dirs.darwin_sdk_layout, .objects = options.link_objects, .frameworks = options.frameworks, .framework_dirs = options.framework_dirs, @@ -5287,7 +5287,7 @@ fn detectWin32ResourceIncludeDirs(arena: Allocator, options: InitOptions) !LibCD .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, - .darwinSdkLayout = .none, + .darwin_sdk_layout = null, }, } } @@ -5656,7 +5656,7 @@ const LibCDirs = struct { libc_installation: ?*const LibCInstallation, libc_framework_dir_list: []const []const u8, sysroot: ?[]const u8, - darwinSdkLayout: link.DarwinSdkLayout, + darwin_sdk_layout: ?link.DarwinSdkLayout, }; fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs { @@ -5672,7 +5672,7 @@ fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, - .darwinSdkLayout = .vendored, + .darwin_sdk_layout = .vendored, }; } @@ -5690,7 +5690,7 @@ pub fn detectLibCIncludeDirs( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, - .darwinSdkLayout = .none, + .darwin_sdk_layout = null, }; } @@ -5748,7 +5748,7 @@ pub fn detectLibCIncludeDirs( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, - .darwinSdkLayout = .none, + .darwin_sdk_layout = null, }; } @@ -5803,7 +5803,7 @@ fn detectLibCFromLibCInstallation(arena: Allocator, target: Target, lci: *const .libc_installation = lci, .libc_framework_dir_list = framework_list.items, .sysroot = sysroot, - .darwinSdkLayout = if (sysroot == null) .none else .sdk, + .darwin_sdk_layout = if (sysroot == null) null else .sdk, }; } @@ -5865,7 +5865,7 @@ fn detectLibCFromBuilding( .libc_installation = null, .libc_framework_dir_list = &.{}, .sysroot = null, - .darwinSdkLayout = .vendored, + .darwin_sdk_layout = .vendored, }; } diff --git a/src/link.zig b/src/link.zig index efd02e982e..844ddb7b40 100644 --- a/src/link.zig +++ b/src/link.zig @@ -137,7 +137,7 @@ pub const Options = struct { link_libc: bool, link_libcpp: bool, link_libunwind: bool, - darwinSdkLayout: DarwinSdkLayout, + darwin_sdk_layout: ?DarwinSdkLayout, function_sections: bool, no_builtin: bool, eh_frame_hdr: bool, @@ -285,8 +285,6 @@ pub const CompressDebugSections = enum { none, zlib }; /// The filesystem layout of darwin SDK elements. pub const DarwinSdkLayout = enum { - /// Does not apply to the target. - none, /// macOS SDK layout: TOP { /usr/include, /usr/lib, /System/Library/Frameworks }. sdk, /// Shipped libc layout: TOP { /lib/libc/include, /lib/libc/darwin, <NONE> }. diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 0110ff81ce..81d6c5ead3 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -652,8 +652,7 @@ pub fn resolveLibSystem( "libSystem", )) break :success; - switch (self.base.options.darwinSdkLayout) { - .none => unreachable, + switch (self.base.options.darwin_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; diff --git a/src/link/MachO/load_commands.zig b/src/link/MachO/load_commands.zig index a00aec46fa..3aca247d8a 100644 --- a/src/link/MachO/load_commands.zig +++ b/src/link/MachO/load_commands.zig @@ -474,19 +474,16 @@ pub fn inferSdkVersion(gpa: Allocator, comp: *const Compilation) ?std.SemanticVe const options = comp.bin_file.options; - const sdk_dir = switch (options.darwinSdkLayout) { - .none => unreachable, + const sdk_layout = options.darwin_sdk_layout.?; + 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, }; - if (readSdkVersionFromSettings(arena, sdk_dir)) |ver| { return parseSdkVersion(ver); } else |_| { - if (options.darwinSdkLayout == .vendored) { - // vendored layout does not have versioned pathname - return null; - } + // We control vendored and reading settings should always succeed. + if (sdk_layout == .vendored) @panic("zig installation bug: unable to parse SDK version"); } // infer from pathname |
