Build currently failing on AIX and OS/400 (IBM i)
johnsonjh opened this issue · comments
src/unix/fs.c: In function 'uv__fs_copyfile':
src/unix/fs.c:1321:14: error: incompatible types when assigning to type 'struct timespec' from type 'st_timespec_t' {aka 'struct st_timespec'}
1321 | times[0] = src_statsbuf.st_atim;
| ^~~~~~~~~~~~
src/unix/fs.c:1322:14: error: incompatible types when assigning to type 'struct timespec' from type 'st_timespec_t' {aka 'struct st_timespec'}
1322 | times[1] = src_statsbuf.st_mtim;
| ^~~~~~~~~~~~
CC src/unix/libuv_la-poll.lo
gmake[1]: *** [Makefile:2730: src/unix/libuv_la-fs.lo] Error 1
gmake[1]: *** Waiting for unfinished jobs....
AIX build is failing with the same error.
Must be a change within the last 60 days or so, I haven't yet bisected it. Reverting my application CI build processes to use the last released libuv (1.48.0) is a successful workaround for now.
Did a git bisect, the bad commit is the one 3 days ago:
commit bf61390769068de603e6deec8e16623efcbe761a (HEAD -> v1.x, origin/v1.x, origin/HEAD)
Author: Juan José Arboleda <soyjuanarbol@gmail.com>
Date: Wed May 8 04:30:30 2024 -0500
linux,darwin: make `uv_fs_copyfile` behaves like `cp -r` (#4396)
This commit changes the timestamps in the file, the ownership and the
group.
Fixes: https://github.com/libuv/libuv/issues/3125
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Ping @juanarbol
I'll remove NetBSD from this issue for now, I think that was a local configuration error, so I will open a separate issue if needed when I have more information.
The AIX, the error messages are:
src/unix/fs.c: In function 'uv__fs_copyfile':
src/unix/fs.c:1321:14: error: incompatible types when assigning to type 'struct timespec' from type 'st_timespec_t' {aka 'struct st_timespec'}
1321 | times[0] = src_statsbuf.st_atim;
| ^~~~~~~~~~~~
src/unix/fs.c:1322:14: error: incompatible types when assigning to type 'struct timespec' from type 'st_timespec_t' {aka 'struct st_timespec'}
1322 | times[1] = src_statsbuf.st_mtim;
| ^~~~~~~~~~~~
I had a bit of time to look into the problem.
From the AIX stat.h header:
#if _XOPEN_SOURCE>=700
#ifdef _ALL_SOURCE
st_timespec_t st_atim; /* Time of last access */
st_timespec_t st_mtim; /* Time of last data modification */
st_timespec_t st_ctim; /* Time of last file status change */
#else
struct timespec st_atim;/* Time of last access */
struct timespec st_mtim;/* Time of last data modification */
struct timespec st_ctim;/* Time of last file status change */
#endif
#else
time_t st_atime; /* Time of last access */
int st_atime_n;
time_t st_mtime; /* Time of last data modification */
int st_mtime_n;
time_t st_ctime; /* Time of last file status change */
int st_ctime_n;
#endif
A quick check shows that _ALL_SOURCE
is defined, and that configure will always define it unconditionally, although I am not an autoconf expert.
The following patch seems to be sufficient:
diff --git a/src/unix/fs.c b/src/unix/fs.c
index 0c6c585c..7a2ce054 100644
--- a/src/unix/fs.c
+++ b/src/unix/fs.c
@@ -1226,21 +1226,25 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
return r;
}
static ssize_t uv__fs_copyfile(uv_fs_t* req) {
uv_fs_t fs_req;
uv_file srcfd;
uv_file dstfd;
struct stat src_statsbuf;
struct stat dst_statsbuf;
+#if defined(_AIX) && _XOPEN_SOURCE>=700 && defined(_ALL_SOURCE)
+ st_timespec_t times[2];
+#else
struct timespec times[2];
+#endif
int dst_flags;
int result;
int err;
off_t bytes_to_send;
off_t in_offset;
off_t bytes_written;
size_t bytes_chunk;
dstfd = -1;
err = 0;
I just tested on OS/400 (PASE for IBM i 7.5, GCC 10.5.0, powerpc-ibm-os400) - it was broken in the same way, so I've updated the title again. The patch above works there also.