Hi,
short version:
Why does sys/unix/sys_time.c undefine _FILE_OFFSET_BITS and _LARGEFILE_SOURCE?
Long version:
I’m trying to cross compile for a 32bit ARM system using Yocto 4.3.1.
It seems that Yocto tools now set ‘-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64’
by default. I assume it is a Y2038 thing.
However, this throws an error in sys_time.c (using c92b340bb5):
arm-poky-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=/opt/yocto/4.3.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Werror=undef -Werror=implicit -Werror=return-type -fno-strict-aliasing -fno-common -Os -I/u1/no_backup/otp_arm32/erts/arm-unknown-linux-gnueabi -D_GNU_SOURCE -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -DERLANG_GIT_VERSION="\"c92b340bb5\"" -Iarm-unknown-linux-gnueabi/opt/emu -Ibeam -Isys/unix -Isys/common -Iarm-unknown-linux-gnueabi -Ipcre -Iryu -Iopenssl/include -I../include -I../include/arm-unknown-linux-gnueabi -I../include/internal -I../include/internal/arm-unknown-linux-gnueabi -c sys/unix/sys_time.c -o obj/arm-unknown-linux-gnueabi/opt/emu/sys_time.o
In file included from /opt/yocto/4.3.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/features.h:394,
from /opt/yocto/4.3.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/bits/libc-header-start.h:33,
from /opt/yocto/4.3.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/stdlib.h:26,
from sys/unix/sys_time.c:35:
/opt/yocto/4.3.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
| ^~~~~
make[4]: *** [arm-unknown-linux-gnueabi/Makefile:912: obj/arm-unknown-linux-gnueabi/opt/emu/sys_time.o] Error 1
make[4]: Leaving directory '/u1/no_backup/otp_arm32/erts/emulator'
features-time64.h throws this error because _FILE_OFFSET_BITS is undefined :
#if defined _TIME_BITS
# if _TIME_BITS == 64
# if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
# error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
_FILE_OFFSET_BITS and _LARGEFILE_SOURCE are both undefined early in sys_time.c.
The comment says “These need to be undef:ed to not break activation of micro
level process accounting on /proc/self” which, to me, is rather fuzzy.
This code seems to date back to the pre-git era, so git does not offer any
more clues.
If I comment out ‘#undef _FILE_OFFSET_BITS’ everything builds and boots.
But why are the undef’s there in the first place?