[Buildroot] [PATCH] package/Makefile.in: year2038 makes time_t 64-bit for glibc toolchains

Arnout Vandecappelle arnout at mind.be
Mon Mar 7 22:33:10 UTC 2022



On 07/03/2022 22:49, Romain Naour wrote:
> Hello Peter,
> 
> Le 07/03/2022 à 20:54, Peter Korsgaard a écrit :
>>>>>>> "Romain" == Romain Naour <romain.naour at gmail.com> writes:
>>
>>   > To use time_t 64-bit for glibc >= 2.34 toolchains we have to set both
>>   > _FILE_OFFSET_BITS=64 and _TIME_BITS=64 for glibc toolchains. Buildroot
>>   > already define _FILE_OFFSET_BITS=64 since 2008 [1] before the first
>>   > release tag 2009.02.
>>
>>   > _TIME_BITS is not needed for musl libc since it already year2038
>>   > ready [2].
>>
>>   > The uclibc-ng libc only support time_t 32-bit (long int) so it will be
>>   > affected by the year2038 issue [3].
>>
>>   > Fixes (in French, chapter Buildroot 2022 and GlibC):
>>   > https://www.blaess.fr/christophe/2038
>>
>>   > Runtime tested with qemu_arm_vexpress_defconfig and the Bootlin glibc
>>   > bleeding-edge 2021.11-1 toolchain.
>>
>>   > Before:
>>   >  # date
>>   >  Tue Jan 19 03:14:07 UTC 2038
>>   >  # date
>>   >  Thu Jan  1 00:00:00 UTC 1970
>>
>>   > After:
>>   >  # date
>>   >  Tue Jan 19 03:14:07 UTC 2038
>>   >  # date
>>   >  Tue Jan 19 03:14:08 UTC 2038
>>   >  # date
>>   >  Tue Jan 19 03:14:09 UTC 2038
>>
>> Ahh, good catch. Maybe something to add a runtime test for?
>>
>> Committed, thanks.
> 
> Sorry but I guess this patch needs more testing.
> 
>>
>>   > [1] 60b5eee76edfa153ef118d2788c74ac8da1497a0
>>   > [2] https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in?h=v1.2.2#n3
>>   > [3] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/time.h?h=v1.0.40#n75
>>   >     https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common/bits/types.h?h=v1.0.40#n106
>>
>>   > Signed-off-by: Romain Naour <romain.naour at gmail.com>
>>   > Cc: Christophe Blaess <christophe.blaess at logilin.fr>
>>   > ---
>>   >  package/Makefile.in | 2 +-
>>   >  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>   > diff --git a/package/Makefile.in b/package/Makefile.in
>>   > index 508ea7c366..cde050ca82 100644
>>   > --- a/package/Makefile.in
>>   > +++ b/package/Makefile.in
>>   > @@ -167,7 +167,7 @@ else ifeq ($(BR2_FORTIFY_SOURCE_2),y)
>>   >  TARGET_HARDENED += -D_FORTIFY_SOURCE=2
>>   >  endif
>>   
>>   > -TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
>>   > +TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
> 
> I noticed that glibc 2.34 stop the build if _TIME_BITS is set without
> _FILE_OFFSET_BITS.
> What if something (build system) unset _FILE_OFFSET_BITS ?

  Then there's something wrong with that package and it needs to be fixed.

> There is something weird with libzlib package.

  gzguts.h has this:

#ifdef _LARGEFILE64_SOURCE
#  ifndef _LARGEFILE_SOURCE
#    define _LARGEFILE_SOURCE 1
#  endif
#  ifdef _FILE_OFFSET_BITS
#    undef _FILE_OFFSET_BITS
#  endif
#endif

  Why, I have no idea...

  Regards,
  Arnout

> 
> I suggest to apply for next first and backport it latter to the stable branch.
> 
> Best regards,
> Romain
> 
> 
>>   >  TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED)
>>   >  TARGET_CXXFLAGS = $(TARGET_CFLAGS)
>>   >  TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
>>   > --
>>
>>   > 2.35.1
>>
>>   > _______________________________________________
>>   > buildroot mailing list
>>   > buildroot at buildroot.org
>>   > https://lists.buildroot.org/mailman/listinfo/buildroot
>>
>>
> 
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot



More information about the buildroot mailing list