[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1067453: gnat: Ada.Calendar.Clock crashes on time_t64 architectures



Source: gcc-13
Followup-For: Bug #1067453

Hello.

In case anyone tries to build attempt3 at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114065
in Debian, please:
 * disable debian/patches/libgnat-time64.diff in debian/rules.patch
 * adapt the current ada-lib-info-source-date-epoch.diff

--- a/debian/patches/ada-lib-info-source-date-epoch.diff
+++ b/debian/patches/ada-lib-info-source-date-epoch.diff
@@ -62,24 +62,26 @@ Author: Nicolas Boulenguez <nicolas@debian.org>
     end File_Stamp;
  
     function File_Stamp (Name : Path_Name_Type) return Time_Stamp_Type is
-@@ -3261,4 +3276,28 @@ begin
+@@ -3261,4 +3276,30 @@ begin
        Osint.Initialize;
     end Initialization;
  
 +   Set_Source_Date_Epoch : declare
++      --  See comments in OS_Time_To_GNAT_Time.
++      use type CRTL.int64;
++      function To_Ada is new Ada.Unchecked_Conversion (CRTL.int64, OS_Time);
 +      Env_Var : String_Access                 := Getenv ("SOURCE_DATE_EPOCH");
-+      Epoch   : time_t range 0 .. time_t'Last := 0;
-+      Digit   : time_t range 0 .. 9;
++      Epoch   : CRTL.int64 range 0 .. CRTL.int64'Last := 0;
++      Digit   : CRTL.int64 range 0 .. 9;
 +   begin
 +      if 0 < Env_Var.all'Length then
 +         --  Calling System.Val_LLI breaks the bootstrap sequence.
-+         --  First convert to time_t because OS_Time is private.
 +         for C of Env_Var.all loop
 +            if C not in '0' .. '9' then
 +               goto Finally;
 +            end if;
-+            Digit := time_t (Character'Pos (C) - Character'Pos ('0'));
-+            if (time_t'Last - Digit) / 10 < Epoch then
++            Digit := CRTL.int64 (Character'Pos (C) - Character'Pos ('0'));
++            if (CRTL.int64'Last - Digit) / 10 < Epoch then
 +               goto Finally;
 +            end if;
 +            Epoch := Epoch * 10 + Digit;


Reply to: