#1121759 gcc-14: Fix broken ada timespec record with -D_TIME_BITS=64 on 32-bit big-endian targets

Package:
src:gcc-16
Source:
src:gcc-16
Submitter:
John David Anglin
Date:
2025-12-02 03:03:01 UTC
Severity:
normal
Tags:
#1121759#5
Date:
2025-06-25 21:22:52 UTC
From:
To:
Dear Maintainer,

The gnat patches applied to gcc-14 to support building with -D_TIME_BITS=64
-D_FILE_OFFSET_BITS=64 broke numerous tests in the gnat testsuite.

Analysis of the array39 test showed that the ada timespec record was
not correctly layed out.  See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065

In s-c_time.ads, we have

   type timespec is record
      tv_sec  : time_t range 0 .. OS_Constants.MAX_tv_sec;  --  seconds
      tv_nsec : nsec_t range 0 .. 999_999_999;              --  nanoseconds
   end record

but the struct __timespec64 is defined as follows:

#if __TIMESIZE == 64
# define __timespec64 timespec
#else
#include <endian.h>
/* The glibc Y2038-proof struct __timespec64 structure for a time value.
   To keep things Posix-ish, we keep the nanoseconds field a 32-bit
   signed long, but since the Linux field is a 64-bit signed int, we
   pad our tv_nsec with a 32-bit unnamed bit-field padding.

   As a general rule the Linux kernel is ignoring upper 32 bits of
   tv_nsec field.  */
struct __timespec64
{
  __time64_t tv_sec;         /* Seconds */
# if BYTE_ORDER == BIG_ENDIAN
  __int32_t :32;             /* Padding */
  __int32_t tv_nsec;         /* Nanoseconds */
# else
  __int32_t tv_nsec;         /* Nanoseconds */
  __int32_t :32;             /* Padding */
# endif
};
#endif

The nsec_t is currently defined using the size of the tv_nsec in
the __timespec 64 struct  but this ignores the padding on big-endian
targets.

The attached patch fixes this issue.

Regards,
Dave Anglin

#1121759#10
Date:
2025-07-28 17:35:47 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
gcc-14, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1108322@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Matthias Klose <doko@debian.org> (supplier of updated gcc-14 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Mon, 28 Jul 2025 17:42:09 +0200
Source: gcc-14
Architecture: source
Version: 14.3.0-4
Distribution: experimental
Urgency: medium
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Changed-By: Matthias Klose <doko@debian.org>
Closes: 1108322
Changes:
 gcc-14 (14.3.0-4) experimental; urgency=medium
 .
   * Update to git 20250728 from the gcc-14 branch.
     - Fix PR target/121027 (AArch64), PR target/118891 (AArch64),
       PR tree-optimization/118891, PR tree-optimization/121131,
       PR target/120908 (x86), PR target/120624 (AArch64),
       PR tree-optimization/116674, PR middle-end/120631, PR middle-end/117811,
       PR tree-optimization/120638, PR middle-end/120547, PR c++/120577,
       PR c++/120940, PR c++/120471, PR fortran/121060, PR libstdc++/120548,
       PR libstdc++/99832.
   * Fix broken ada timespec record with -D_TIME_BITS=64 on 32-bit big-endian
     targets (John David Anglin). Closes: #1108322.
Checksums-Sha1:
 a45dbb56efd6093503a4d87296c51cc7d01eaca4 42270 gcc-14_14.3.0-4.dsc
 8bb0371e9203e71167aca9262b246c9a4afebb61 601952 gcc-14_14.3.0-4.debian.tar.xz
 9752af2cb1eda8510dea0a13360074f4931588d9 9887 gcc-14_14.3.0-4_source.buildinfo
Checksums-Sha256:
 bc881bf5b78c44418b24b071c53025c659addd35cdc8a636a1038247e741da88 42270 gcc-14_14.3.0-4.dsc
 22596fa57e738c785b9e05c54044e864077a4219ff397840f90f8ba3e13813a1 601952 gcc-14_14.3.0-4.debian.tar.xz
 9625d907a5238dd45ea8dfe3e67d395c537423ddadfb78b42ab4e194f31819ad 9887 gcc-14_14.3.0-4_source.buildinfo
Files:
 e79cbad9eb672ca960adeddbb0edc0c5 42270 devel optional gcc-14_14.3.0-4.dsc
 6c5b7971422b7d2a66ca4abf521b8459 601952 devel optional gcc-14_14.3.0-4.debian.tar.xz
 008a73640be9c60d460c5da60b18a9fc 9887 devel optional gcc-14_14.3.0-4_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQJEBAEBCgAuFiEE1WVxuIqLuvFAv2PWvX6qYHePpvUFAmiHr38QHGRva29AZGVi
aWFuLm9yZwAKCRC9fqpgd4+m9R2dEACrOQv3mctnhS+tLOL1kPXPT8KhLvNUevyp
XysPYqGTeoPyLNcNDZ8x6vrDKb6n7UH1jUHk+yRnyxzwKZ+LUcLMiSCevPpN4nr+
NsyFJNo5MTukyqdrIAtqStfjQgZPDsEOPFmUUFgjAk6c07qIbv9wwWjqSBhv8Rwg
4b5/tf5BLvCfjZg0PweyECCGCpfbdKfnoq1MxTy9FjDAMDJvHTQeiVw7lr9vi+Kr
/u6YvhNhilANdTgbesgd1/VQhVKdAMj2mgPQ45X87sM1wnRTVKmmfpFLrbzxaHph
6F6JZ4xmoDgvkwLjAdvXdSrCWhSW3mWmEwsfxCeSDSKAVAQg4e2Dv7F4hs2lbY+t
FtW0ILHT8B/w0O5slDR8lJWkNOgGicdOr/npVpUym9iZt5trk40pLt1PaP+PwcT6
Xp6YsFPr/vltkcLo3x9lzSyT1Z4xUeWJsnABvlu/CoHQiqINkQ6pzyBDnBHm5DbF
XdkQl+sNgexsIYQpSKJAh8UNmsOxb8GHlROjVrsCAqdcK3sx+u5eW5WyTe/zl2gG
I0hqk8QtNse4BPuDvVA4tS+VPqk/NYEP3QdxE7+r+U4y6UY5GusQtqpvTYRSIHyk
XZZAXGHjxUWwHrK0yIBZP7i94Dh2mue4J9fa8kotrtPFRG5h2WYeqa57DWwar3wh
ieOd9QFgqA==
=Jh8z
-----END PGP SIGNATURE-----

#1121759#15
Date:
2025-08-04 08:37:50 UTC
From:
To:
this change has some unintended (?) effects for at least 32bit little
endian targets as well.  It changes at least the Provides in
gnat-14-arm-linux-gnueabihf in 14.3.0-4, compared to -3.

That should be fixed. As a work around, I'll apply this patch only for
32bit big-endian targets for now.

#1121759#24
Date:
2025-12-02 03:00:52 UTC
From:
To:
now updating the patch for gcc-16.  I see this is not yet forwarded?