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
This commit is contained in:
Michael Dusan 2023-09-15 01:05:14 -04:00
parent 52e8354926
commit 15fd7cd154
No known key found for this signature in database
GPG Key ID: ED4C5BA849FA1B74
3 changed files with 6 additions and 30 deletions

View File

@ -5656,31 +5656,14 @@ const LibCDirs = struct {
sysroot: ?[]const u8,
};
fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8, target: Target) !LibCDirs {
const arch_name = @tagName(target.cpu.arch);
const os_name = try std.fmt.allocPrint(arena, "{s}.{d}", .{
@tagName(target.os.tag),
target.os.version_range.semver.min.major,
});
fn getZigShippedLibCIncludeDirsDarwin(arena: Allocator, zig_lib_dir: []const u8) !LibCDirs {
const s = std.fs.path.sep_str;
const list = try arena.alloc([]const u8, 3);
const list = try arena.alloc([]const u8, 1);
list[0] = try std.fmt.allocPrint(
arena,
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-none",
.{ zig_lib_dir, arch_name, os_name },
);
list[1] = try std.fmt.allocPrint(
arena,
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any",
.{ zig_lib_dir, os_name },
);
list[2] = try std.fmt.allocPrint(
arena,
"{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-macos-any",
.{zig_lib_dir},
);
return LibCDirs{
.libc_include_dir_list = list,
.libc_installation = null,
@ -5823,7 +5806,7 @@ fn detectLibCFromBuilding(
target: std.Target,
) !LibCDirs {
if (target.isDarwin())
return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir, target);
return getZigShippedLibCIncludeDirsDarwin(arena, zig_lib_dir);
const generic_name = target_util.libCGenericName(target);
// Some architectures are handled by the same set of headers.

View File

@ -661,10 +661,7 @@ pub fn resolveLibSystem(
)) break :success;
const dir = try comp.zig_lib_directory.join(tmp_arena, &[_][]const u8{ "libc", "darwin" });
const lib_name = try std.fmt.allocPrint(tmp_arena, "libSystem.{d}", .{
self.base.options.target.os.version_range.semver.min.major,
});
if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, lib_name)) break :success;
if (try accessLibPath(tmp_arena, &test_path, &checked_paths, dir, "libSystem")) break :success;
try self.reportMissingLibraryError(checked_paths.items, "unable to find libSystem system library", .{});
return;

View File

@ -18,8 +18,6 @@ pub const available_libcs = [_]ArchOsAbi{
.{ .arch = .aarch64, .os = .linux, .abi = .musl },
.{ .arch = .aarch64, .os = .windows, .abi = .gnu },
.{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
.{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
.{ .arch = .aarch64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
.{ .arch = .armeb, .os = .linux, .abi = .gnueabi },
.{ .arch = .armeb, .os = .linux, .abi = .gnueabihf },
.{ .arch = .armeb, .os = .linux, .abi = .musleabi },
@ -72,9 +70,7 @@ pub const available_libcs = [_]ArchOsAbi{
.{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },
.{ .arch = .x86_64, .os = .linux, .abi = .musl },
.{ .arch = .x86_64, .os = .windows, .abi = .gnu },
.{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 11, .minor = 0, .patch = 0 } },
.{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 12, .minor = 0, .patch = 0 } },
.{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 13, .minor = 0, .patch = 0 } },
.{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 10, .minor = 7, .patch = 0 } },
};
pub fn libCGenericName(target: std.Target) [:0]const u8 {
@ -153,7 +149,7 @@ pub fn canBuildLibC(target: std.Target) bool {
if (target.cpu.arch == libc.arch and target.os.tag == libc.os and target.abi == libc.abi) {
if (target.os.tag == .macos) {
const ver = target.os.version_range.semver;
if (ver.min.major != libc.os_ver.?.major) continue; // no match, keep going
return ver.min.order(libc.os_ver.?) != .lt;
}
return true;
}