Package: gnat-13 Version: 13.2.0-19 Severity: normal X-Debbugs-Cc: lbre...@debian.org Control: affects -1 pcscada libalog dbusada anet ahven libgmpada libgtkada libgnatcoll-db libncursesada libaunit adacgi liblog4ada libtexttools libtemplates-parser libxmlezout libgnatcoll-bindings libgnatcoll gprbuild
Hello. Most Ada packages randomly FTBFS on 32 bit architectures with gprbuild: raised CONSTRAINT_ERROR : a-calend.adb:371 overflow check failed The problem originates in the gcc-13 switch to time_t64. gcc/ada/libgnat/s-os_prim__posix.adb is affected by two apparently distinct issues. * s-os_prim.adb allocates 3Long_Integer=3void*=3*32 bits for the timeval C struct, while 2*64bits = 2Long_Long_Integer are now needed. This issue affects other files, but is easy to find and fix. * The switch breaks the call from Ada to the C gettimeofday function. Can anyone explain this, and ideally provide a real fix instead of the ugly work-around below? cat > mycal.c <<EOF #include <sys/time.h> int mygettimeofday(struct timeval *restrict tv, struct timezone *restrict tz) { return gettimeofday(tv, tz); } EOF cat > foo.adb <<EOF with Ada.Text_IO, System.OS_Primitives; procedure Foo is -- On armhf, array(1..3) of Long_Integer gives random usec values. type timeval is array (1 .. 2) of Long_Long_Integer; procedure timeval_to_duration (T : not null access timeval; sec : not null access Long_Long_Integer; usec : not null access Long_Integer); pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration"); sec : aliased Long_Long_Integer; usec : aliased Long_Integer; TV : aliased timeval; function gettimeofday (Tv : access timeval; Tz : System.Address := System.Null_Address) return Integer; -- On armhf, a direct import of gettimeofday leads to random Tv values. pragma Import (C, gettimeofday, "mygettimeofday"); Result : constant Integer := gettimeofday (TV'Access, System.Null_Address); SOP : constant Duration := System.OS_Primitives.Clock; begin timeval_to_duration (TV'Access, sec'Access, usec'Access); Ada.Text_IO.Put_Line ("local :" & Sec'Img & "." & Usec'Img); Ada.Text_IO.Put_Line ("System.OS_Primitives:" & SOP'Img); end Foo; EOF gcc -c mycal.c -o mycal.o gnatmake -gnat2022 foo -largs mycal.o echo -n 'Machine : '; uname -m date '+Expected : %s' ./foo Machine : x86_64 (amd64 x86_64-linux-gnu) Expected : 1711035183 local : 1711035183. 324545 System.OS_Primitives: 1711035183.324549000 Machine : armv7l (armhf arm-gnu-eabi) Expected : 1711035189 local : 1711035189. 551691 System.OS_Primitives: 1113580361.675821568