Question about glibc issue

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Jul 27 18:55:58 GMT 2026



On 27/07/26 15:41, Aaron M. Biver via Libc-help wrote:
> 
> I seek the wisdom of the glibc oracle:
> 
> I'm trying to compile glibc 2.26  in a yocto-like environment (petalinux 2023.1) where I'm addressing the Y2038 issue, and the compile flags "-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" break the glibc build.  If there is some better forum for discussing this, please let me know.
> 
> Hopefully you can tell me what silly thing I'm doing wrong.
> 
> I see that glibc may already support 64 bit time flags being on by default, or at least it supports them being turned on by the user.  Thus, I expect your first answer to be that it already supports it and no action is needed.
> However, when I add global compile flags "-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64", the glibc compile fails with a few errors.  I would like the petalinux toolchain to use identical flags for all components, and this would include those flags.
> 
> The first failure is a pragma warning that 3 of the time functions' asm declarations are being redefined.  This stops the build due to -Werror.  However, if I turn that warning back into a warning-only, I get to a more serious error with fgetpos, and I suspect that the original warning was similarly serious.

There is no need build *glibc* with -D_FILE_OFFSET_BITS=64 nor -D_TIME_BITS=64, these
flags are meant to be used by applications.  The 64-bit time_t support is provided by
default for glibc 2.34+, although not enable by default.

