[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #58060|0 |1 is obsolete|| Attachment #58181|0 |1 is obsolete|| --- Comment #27 from Nicolas Boulenguez --- Created attachment 58252 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58252=edit Version 10, tarball with 8 commits + tests Hello. Version 10 * restores support for time_t in System.OS_Lib, with a comment saying that the type is now unrelated with C (patch 4/8). * restores support for timespec in Ada.Calendar.Conversions and timeval in GNAT.Calendar, via wrappers delegating to C_Time. The subtype ranges for the parameters are tighter, but that only makes preexisting pre- and post-conditions explicit. * unsuppresses the Overflow_Check * replaces pre- and post-conditions with subtype ranges * fixes a type name in docs (patch 3/8) * fixes a typo on android * roughly sorts the patches by decreasing importance (only 1-2 fix bugs) The restorations hopefully answer the concerns expressed by Arnaud Charlet at https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651794.html. In Ada.Calendar, the changes only affect the private part.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #26 from Nicolas Boulenguez --- Created attachment 58181 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58181=edit v9 fixing a typo in patch 9/9 "select 32 or 64 bits variants" The "select 32 or 64 bits variants" patch in v8 (attachment 58060) mispells OS_Constants in s-osinte__gnu.ads and breaks the build on hurd.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #25 from Nicolas Boulenguez --- The suggested changes for libgnat slightly affect gprbuild. https://salsa.debian.org/debian/gprbuild/-/blob/debian/master/debian/patches/adapt-to-private-time-t.diff https://salsa.debian.org/debian/gprbuild/-/blob/debian/master/debian/patches/adapt-to-private-timeval.diff
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #58028|0 |1 is obsolete|| --- Comment #24 from Nicolas Boulenguez --- Created attachment 58060 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58060=edit timeval timespec: merge all definitions, select 32 or 64 bits variants on glibc Hello. The second issue is caused by glibc implementing (on architectures where time_t was 32 bits by default) gettimeofday __gettimeofday64 and #defining gettimeofday __gettimeofday64 if __USE_TIME_BITS64. Ada, ignoring this, was still importing the 32 bits version. The attached archive patches all such issues as far as I know. The patch has been tested on x86_64-linux-gnu (time_t64 is the default) and arm-linux-gnueabihf (time_t64 is affected by __USE_TIME_BITS64).
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #23 from Nicolas Boulenguez --- Always with gcc-13.2.0+Debian patches on arm-linux-gnueabihf, if s-osprim__posix.adb imports and calls int __gnat_gettimeofday(struct timeval *restrict tv, struct timezone *restrict tz) { return gettimeofday(tv, tz); } defined in cal.c instead of directly importing and calling the C gettimeofday as it does for now, the returned date is correct. This suggests that there is a distinct issue and provides a workaround for it.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #57926|0 |1 is obsolete|| --- Comment #22 from Nicolas Boulenguez --- Created attachment 58028 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58028=edit merge all definitions and conversions for timeval and timespec Hello. Moving the definitions into System.CRTL was a bad idea because they are needed before the target libgnat is built. The attached version 6 creates a new System.C_Time unit. It also adds a script testing the C_Time functions against handwritten results on 32 combinations of type sizes for Duration, time_t and suseconds_t. With the first four patches applied, gcc-13.2.0 (with Debian patches) builds on x86_64-linux-gnu and arm-linux-gnueabihf. The following program then gives the correct date on x86_64-linux-gnu but random dates or Time_Error on arm-linux-gnueabihf. So the original issue remains. -- with Ada.Calendar, Ada.Text_IO; procedure Demo is Y : Ada.Calendar.Year_Number; M : Ada.Calendar.Month_Number; D : Ada.Calendar.Day_Number; S : Duration; H, Min : Integer; begin Ada.Calendar.Split (Ada.Calendar.Clock, Y, M, D, S); H := Integer ((S / 3_600) - 0.5); S := S - 3600 * Duration (H); Min := Integer ((S / 60) - 0.5); S := S - 60 * Duration (Min); Ada.Text_IO.Put_Line (Y'Img & M'Img & D'Img & H'Img & Min'Img & S'Img); end Demo; -- The commits are rebased on the trunk, with only trivial changes but untested.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #21 from Matthias Klose --- trying to update your patches, the build then fails with: ../../xgcc -B../../ -c -g -O2 -W -Wall -gnatpg -gnata -gnatn -I- -nostdinc -I/home/packages/gcc/14/gcc-14-14-20240424/build/gcc/ada/rts -I. -I/home/packages/ gcc/14/gcc-14-14-20240424/src/gcc/ada /home/packages/gcc/14/gcc-14-14-20240424/src/gcc/ada/osint.adb -o osint. o osint.adb:3281:17: error: "time_t" is undefined (more references follow) osint.adb:3295:28: error: invalid operand types for operator "*" osint.adb:3295:28: error: right operand has type universal integer make[5]: *** [../gcc-interface/Makefile:306: osint.o] Error 1
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #20 from Matthias Klose --- Nicolas, the patch series fails to apply on the trunk. Please could you update it, then post it on gcc-patches to get a proper review?
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #57890|0 |1 is obsolete|| Attachment #57897|0 |1 is obsolete|| --- Comment #19 from Nicolas Boulenguez --- Created attachment 57926 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57926=edit eight commits isolating the definition of C time types This version 5 fixes typos in commit 3 that were breaking the build with 1-3 applied only on x86_64-linux-gnu. Commit 8 is adapted so that the overall effect of 1-8 is unchanged.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #18 from Nicolas Boulenguez --- Created attachment 57897 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57897=edit rewrite commit 3/8 so that Duration'Size may be 32 Would version 4 of commit 3/8 be OK? It only modifies s-crtl.ad[bs]. A bit out of the subject, but if GNAT supports Duration'Size = 32, a-reatim.adb s-ransee.adb a-calend.adb probably deserve comments about the way the conversion deals with the size difference and sign bit.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #17 from Eric Botcazou --- Nice work indeed, in an area that clearly needed it, thanks! Something potentially problematic though: +package body System.CRTL is + + -- In GNAT, Duration'Size = 64. + function Duration_To_int64 is new Ada.Unchecked_Conversion + (Duration, int64); That's not universal, see Targparm: - -- Duration Format -- - -- By default, type Duration is a 64-bit fixed-point type with a delta -- and small of 10**(-9) (i.e. it is a count in nanoseconds). This flag -- allows that standard format to be modified. Duration_32_Bits_On_Target : Boolean := False; -- If True, then Duration is represented in 32 bits and the delta and -- small values are set to 20.0*(10**(-3)) (i.e. it is a count in units -- of 20 milliseconds). although Duration_32_Bit is indeed False in all the system-*.ads files.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #16 from Nicolas Boulenguez --- This 3rd attempt does the requested split. It fixes all build errors on Debian/amd64. The new Ada.Calendar.Clock returns sensible results. In other words, it seems ready for review.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #57866|0 |1 is obsolete|| Attachment #57867|0 |1 is obsolete|| Attachment #57868|0 |1 is obsolete|| Attachment #57869|0 |1 is obsolete|| Attachment #57876|0 |1 is obsolete|| --- Comment #15 from Nicolas Boulenguez --- Created attachment 57890 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57890=edit eight commits isolating the definition of C time types
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #14 from Nicolas Boulenguez --- The new version does not change much, but I am only posting it in order to prevent duplicated work. I will try to split the timespec changes and the timeval+Sockets changes, then attempt a build.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added Attachment #57865|0 |1 is obsolete|| --- Comment #13 from Nicolas Boulenguez --- Created attachment 57876 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57876=edit Ada: define time_t timeval timespec C types in a single place
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Arnaud Charlet changed: What|Removed |Added CC||charlet at gcc dot gnu.org --- Comment #12 from Arnaud Charlet --- Yes, on paper this looks like a very nice cleanup, thank you! The tricky part is to carefully review the conversion code, as well as the change in GNAT.Sockets* (perhaps consider separating the changes in GNAT.Socket* in another patch on top of the first one, that will ease the review if possible).
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #11 from Nicolas Boulenguez --- Created attachment 57869 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57869=edit Ada: import nanosleep from System.OS_Primitives.Timed_Delay
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #10 from Nicolas Boulenguez --- Created attachment 57868 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57868=edit Ada: drop unneeded darwin, solaris, x32 variants of System.OS_Primitives
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #9 from Nicolas Boulenguez --- Created attachment 57867 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57867=edit Ada: drop unneeded posix2008 variant of System.Parameters
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #8 from Nicolas Boulenguez --- Created attachment 57866 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57866=edit Ada: drop unneeded x32 variant of System.Linux
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #7 from Nicolas Boulenguez --- Hello. The attached suggestions (based on gcc-13/13.2.0) might solve the current issue, or at least simplify the investigation, but they are so intrusive that I would like a quick review by experts before testing anything. For now, I have not even tried a build. In principle, is there a chance that you accept such changes upstream, once/if they are tested in Debian? The main suggestion is of course 'Define time_t ... in a single place'. Then, ``` diff -u --color=auto libgnarl/s-linux{,__x32}.ads diff -u --color=auto libgnat/s-parame{,__posix2008}.ads diff -u --color=auto libgnat/s-osprim__{unix,solaris}.adb diff -u --color=auto libgnat/s-osprim__{rtems,darwin}.adb diff -u --color=auto libgnat/s-osprim__{rtems,x32}.adb ``` should validate the removal and the last suggestion should be trivial. Thanks in advance.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Nicolas Boulenguez changed: What|Removed |Added CC||nicolas at debian dot org --- Comment #6 from Nicolas Boulenguez --- Created attachment 57865 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57865=edit Ada: define time_t timeval timespec C types in a single place
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #5 from Eric Botcazou --- *** Bug 114424 has been marked as a duplicate of this bug. ***
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #4 from Eric Botcazou --- > is that the correct approach? most likely has to be guarded with a configure > option. The conditional setting is very likely superfluous, i.e. you can use the POSIX 2008 version whatever the multilib on Linux.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #3 from Matthias Klose --- Created attachment 57763 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57763=edit proposed patch is that the correct approach? most likely has to be guarded with a configure option.
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 --- Comment #2 from Andrew Pinski --- *** Bug 114424 has been marked as a duplicate of this bug. ***
[Bug ada/114065] gnat build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 fails on 32bit archs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065 Eric Botcazou changed: What|Removed |Added Last reconfirmed||2024-02-26 CC||ebotcazou at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from Eric Botcazou --- > however that's not the correct fix. Is there any way to fix this in a better > way? s-parame__posix2008.ads already has the 64-bit time_t so you just need to tweak Makefile.rtl.