authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-09-15 01:05:14-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-09-25 15:53:05-04:00
log15fd7cd154316e7eb3bf254e249072e562fdbe2c
tree7ebf55a244fdb21b1739b30e4dfeec073d86b3f4
parent52e835492626b34b34a46115f953591e01d1088e
signaturelock-open Commit is signed but in an unrecognized format.

macos: vendored libc: combine headers: part 2

- update include dirs to use combined dir - use one libSystem.tbd (drop use of libSystem.VERSION.tbd) - update canBuildLibC to check for minimum os version only

3 files changed, 6 insertions(+), 30 deletions(-)

src/Compilation.zig+3-20
......@@ -5656,31 +5656,14 @@ const LibCDirs = struct {
56565656 sysroot: ?[]const u8,
56575657};
56585658
5659fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8, target: Target) !LibCDirs {
5660 const arch_name = @tagName(target.cpu.arch);
5661 const os_name = try std.fmt.allocPrint(arena, "{s}.{d}", .{
5662 @tagName(target.os.tag),
5663 target.os.version_range.semver.min.major,
5664 });
5659fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs {
56655660 const s = std.fs.path.sep_str;
5666 const list = try arena.alloc([]const u8, 3);
5667
5661 const list = try arena.alloc([]const u8, 1);
56685662 list[0] = try std.fmt.allocPrint(
5669 arena,
5670 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-none",
5671 .{ zig_lib_dir, arch_name, os_name },
5672 );
5673 list[1] = try std.fmt.allocPrint(
5674 arena,
5675 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any",
5676 .{ zig_lib_dir, os_name },
5677 );
5678 list[2] = try std.fmt.allocPrint(
56795663 arena,
56805664 "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-macos-any",
56815665 .{zig_lib_dir},
56825666 );
5683
56845667 return LibCDirs{
56855668 .libc_include_dir_list = list,
56865669 .libc_installation = null,
......@@ -5823,7 +5806,7 @@ fn detectLibCFromBuilding(
58235806 target: std.Target,
58245807) !LibCDirs {
58255808 if (target.isDarwin())
5826 return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir, target);
5809 return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir);
58275810
58285811 const generic_name = target_util.libCGenericName(target);
58295812 // Some architectures are handled by the same set of headers.
src/link/MachO.zig+1-4
......@@ -661,10 +661,7 @@ pub fn resolveLibSystem(
661661 )) break :success;
662662
663663 const dir = try comp.zig_lib_directory.join(tmp_arena, &[_][]const u8{ "libc", "darwin" });
664 const lib_name = try std.fmt.allocPrint(tmp_arena, "libSystem.{d}", .{
665 self.base.options.target.os.version_range.semver.min.major,
666 });
667 if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, lib_name)) break :success;
664 if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;
668665
669666 try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});
670667 return;
src/target.zig+2-6
......@@ -18,8 +18,6 @@ pub const available_libcs = [_]ArchOsAbi{
1818 .{ .arch = .aarch64, .os = .linux, .abi = .musl },
1919 .{ .arch = .aarch64, .os = .windows, .abi = .gnu },
2020 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
21 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
22 .{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
2321 .{ .arch = .armeb, .os = .linux, .abi = .gnueabi },
2422 .{ .arch = .armeb, .os = .linux, .abi = .gnueabihf },
2523 .{ .arch = .armeb, .os = .linux, .abi = .musleabi },
......@@ -72,9 +70,7 @@ pub const available_libcs = [_]ArchOsAbi{
7270 .{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },
7371 .{ .arch = .x86_64, .os = .linux, .abi = .musl },
7472 .{ .arch = .x86_64, .os = .windows, .abi = .gnu },
75 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
76 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
77 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
73 .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 10, .minor = 7, .patch = 0 } },
7874};
7975
8076pub fn libCGenericName(target: std.Target) [:0]const u8 {
......@@ -153,7 +149,7 @@ pub fn canBuildLibC(target: std.Target) bool {
153149 if (target.cpu.arch == libc.arch and target.os.tag == libc.os and target.abi == libc.abi) {
154150 if (target.os.tag == .macos) {
155151 const ver = target.os.version_range.semver;
156 if (ver.min.major != libc.os_ver.?.major) continue; // no match, keep going
152 return ver.min.order(libc.os_ver.?) != .lt;
157153 }
158154 return true;
159155 }