package/Makefile.in: Use 64-bit time_t with glibc toolchains for > year 2038 support

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

[1] 60b5eee76e
[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@gmail.com>
Cc: Christophe Blaess <christophe.blaess@logilin.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Romain Naour 2022-02-25 18:11:48 +01:00 committed by Peter Korsgaard
parent f8a4972a9a
commit 6e33e59080

View File

@ -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
TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED)
TARGET_CXXFLAGS = $(TARGET_CFLAGS)
TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)