| Store | Cart

[perl #125830] Building perl reproducibly: __DATE__ and __TIME__ usage in perl.c

From: Dominic Hargreaves via RT <perl...@perl.org>
Fri, 28 Aug 2015 14:35:48 -0700
Here is the final version of this patch included in Debian, with the reindentation requested by Tony. I believe this should be suitable for inclusion in blead (and indeed it applies cleanly).

Thanks,
Dominic.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=125830

From 5915800fd10cbb59be3f1b3639ebb1a7ce5ea88c Mon Sep 17 00:00:00 2001
From: Niko Tyni <nty...@debian.org>
Date: Sun, 12 Jul 2015 22:23:00 +0300
Subject: Allow overriding the compile time in "perl -V" output

The C preprocessor macros __DATE__ and __TIME__ embed the compile time
into the binary for the purposes of "perl -V" output. This makes the
build unreproducible: compiling the same source with the same toolchain
cannot be made to yield bitwise identical binaries and other generated
files.

The compile time can now be overridden with the PERL_BUILD_DATE macro.

Bug: https://rt.perl.org/Ticket/Display.html?id=125830
Bug-Debian: https://bugs.debian.org/774422
Patch-Name: debian/do-not-record-build-date.diff
---
 perl.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/perl.c b/perl.c
index e64f1f4..4d835d2 100644
--- a/perl.c
+++ b/perl.c
@@ -1795,15 +1795,20 @@ S_Internals_V(pTHX_ CV *cv)
     PUSHs(Perl_newSVpvn_flags(aTHX_ non_bincompat_options,
 			      sizeof(non_bincompat_options) - 1, SVs_TEMP));
 
-#ifdef __DATE__
-#  ifdef __TIME__
+#ifndef PERL_BUILD_DATE
+#  ifdef __DATE__
+#    ifdef __TIME__
+#      define PERL_BUILD_DATE __DATE__ " " __TIME__
+#    else
+#      define PERL_BUILD_DATE __DATE__
+#    endif
+#  endif
+#endif
+
+#ifdef PERL_BUILD_DATE
     PUSHs(Perl_newSVpvn_flags(aTHX_
-			      STR_WITH_LEN("Compiled at " __DATE__ " " __TIME__),
-			      SVs_TEMP));
-#  else
-    PUSHs(Perl_newSVpvn_flags(aTHX_ STR_WITH_LEN("Compiled on " __DATE__),
+			      STR_WITH_LEN("Compiled at " PERL_BUILD_DATE),
 			      SVs_TEMP));
-#  endif
 #else
     PUSHs(&PL_sv_undef);
 #endif

Recent Messages in this Thread
Niko Tyni (via RT) Aug 17, 2015 04:29 pm
Tony Cook via RT Aug 18, 2015 06:34 am
Niko Tyni Aug 18, 2015 04:30 pm
H.Merijn Brand Aug 18, 2015 05:42 pm
Dominic Hargreaves Aug 18, 2015 07:29 pm
Dominic Hargreaves via RT Aug 28, 2015 09:35 pm
Jim Cromie Sep 02, 2015 03:58 am
Niko Tyni Aug 18, 2015 04:12 pm
Tony Cook via RT Aug 19, 2015 01:56 am
Niko Tyni Aug 22, 2015 07:44 am
bulk88 via RT Aug 18, 2015 02:59 pm
Messages in this thread