[gcc-7] 237/354: gnatmake: compile once even with SOURCE_DATE_EPOCH. Closes: #866029.

Ximin Luo infinity0 at debian.org
Thu Nov 23 15:50:59 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository gcc-7.

commit 6a145f15f9cc43ac00013d174387b0cc76242cc4
Author: nicolas <nicolas at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date:   Wed Jun 28 16:43:50 2017 +0000

    gnatmake: compile once even with SOURCE_DATE_EPOCH. Closes: #866029.
    
    git-svn-id: svn+ssh://svn.debian.org/svn/gcccvs/branches/sid/gcc-7@9555 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
 debian/changelog                                   |   1 +
 debian/patches/ada-lib-info-source-date-epoch.diff | 156 ++++++++-------------
 2 files changed, 63 insertions(+), 94 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2cb56f2..e7d189e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,7 @@ gcc-7 (7.1.0-7ubuntu1) UNRELEASED; urgency=medium
   * Update ada/confirm_debian_bugs.py for gcc-7.
   * Drop ada-driver-check.diff, the problem is unreproducible.
   * Stop symlinking gcc-7-7 -> gcc-7. See #856274 and #814977.
+  * gnatmake: compile once even with SOURCE_DATE_EPOCH. Closes: #866029.
 
  -- Matthias Klose <doko at debian.org>  Tue, 27 Jun 2017 13:19:14 +0200
 
diff --git a/debian/patches/ada-lib-info-source-date-epoch.diff b/debian/patches/ada-lib-info-source-date-epoch.diff
index 45802da..d012b43 100644
--- a/debian/patches/ada-lib-info-source-date-epoch.diff
+++ b/debian/patches/ada-lib-info-source-date-epoch.diff
@@ -6,114 +6,82 @@ Description: set ALI timestamps from SOURCE_DATE_EPOCH if available.
  https://reproducible-builds.org/specs/source-date-epoch/
 Author: Nicolas Boulenguez <nicolas at debian.org>
 
+--- a/src/gcc/ada/ali-util.adb
++++ b/src/gcc/ada/ali-util.adb
+@@ -484,8 +484,10 @@
+       for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop
+          Src := Source_Id (Get_Name_Table_Int (Sdep.Table (D).Sfile));
+ 
+-         if Opt.Minimal_Recompilation
+-           and then Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
++         if (Opt.Minimal_Recompilation
++             and then Sdep.Table (D).Stamp /= Source.Table (Src).Stamp)
++           or else (Sdep.Table (D).Stamp = Source_Date_Epoch
++                    and then Source_Date_Epoch < Source.Table (Src).Stamp)
+          then
+             --  If minimal recompilation is in action, replace the stamp
+             --  of the source file in the table if checksums match.
 --- a/src/gcc/ada/lib-writ.adb
 +++ b/src/gcc/ada/lib-writ.adb
