diff --git a/Config.in b/Config.in index 670e199c0b..dbcca4c55a 100644 --- a/Config.in +++ b/Config.in @@ -736,6 +736,20 @@ config BR2_PER_PACKAGE_DIRECTORIES endmenu +config BR2_TIME_BITS_64 + bool "Build Y2038-ready code" + depends on BR2_TOOLCHAIN_USES_GLIBC && !BR2_ARCH_IS_64 + help + This option will pass -D_TIME_BITS=64 in the compiler flags + to ensure the glibc C library uses a 64-bit representation + for time_t and other time types, which ensures that + programs/libraries will correctly handle time past year + 2038. + + This option only has an effect with glibc >= 2.34, as + earlier glibc versions did not have support for 64-bit + time_t. + comment "Security Hardening Options" config BR2_PIC_PIE_ARCH_SUPPORTS diff --git a/package/Makefile.in b/package/Makefile.in index 5c11cae732..9fbe960759 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -167,6 +167,9 @@ TARGET_HARDENED += -D_FORTIFY_SOURCE=3 endif TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ifeq ($(BR2_TIME_BITS_64),y) +TARGET_CPPFLAGS += -D_TIME_BITS=64 +endif TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED) TARGET_CXXFLAGS = $(TARGET_CFLAGS) TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)