zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bda9a159aa38f67dc76f2f4b7730a916239b27e0 (tree)
parent e1ca6946bee3acf9cbdf6e5ea30fa2d55304365d
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Tue, 27 Oct 2020 21:47:34 +0100

Apple Silicon: no fstat$INODE64 symbol found

It seems that Apple has finally got rid of the 32bit versions of
`fstat` and `fstatat`, and instead, only 64bit versions are available
on BigSur and Apple Silicon.

The tweak in this commit is required to make Zig stage1 compile on
BigSur + aarch64.

Diffstat:
Mlib/std/c.zig | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/std/c.zig b/lib/std/c.zig @@ -124,7 +124,14 @@ pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias b pub usingnamespace switch (builtin.os.tag) { .macos, .ios, .watchos, .tvos => struct { pub const realpath = @"realpath$DARWIN_EXTSN"; - pub const fstatat = @"fstatat$INODE64"; + pub usingnamespace switch (builtin.arch) { + .aarch64 => struct { + pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; + }, + else => struct { + pub const fstatat = @"fstatat$INODE64"; + }, + }; }, else => struct { pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; @@ -194,7 +201,14 @@ pub usingnamespace switch (builtin.os.tag) { // XXX: getdirentries -> _getdirentries64 pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; - pub const fstat = @"fstat$INODE64"; + pub usingnamespace switch (builtin.arch) { + .aarch64 => struct { + pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; + }, + else => struct { + pub const fstat = @"fstat$INODE64"; + } + }; pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;