https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103886
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:c91a6b8ec7cedb8949675c6855f2f35cfe4100e5 commit r17-5917-gc91a6b8ec7cedb8949675c6855f2f35cfe4100e5 Author: Richard Biener <[email protected]> Date: Sat Oct 31 15:52:47 2026 +0100 libgfortran/103886 - enable 64-bit time_t on 32-bit glibc targets PR114895 reports that on 32-bit glibc targets with 32-bit time_t, stat() fails with EOVERFLOW once file timestamps are past 2038-01-19. The LIBGFOR_CHECK_WORKING_STAT configure test then fails, HAVE_WORKING_STAT is left undefined, and the build of io/unix.c breaks, since the !HAVE_WORKING_STAT code path there is only usable on MinGW. This can be reproduced e.g. by building the 32-bit multilib in a VM whose clock is set past 2038. Fix this by building libgfortran with 64-bit time_t where the C library supports it as requested by PR103886. A new LIBGFOR_CHECK_TIME_BITS64 check, run right after AC_SYS_LARGEFILE, tests whether time_t is already 64 bits wide and, if not, whether defining _TIME_BITS to 64 makes it so; in that case _TIME_BITS is defined to 64 in config.h. glibc only accepts _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, so the check relies on the _FILE_OFFSET_BITS setting from AC_SYS_LARGEFILE and does nothing when configured with --disable-largefile. No exported libgfortran interface uses time_t, struct stat or other time-related C types; the time_t uses are all in internal helpers, so the library ABI does not change. Note that intrinsics returning or taking default-kind INTEGER values (e.g. TIME, or STAT with an INTEGER(4) array) still truncate to 32 bits; this change only makes the internal handling and the 64-bit variants correct past 2038. PR libfortran/103886 PR libfortran/114895 libgfortran/ * acinclude.m4 (LIBGFOR_CHECK_TIME_BITS64): New check for 64-bit time_t support. * configure.ac: Invoke LIBGFOR_CHECK_TIME_BITS64. * configure: Regenerate. * config.h.in: Regenerate.
