macho: check if fallback libSystem.{d}.tbd exists in Zig's installation

This commit is contained in:
Jakub Konka 2023-08-31 22:04:24 +02:00
parent f4c9e19bc3
commit 43adfd9689

View File

@ -657,17 +657,17 @@ pub fn resolveLibSystem(
if (try resolveLibSystemInDirs(arena, search_dirs, out_libs)) return;
// As a fallback, try linking against Zig shipped stub.
const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}.tbd", .{
const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}", .{
target.os.version_range.semver.min.major,
});
const full_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
"libc", "darwin", libsystem_name,
});
try out_libs.put(full_path, .{
.needed = true,
.weak = false,
.path = full_path,
});
const full_dir_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "darwin" });
if (try resolveLib(arena, full_dir_path, libsystem_name, ".tbd")) |full_path| {
try out_libs.put(full_path, .{
.needed = true,
.weak = false,
.path = full_path,
});
}
}
fn resolveLibSystemInDirs(arena: Allocator, dirs: []const []const u8, out_libs: anytype) !bool {