authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-10-27 21:47:34+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-10-27 22:47:53+01:00
logbda9a159aa38f67dc76f2f4b7730a916239b27e0
treeccf1af3ef2723b5a6e41bc71fc62712013c3eda9
parente1ca6946bee3acf9cbdf6e5ea30fa2d55304365d

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.

1 files changed, 16 insertions(+), 2 deletions(-)

lib/std/c.zig+16-2
...@@ -124,7 +124,14 @@ pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias b...@@ -124,7 +124,14 @@ pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias b
124pub usingnamespace switch (builtin.os.tag) {124pub usingnamespace switch (builtin.os.tag) {
125 .macos, .ios, .watchos, .tvos => struct {125 .macos, .ios, .watchos, .tvos => struct {
126 pub const realpath = @"realpath$DARWIN_EXTSN";126 pub const realpath = @"realpath$DARWIN_EXTSN";
127 pub const fstatat = @"fstatat$INODE64";127 pub usingnamespace switch (builtin.arch) {
128 .aarch64 => struct {
129 pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
130 },
131 else => struct {
132 pub const fstatat = @"fstatat$INODE64";
133 },
134 };
128 },135 },
129 else => struct {136 else => struct {
130 pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;137 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) {...@@ -194,7 +201,14 @@ pub usingnamespace switch (builtin.os.tag) {
194 // XXX: getdirentries -> _getdirentries64201 // XXX: getdirentries -> _getdirentries64
195 pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;202 pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
196 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;203 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
197 pub const fstat = @"fstat$INODE64";204 pub usingnamespace switch (builtin.arch) {
205 .aarch64 => struct {
206 pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
207 },
208 else => struct {
209 pub const fstat = @"fstat$INODE64";
210 }
211 };
198 pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;212 pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
199 pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;213 pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
200 pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;214 pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;