[gcc-7] 119/354: [ Nicolas Boulenguez ] * Use SOURCE_DATE_EPOCH for reproducible ALI timestamps. Closes: #856042.
Ximin Luo
infinity0 at debian.org
Thu Nov 23 15:50:40 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 86f7e3bb3e2c4895c6873cd5f844e50f49f134d0
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date: Wed Mar 1 08:50:51 2017 +0000
[ Nicolas Boulenguez ]
* Use SOURCE_DATE_EPOCH for reproducible ALI timestamps. Closes: #856042.
git-svn-id: svn+ssh://svn.debian.org/svn/gcccvs/branches/sid/gcc-7@9320 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
debian/changelog | 5 +
debian/patches/ada-lib-info-source-date-epoch.diff | 174 +++++++++++++++++++++
debian/rules.patch | 1 +
3 files changed, 180 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index a32a29b..87680be 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,16 @@
gcc-7 (7-20170227-1) experimental; urgency=medium
* GCC 7 snapshot build, taken from the trunk 20170227.
+
+ [ Matthias Klose ]
* Update gdc to trunk 20170227.
* Update libcc1 symbols file.
* Bump binutils version requirement.
* Allow to disable brig in DEB_BUILD_OPTIONS. Closes: #856452.
+ [ Nicolas Boulenguez ]
+ * Use SOURCE_DATE_EPOCH for reproducible ALI timestamps. Closes: #856042.
+
-- Matthias Klose <doko at debian.org> Mon, 27 Feb 2017 14:29:03 +0100
gcc-7 (7-20170226-1) experimental; urgency=medium
diff --git a/debian/patches/ada-lib-info-source-date-epoch.diff b/debian/patches/ada-lib-info-source-date-epoch.diff
new file mode 100644
index 0000000..684f332
--- /dev/null
+++ b/debian/patches/ada-lib-info-source-date-epoch.diff
@@ -0,0 +1,174 @@
+# DP: When the SOURCE_DATE_EPOCH environment variable is set,
+# DP: replace timestamps more recent than its value with its value
+# DP: when writing Ada Library Information (ALI) files.
+# DP: This allow reproducible builds from generated or patched Ada sources.
+# DP: https://reproducible-builds.org/specs/source-date-epoch/
+
+--- 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 @@
+
+ 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);
++ Write_Info_Str (String (T));
++ end;
++
+ Write_Info_Char (' ');
+ Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
+
+--- a/src/gcc/ada/s-os_lib.adb
++++ b/src/gcc/ada/s-os_lib.adb
+@@ -1153,6 +1153,41 @@
+ return Result;
+ end Get_Object_Suffix;
+
++ -----------------------------
++ -- Get_OS_Time_From_String --
++ -----------------------------
++
++ procedure Get_OS_Time_From_String (Arg : String;
++ Success : out Boolean;
++ Result : out OS_Time) is
++ -- Calling System.Val_LLI breaks the bootstrap sequence.
++ Digit : OS_Time;
++ begin
++ Result := 0;
++ if Arg'Length = 0 then
++ Success := False;
++ return;
++ end if;
++ for I in Arg'Range loop
++ if Arg (I) not in '0' .. '9' then
++ Success := False;
++ return;
++ end if;
++ Digit := OS_Time (Character'Pos (Arg (I)) - Character'Pos ('0'));
++ if OS_Time'Last / 10 < Result then
++ Success := False;
++ return;
++ end if;
++ Result := Result * 10;
++ if OS_Time'Last - Digit < Result then
++ Success := False;
++ return;
++ end if;
++ Result := Result + Digit;
++ end loop;
++ Success := True;
++ end Get_OS_Time_From_String;
++
+ ----------------------------------
+ -- Get_Target_Debuggable_Suffix --
+ ----------------------------------
+--- a/src/gcc/ada/s-os_lib.ads
++++ b/src/gcc/ada/s-os_lib.ads
+@@ -164,6 +164,13 @@
+ -- component parts to be interpreted in the local time zone, and returns
+ -- an OS_Time. Returns Invalid_Time if the creation fails.
+
++ procedure Get_OS_Time_From_String (Arg : String;
++ Success : out Boolean;
++ Result : out OS_Time);
++ -- Success is set if Arg is not empty, only contains decimal
++ -- digits and represents an integer within OS_Time range. Result
++ -- is then affected with the represented value.
++
+ ----------------
+ -- File Stuff --
+ ----------------
diff --git a/debian/rules.patch b/debian/rules.patch
index 206958c..3c2696d 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -145,6 +145,7 @@ debian_patches += ada-arm
#endif
debian_patches += ada-link-shlib
+ debian_patches += ada-lib-info-source-date-epoch
#endif
--
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