mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
macho: append syslibroot to search dirs when resolving libSystem
This commit is contained in:
parent
72fb58f107
commit
f96d773d98
1 changed files with 40 additions and 45 deletions
|
|
@ -829,55 +829,50 @@ pub fn resolveLibSystem(
|
||||||
out_libs: anytype,
|
out_libs: anytype,
|
||||||
) !void {
|
) !void {
|
||||||
// If we were given the sysroot, try to look there first for libSystem.B.{dylib, tbd}.
|
// If we were given the sysroot, try to look there first for libSystem.B.{dylib, tbd}.
|
||||||
var libsystem_available = false;
|
if (syslibroot) |root| {
|
||||||
if (syslibroot != null) blk: {
|
const full_dir_path = try std.fs.path.join(arena, &.{ root, "usr", "lib" });
|
||||||
// Try stub file first. If we hit it, then we're done as the stub file
|
if (try resolveLibSystemInDirs(arena, &.{full_dir_path}, out_libs)) return;
|
||||||
// re-exports every single symbol definition.
|
}
|
||||||
for (search_dirs) |dir| {
|
|
||||||
if (try resolveLib(arena, dir, "System", ".tbd")) |full_path| {
|
// Next, try input search dirs if we are linking on a custom host such as Nix.
|
||||||
try out_libs.put(full_path, .{
|
if (try resolveLibSystemInDirs(arena, search_dirs, out_libs)) return;
|
||||||
.needed = true,
|
|
||||||
.weak = false,
|
// As a fallback, try linking against Zig shipped stub.
|
||||||
.path = full_path,
|
const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}.tbd", .{
|
||||||
});
|
target.os.version_range.semver.min.major,
|
||||||
libsystem_available = true;
|
});
|
||||||
break :blk;
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolveLibSystemInDirs(arena: Allocator, dirs: []const []const u8, out_libs: anytype) !bool {
|
||||||
|
// Try stub file first. If we hit it, then we're done as the stub file
|
||||||
|
// re-exports every single symbol definition.
|
||||||
|
for (dirs) |dir| {
|
||||||
|
if (try resolveLib(arena, dir, "System", ".tbd")) |full_path| {
|
||||||
|
try out_libs.put(full_path, .{ .needed = true, .weak = false, .path = full_path });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// If we didn't hit the stub file, try .dylib next. However, libSystem.dylib
|
}
|
||||||
// doesn't export libc.dylib which we'll need to resolve subsequently also.
|
// If we didn't hit the stub file, try .dylib next. However, libSystem.dylib
|
||||||
for (search_dirs) |dir| {
|
// doesn't export libc.dylib which we'll need to resolve subsequently also.
|
||||||
if (try resolveLib(arena, dir, "System", ".dylib")) |libsystem_path| {
|
for (dirs) |dir| {
|
||||||
if (try resolveLib(arena, dir, "c", ".dylib")) |libc_path| {
|
if (try resolveLib(arena, dir, "System", ".dylib")) |libsystem_path| {
|
||||||
try out_libs.put(libsystem_path, .{
|
if (try resolveLib(arena, dir, "c", ".dylib")) |libc_path| {
|
||||||
.needed = true,
|
try out_libs.put(libsystem_path, .{ .needed = true, .weak = false, .path = libsystem_path });
|
||||||
.weak = false,
|
try out_libs.put(libc_path, .{ .needed = true, .weak = false, .path = libc_path });
|
||||||
.path = libsystem_path,
|
return true;
|
||||||
});
|
|
||||||
try out_libs.put(libc_path, .{
|
|
||||||
.needed = true,
|
|
||||||
.weak = false,
|
|
||||||
.path = libc_path,
|
|
||||||
});
|
|
||||||
libsystem_available = true;
|
|
||||||
break :blk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!libsystem_available) {
|
|
||||||
const libsystem_name = try std.fmt.allocPrint(arena, "libSystem.{d}.tbd", .{
|
return false;
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolveSearchDir(
|
pub fn resolveSearchDir(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue