wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.64k stars 321 forks source link

Compile problem in CentOS7 on M1 #403

Closed perldude closed 1 year ago

perldude commented 2 years ago

I am building libfaketime in the official CentOS7 container. Works fine for Intel. When I build it on an M1 MacBook, I get:

libfaketime.c:2300:5: error: conflicting types for ‘gettimeofday’
 int gettimeofday(struct timeval *tv, void *tz)
     ^
In file included from /usr/include/sys/procfs.h:32:0,
                 from /usr/include/sys/ucontext.h:26,
                 from /usr/include/signal.h:360,
                 from libfaketime.c:79:
/usr/include/sys/time.h:72:12: note: previous declaration of ‘gettimeofday’ was here
 extern int gettimeofday (struct timeval *__restrict __tv,
            ^

The reason is that signal.h eventually includes sys/time.h, which results in a conflict between the gettimeofday() there and the one in libfaketime.c. The Intel version of the CentOS container does not have this problem because sys/time.h does not end up getting included there.

I have a solution that is working for me but I wanted to create a ticket to attach a PR to.

wolfcw commented 2 years ago

Thanks for that, just merged. :-)