mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
link/MachO: Avoid depending on host PATH_MAX
Repeat of a4eb221b9 for the newly-synchronized zld code. Restores ability to compile Zig for WASI.
This commit is contained in:
parent
d02242661e
commit
6f2408aab8
@ -2982,7 +2982,7 @@ pub fn populateMissingMetadata(self: *MachO) !void {
|
||||
}
|
||||
}
|
||||
|
||||
inline fn calcInstallNameLen(cmd_size: u64, name: []const u8, assume_max_path_len: bool) u64 {
|
||||
pub inline fn calcInstallNameLen(cmd_size: u64, name: []const u8, assume_max_path_len: bool) u64 {
|
||||
const darwin_path_max = 1024;
|
||||
const name_len = if (assume_max_path_len) darwin_path_max else std.mem.len(name) + 1;
|
||||
return mem.alignForwardGeneric(u64, cmd_size + name_len, @alignOf(u64));
|
||||
|
||||
@ -1516,11 +1516,6 @@ pub const Zld = struct {
|
||||
}
|
||||
}
|
||||
|
||||
inline fn calcInstallNameLen(cmd_size: u64, name: []const u8, assume_max_path_len: bool) u64 {
|
||||
const name_len = if (assume_max_path_len) std.os.PATH_MAX else std.mem.len(name) + 1;
|
||||
return mem.alignForwardGeneric(u64, cmd_size + name_len, @alignOf(u64));
|
||||
}
|
||||
|
||||
fn calcLCsSize(self: *Zld, assume_max_path_len: bool) !u32 {
|
||||
const gpa = self.gpa;
|
||||
|
||||
@ -1542,7 +1537,7 @@ pub const Zld = struct {
|
||||
// LC_DYSYMTAB
|
||||
sizeofcmds += @sizeOf(macho.dysymtab_command);
|
||||
// LC_LOAD_DYLINKER
|
||||
sizeofcmds += calcInstallNameLen(
|
||||
sizeofcmds += MachO.calcInstallNameLen(
|
||||
@sizeOf(macho.dylinker_command),
|
||||
mem.sliceTo(MachO.default_dyld_path, 0),
|
||||
false,
|
||||
@ -1555,7 +1550,7 @@ pub const Zld = struct {
|
||||
if (self.options.output_mode == .Lib) {
|
||||
sizeofcmds += blk: {
|
||||
const install_name = self.options.install_name orelse self.options.emit.?.sub_path;
|
||||
break :blk calcInstallNameLen(
|
||||
break :blk MachO.calcInstallNameLen(
|
||||
@sizeOf(macho.dylib_command),
|
||||
install_name,
|
||||
assume_max_path_len,
|
||||
@ -1567,7 +1562,7 @@ pub const Zld = struct {
|
||||
var it = RpathIterator.init(gpa, self.options.rpath_list);
|
||||
defer it.deinit();
|
||||
while (try it.next()) |rpath| {
|
||||
sizeofcmds += calcInstallNameLen(
|
||||
sizeofcmds += MachO.calcInstallNameLen(
|
||||
@sizeOf(macho.rpath_command),
|
||||
rpath,
|
||||
assume_max_path_len,
|
||||
@ -1584,7 +1579,7 @@ pub const Zld = struct {
|
||||
for (self.referenced_dylibs.keys()) |id| {
|
||||
const dylib = self.dylibs.items[id];
|
||||
const dylib_id = dylib.id orelse unreachable;
|
||||
sizeofcmds += calcInstallNameLen(
|
||||
sizeofcmds += MachO.calcInstallNameLen(
|
||||
@sizeOf(macho.dylib_command),
|
||||
dylib_id.name,
|
||||
assume_max_path_len,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user