Le 2025-01-03 19:23, Helge Deller a écrit :
On 1/3/25 18:59, p...@debian.org wrote:Le 2025-01-03 17:43, Helge Deller a écrit :On 1/3/25 15:55, p...@debian.org wrote:You were right about the gmtime() function being involved. Itappears that on powerpc and hppa it returns 01/01/1970. I've set up a reproducer (attached).That's what I needed. Thanks!On powerpc / hppa: $ gfortran -g -o test_gmtime test_gmtime.F90 $ ./test_gmtime time8: 1735915109 Year: 1970 Month: 1 Day: 1 Hour: 0 Minute: 0 Second: 0 On amd64: $ gfortran -g -o test_gmtime test_gmtime.F90 0 ;) pini@pinibrem14:~/tmp/h5gmtime $ ./test_gmtime time8: 1735915041 Year: 2025 Month: 1 Day: 3 Hour: 14 Minute: 37 Second: 21 I don't know how to solve this yet.Ok, I know how to fix it: In your fortran example, replace FUNCTION gmtime_c(stdtime_t) BIND(C, NAME='gmtime') by: FUNCTION gmtime_c(stdtime_t) BIND(C, NAME='__gmtime64') On 32-bit platforms, glibc provides "gmtime" for 32-bit time_t, and __gmtime64 for 64-bit time_t. At compile time depending on defines, one or the other is used. Is it possible to detect during config time, if that function is exported by glibc, and then use it if it's available?I'm not sure that would be the correct solution. I think there is now an inconsistency between gcc and gfortran on hppa and powerpc, the former using __gmtime64 as the default for gmtime, and the latter sticking to its legacy 32-bit implementation.No. Both use the 64-bit implementation on debian, since debian defines _TIME_BITS=64 on all 32-bit platforms (beside x86 due to compatibility). The rule should be: if H5_SIZEOF_TIME_T == 8 use __gmtime64 if glibc provides it, else use gmtime which is the default. else use gmtime This works for all: 32- and 64-bit, big- and little-endian.This problem doesn't exist on litte-endian 32-bit architectures.Yes, it does. The only difference is, that on little-endian the lower 32-bits ofthe time_t value is stored in the first 4 bytes (and thus have the correct value), while on big endian the upper 32bits (which are zero) are storedin the lower 4 bytes - which is why you get here the wrong date.
I came up with the attached patch. Best, _g.
diff -Nru hdf5-1.14.5+repack/debian/changelog hdf5-1.14.5+repack/debian/changelog --- hdf5-1.14.5+repack/debian/changelog 2024-12-30 20:18:56.000000000 +0100 +++ hdf5-1.14.5+repack/debian/changelog 2025-01-03 18:03:53.000000000 +0100 @@ -1,3 +1,10 @@ +hdf5 (1.14.5+repack-3) UNRELEASED; urgency=medium + + * New patch fortran_gmtime64.patch: fix fortran gmtime related + failures on big-endian 32-bit architectures (closes: #1091911) + + -- Gilles Filippini <p...@debian.org> Fri, 03 Jan 2025 18:03:53 +0100 + hdf5 (1.14.5+repack-2) unstable; urgency=medium * Acknoledge previously fixed CVE: diff -Nru hdf5-1.14.5+repack/debian/patches/fortran_gmtime64.patch hdf5-1.14.5+repack/debian/patches/fortran_gmtime64.patch --- hdf5-1.14.5+repack/debian/patches/fortran_gmtime64.patch 1970-01-01 01:00:00.000000000 +0100 +++ hdf5-1.14.5+repack/debian/patches/fortran_gmtime64.patch 2025-01-03 18:03:53.000000000 +0100 @@ -0,0 +1,24 @@ +Index: hdf5/fortran/src/H5_ff.F90 +=================================================================== +--- hdf5.orig/fortran/src/H5_ff.F90 ++++ hdf5/fortran/src/H5_ff.F90 +@@ -46,6 +46,7 @@ + ! + + #include <H5config_f.inc> ++#include <features-time64.h> + + MODULE H5LIB + +@@ -1064,7 +1065,11 @@ CONTAINS + INTEGER(C_INT), DIMENSION(:), POINTER :: c_time + + INTERFACE ++#ifndef __USE_TIME_BITS64 + FUNCTION gmtime(stdtime_t) BIND(C, NAME='gmtime') ++#else ++ FUNCTION gmtime(stdtime_t) BIND(C, NAME='__gmtime64') ++#endif + IMPORT :: TIME_T, C_PTR + IMPLICIT NONE + INTEGER(KIND=TIME_T) :: stdtime_t diff -Nru hdf5-1.14.5+repack/debian/patches/series hdf5-1.14.5+repack/debian/patches/series --- hdf5-1.14.5+repack/debian/patches/series 2024-12-30 17:40:21.000000000 +0100 +++ hdf5-1.14.5+repack/debian/patches/series 2025-01-03 18:00:37.000000000 +0100 @@ -7,3 +7,4 @@ java_use-system-jars.patch float128.patch cheat-fortranlib_test.patch +fortran_gmtime64.patch diff -Nru hdf5-1.14.5+repack/debian/rules hdf5-1.14.5+repack/debian/rules --- hdf5-1.14.5+repack/debian/rules 2024-12-30 20:18:49.000000000 +0100 +++ hdf5-1.14.5+repack/debian/rules 2025-01-03 18:03:53.000000000 +0100 @@ -157,6 +157,11 @@ export DEB_CFLAGS_MAINT_STRIP = -Werror=format-security -Werror=implicit-function-declaration export DEB_CXXFLAGS_MAINT_STRIP = -Werror=format-security +# Fix for #1091911 along with patch fortran_gmtime64.patch +# These flags should be defined only when dpkg-buildflags sets -D_TIME_BITS=64 +ifneq (,$(filter -D_TIME_BITS=64,$(shell dpkg-buildflags --get CPPFLAGS))) +export DEB_FCFLAGS_MAINT_APPEND = -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 +endif # Compose the packages' name flavor part from $(flavor) flavorpkg = $(subst -serial,,-$(flavor))
signature.asc
Description: OpenPGP digital signature