> 
> Compile setup (I've fetched https://sourceware.org/git/glibc.git, tag glibc-2.36, and I'm using petalinux 2023.1 as the toolchain):
> 
> CC_PREFIX="/build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/bin/arm-xilinx-linux/arm-xilinx-linux"
> ARM_FLAGS="-O2 --sysroot=${SYSROOT} -mfloat-abi=hard -mthumb -mfpu=neon -mcpu=cortex-a9 -fstack-protector-strong -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
> SYSROOT=/build/petalinux/2023.1/sysroot/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi
> 
> Then the compile command:
> ../glibc/configure --host=arm-linux-gnueabihf --prefix=/home/amb58/src/glibc/glibc-build CC="${CC_PREFIX}-gcc" CXX="${CC_PREFIX}-g++"  CFLAGS="${ARM_FLAGS}" CXXFLAGS="${ARM_FLAGS}" --with-headers=${SYSROOT}/usr/include/
> make
> 
> The first error I get is:
> 
> /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/bin/arm-xilinx-linux/arm-xilinx-linux-gcc errlist.c -c -std=gnu11 -fgnu89-inline  -O2 --sysroot=/build/petalinux/2023.1/sysroot/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi -mfloat-abi=hard -mthumb -mfpu=neon -mcpu=cortex-a9 -fstack-protector-strong -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-error=pragmas -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wstrict-prototypes -Wold-style-definition -fmath-errno    -fPIC   -ftls-model=initial-exec      -I../include -I/home/amb58/src/glibc/glibc-build/stdio-common  -I/home/amb58/src/glibc/glibc-build  -I../sysdeps/unix/sysv/linux/arm/le  -I../sysdeps/unix/sysv/linux/arm  -I../sysdeps/arm/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/arm  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/arm/le/armv7/multiarch  -I../sysdeps/arm/armv7/multiarch  -I../sysdeps/arm/le/armv7  -I../sysdeps/arm/armv7  -I../sysdeps/arm/armv6t2  -I../sysdeps/arm/armv6  -I../sysdeps/arm/le  -I../sysdeps/arm/include -I../sysdeps/arm  -I../sysdeps/wordsize-32  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/lib/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/12.2.0/include -isystem /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/lib/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/12.2.0/include-fixed -isystem /build/petalinux/2023.1/sysroot/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/ -D_LIBC_REENTRANT -include /home/amb58/src/glibc/glibc-build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED     -DTOP_NAMESPACE=glibc -D_IO_MTSAFE_IO -o /home/amb58/src/glibc/glibc-build/stdio-common/errlist.os -MD -MP -MF /home/amb58/src/glibc/glibc-build/stdio-common/errlist.os.dt -MT /home/amb58/src/glibc/glibc-build/stdio-common/errlist.os
> In file included from ../sysdeps/nptl/pthread.h:23,
>                  from ../include/pthread.h:1,
>                  from ../sysdeps/nptl/libc-lock.h:22,
>                  from ../sysdeps/nptl/stdio-lock.h:22,
>                  from ../include/stdio.h:3,
>                  from errlist.c:23:
> ../include/time.h:21:1: warning: 'asm' declaration ignored due to conflict with previous rename [-Wpragmas]
>    21 | libc_hidden_proto (mktime)
>       | ^~~~~~~~~~~~~~~~~
> ../include/time.h:22:1: warning: 'asm' declaration ignored due to conflict with previous rename [-Wpragmas]
>    22 | libc_hidden_proto (timelocal)
>       | ^~~~~~~~~~~~~~~~~
> ../include/time.h:23:1: warning: 'asm' declaration ignored due to conflict with previous rename [-Wpragmas]
>    23 | libc_hidden_proto (localtime)
>       | ^~~~~~~~~~~~~~~~~
> 
> If I disable that by adding -Wno-error=pragmas to the compile flags, then I get further, up until...
> 
> /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/bin/arm-xilinx-linux/arm-xilinx-linux-gcc iofgetpos.c -c -std=gnu11 -fgnu89-inline  -O2 --sysroot=/build/petalinux/2023.1/sysroot/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi -mfloat-abi=hard -mthumb -mfpu=neon -mcpu=cortex-a9 -fstack-protector-strong -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-error=pragmas -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wstrict-prototypes -Wold-style-definition -fmath-errno    -fpie -fexceptions  -ftls-model=initial-exec      -I../include -I/home/amb58/src/glibc/glibc-build/libio  -I/home/amb58/src/glibc/glibc-build  -I../sysdeps/unix/sysv/linux/arm/le  -I../sysdeps/unix/sysv/linux/arm  -I../sysdeps/arm/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/arm  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/arm/le/armv7/multiarch  -I../sysdeps/arm/armv7/multiarch  -I../sysdeps/arm/le/armv7  -I../sysdeps/arm/armv7  -I../sysdeps/arm/armv6t2  -I../sysdeps/arm/armv6  -I../sysdeps/arm/le  -I../sysdeps/arm/include -I../sysdeps/arm  -I../sysdeps/wordsize-32  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/lib/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/12.2.0/include -isystem /build/petalinux/2023.1/sysroot/sysroots/x86_64-petalinux-linux/usr/lib/arm-xilinx-linux-gnueabi/gcc/arm-xilinx-linux-gnueabi/12.2.0/include-fixed -isystem /build/petalinux/2023.1/sysroot/sysroots/cortexa9t2hf-neon-xilinx-linux-gnueabi/usr/include/ -D_LIBC_REENTRANT -include /home/amb58/src/glibc/glibc-build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -D_IO_MTSAFE_IO -o /home/amb58/src/glibc/glibc-build/libio/iofgetpos.o -MD -MP -MF /home/amb58/src/glibc/glibc-build/libio/iofgetpos.o.dt -MT /home/amb58/src/glibc/glibc-build/libio/iofgetpos.o
> In file included from <command-line>:
> iofgetpos.c:84:40: error: conflicting types for 'fgetpos'; have 'int(FILE *, __fpos_t *)' {aka 'int(struct _IO_FILE *, struct _G_fpos_t *)'}
>    84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
>       |                                        ^~~~~~~
> ./../include/libc-symbols.h:155:26: note: in definition of macro '_weak_alias'
>   155 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
>       |                          ^~~~~~~~~
> ../include/shlib-compat.h:117:3: note: in expansion of macro 'weak_alias'
>   117 |   weak_alias (local, symbol)
>       |   ^~~~~~~~~~
> iofgetpos.c:84:1: note: in expansion of macro 'versioned_symbol'
>    84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
>       | ^~~~~~~~~~~~~~~~
> In file included from ../include/sys/cdefs.h:10,
>                  from ../include/features.h:490,
>                  from ../stdlib/errno.h:25,
>                  from ../include/errno.h:2,
>                  from libioP.h:40,
>                  from iofgetpos.c:34:
> ../libio/stdio.h:768:24: note: previous declaration of 'fgetpos' with type 'int(FILE * restrict,  fpos_t * restrict)' {aka 'int(struct _IO_FILE * restrict,  struct _G_fpos64_t * restrict)'}
>   768 | extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
>       |                        ^~~~~~~
> ../misc/sys/cdefs.h:247:41: note: in definition of macro '__REDIRECT'
>   247 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
>       |                                         ^~~~
> make[2]: *** [../o-iterator.mk:9: /home/amb58/src/glibc/glibc-build/libio/iofgetpos.o] Error 1
> make[2]: Leaving directory '/home/amb58/src/glibc/glibc/libio'
> make[1]: *** [Makefile:484: libio/subdir_lib] Error 2
> make[1]: Leaving directory '/home/amb58/src/glibc/glibc'
> make: *** [Makefile:9: all] Error 2
> 
> Aaron Biver
> R&D Engineer
> Applied Research Laboratory
> Pennsylvania State University
> Office: 814-863-5223
> 
> 



More information about the Libc-help mailing list