-@@ -54,6 +54,7 @@
- with Uname;    use Uname;
- 
- with System.Case_Util; use System.Case_Util;
-+with System.OS_Lib;
- with System.WCh_Con;   use System.WCh_Con;
- 
- package body Lib.Writ is
-@@ -62,6 +63,15 @@
-    -- Local Subprograms --
-    -----------------------
- 
-+   procedure Truncate_To_Source_Date_Epoch (T : in out Time_Stamp_Type);
-+   pragma Inline (Truncate_To_Source_Date_Epoch);
-+   --  If SOURCE_DATE_EPOCH is defined in the environment and
-+   --  represents an UNIX epoch, T is truncated to this date.
-+
-+   --  This allows reproducible ALI contents even for sources patched
-+   --  or generated at build time.
-+   --  https://reproducible-builds.org/specs/source-date-epoch/
-+
-    procedure Write_Unit_Name (N : Node_Id);
-    --  Used to write out the unit name for R (pragma Restriction) lines
-    --  for uses of Restriction (No_Dependence => unit-name).
-@@ -175,6 +185,65 @@
-       end;
-    end Ensure_System_Dependency;
- 
-+   -----------------------------------
-+   -- Truncate_To_Source_Date_Epoch --
-+   -----------------------------------
-+
-+   --  An internal state caches the result of the getenv() system call
-+   --  during first execution.  The Source_Date_Unset case could be
-+   --  replaced with a Source_Date far in the future, but we want to
-+   --  avoid Time_Stamp_Type comparisons in the most common case.
-+
-+   type A_Source_Date_State is
-+     (Source_Date_Unknown, Source_Date_Unset, Source_Date_Set);
-+   Source_Date_State : A_Source_Date_State := Source_Date_Unknown;
-+   Source_Date       : Time_Stamp_Type;
-+
-+   procedure Truncate_To_Source_Date_Epoch (T : in out Time_Stamp_Type) is
-+   begin
-+      case Source_Date_State is
-+         when Source_Date_Unset =>
-+            null;
-+         when Source_Date_Set =>
-+            if Source_Date < T then
-+               T := Source_Date;
-+            end if;
-+         when Source_Date_Unknown =>
-+            declare
-+               use System.OS_Lib;
-+               Env_Var : String_Access;
-+               Get_OK  : Boolean;
-+               Epoch   : OS_Time;
-+               Y       : Year_Type;
-+               Mo      : Month_Type;
-+               D       : Day_Type;
-+               H       : Hour_Type;
-+               Mn      : Minute_Type;
-+               S       : Second_Type;
-+            begin
-+               Env_Var := Getenv ("SOURCE_DATE_EPOCH");
-+               Get_OS_Time_From_String (Env_Var.all, Get_OK, Epoch);
-+               Free (Env_Var);
-+               if Get_OK then
-+                  GM_Split (Epoch, Y, Mo, D, H, Mn, S);
-+                  Make_Time_Stamp (Year    => Nat (Y),
-+                                   Month   => Nat (Mo),
-+                                   Day     => Nat (D),
-+                                   Hour    => Nat (H),
-+                                   Minutes => Nat (Mn),
-+                                   Seconds => Nat (S),
-+                                   TS      => Source_Date);
-+                  Source_Date_State := Source_Date_Set;
-+                  if Source_Date < T then
-+                     T := Source_Date;
-+                  end if;
-+               else
-+                  Source_Date_State := Source_Date_Unset;
-+               end if;
-+            end;
-+      end case;
-+   end Truncate_To_Source_Date_Epoch;
-+
-    ---------------
-    -- Write_ALI --
-    ---------------
-@@ -1471,7 +1540,14 @@
+@@ -1471,7 +1471,14 @@
  
                 Write_Info_Name_May_Be_Quoted (Fname);
                 Write_Info_Tab (25);
 -               Write_Info_Str (String (Time_Stamp (Sind)));
-+
 +               declare
 +                  T : Time_Stamp_Type := Time_Stamp (Sind);
 +               begin
-+                  Truncate_To_Source_Date_Epoch (T);
++                  if Source_Date_Epoch < T then
++                     T := Source_Date_Epoch;
++                  end if;
 +                  Write_Info_Str (String (T));
 +               end;
-+
                 Write_Info_Char (' ');
                 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
  
+--- a/src/gcc/ada/osint.adb
++++ b/src/gcc/ada/osint.adb
+@@ -1674,6 +1674,20 @@
+ 
+       Lib_Search_Directories.Set_Last (Primary_Directory);
+       Lib_Search_Directories.Table (Primary_Directory) := new String'("");
++
++      --  Look for Source_Date_Epoch in the environment.
++      declare
++         Env_Var : String_Access;
++         Get_OK  : Boolean;
++         Epoch   : OS_Time;
++      begin
++         Env_Var := Getenv ("SOURCE_DATE_EPOCH");
++         Get_OS_Time_From_String (Env_Var.all, Get_OK, Epoch);
++         Free (Env_Var);
++         if Get_OK then
++            Source_Date_Epoch := OS_Time_To_GNAT_Time (Epoch);
++         end if;
++      end;
+    end Initialize;
+ 
+    ------------------
+--- a/src/gcc/ada/osint.ads
++++ b/src/gcc/ada/osint.ads
+@@ -685,6 +685,17 @@
+    function Prep_Suffix return String;
+    --  The suffix used for pre-processed files
+ 
++   Source_Date_Epoch : Time_Stamp_Type := Time_Stamp_Type'("99991231235959");
++   --  * gnat1 truncates to this date time stamps written to ALI files, making
++   --    their contents deterministic even for patched or generated sources.
++   --    See https://reproducible-builds.org/specs/source-date-epoch.
++   --  * When gnatmake reads this date from an ALI file, and the source file is
++   --    more recent, it ignores the dates and only considers checksums as if
++   --    Minimal_Recompilation was selected. Else, the source would always
++   --    be detected as requiring a recompilation.
++   --  The default value has no effect, but Initialize will assign it if
++   --  SOURCE_DATE_EPOCH in the environment represents a valid epoch.
++
+ private
+ 
+    Current_Main : File_Name_Type := No_File;
 --- a/src/gcc/ada/s-os_lib.adb
 +++ b/src/gcc/ada/s-os_lib.adb
 @@ -1153,6 +1153,41 @@

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-7.git



More information about the Reproducible-commits mailing list