Closed Tom-python0121 closed 2 years ago
I suspect that the function declaration is inconsistent with the parameter or return value type in the function call. I debug it and find that the compilation process does not follow the gettimeofday function method, but the compiler of arm64 always takes it out, leading to compilation failure. So I temporarily blocked the gettimeofday method, so that the compilation tests were OK.
If you have a better solution, please provide it.
[root@localhost libfaketime]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper Target: aarch64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux Thread model: posix gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
I find that the input parameters are different. The gettimeofday function defines a parameter of the void type, but the name is a parameter of the struct timezone type. As a result, the preceding error occurs. I'll close the issue once the error is detected.
[root@localhost spack-src]# git diff
diff --git a/src/libfaketime.c b/src/libfaketime.c
index e632395..6fd6eca 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -2219,7 +2219,7 @@ int ftime(struct timeb *tb)
#ifdef MACOS_DYLD_INTERPOSE
int macos_gettimeofday(struct timeval *tv, void *tz)
#else
-int gettimeofday(struct timeval *tv, void *tz)
+int gettimeofday(struct timeval *tv, struct timezone *tz)
#endif
{
int result;
[root@localhost spack-src]# make
make -C src all
make[1]: Entering directory '/home/spack-stage/root/spack-stage-libfaketime-0.9.10-hwaa7ovwsgrhu3qso53cwmemrbl3jwtp/spack-src/src'
cc -o libfaketime.o -c -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' libfaketime.c
cc -o libfaketime.so.1 -Wl,-soname,libfaketime.so.1 -lpthread -Wl,--version-script=libfaketime.map -shared libfaketime.o -ldl -lm -lrt
cc -o libfaketimeMT.o -c -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -DPTHREAD_SINGLETHREADED_TIME libfaketime.c
cc -o libfaketimeMT.so.1 -Wl,-soname,libfaketimeMT.so.1 -lpthread -Wl,--version-script=libfaketime.map -shared libfaketimeMT.o -ldl -lm -lrt
make[1]: Leaving directory '/home/spack-stage/root/spack-stage-libfaketime-0.9.10-hwaa7ovwsgrhu3qso53cwmemrbl3jwtp/spack-src/src'
FWIW, I had this same problem but when I was doing the build in a centOS container on an M1 MacBook. The problem comes starts with libfaketime.c
including signal.h
. That, in turn, includes sys/procfs.h
. Since it's a system file, it can vary between architectures (and it does). On the M1 it includes sys/procfs.h
, which includes sys/time.h
(that is not the case on my Intel iMac). Here is the change I made to libfaketime.c:
#if defined PTHREAD_SINGLETHREADED_TIME || defined FAKE_PTHREAD
#include <pthread.h>
> #ifdef __aarch64__
> #define _SYS_TIME_H 1
> #endif
#include <signal.h>
#endif
Defining _SYS_TIME_H
keeps sys/time.h
from being included. Seems to work.
Steps to reproduce the issue
I see:https://github.com/wolfcw/libfaketime/issues/293,This problem always occurs when I compile on ARM64, but the compilation on x86_64 is OK.But I can't confirm what is the reason for error: conflicting types?