This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow overriding the compile time in "perl -V" output
authorNiko Tyni <ntyni@debian.org>
Sun, 12 Jul 2015 19:23:00 +0000 (22:23 +0300)
committerTony Cook <tony@develop-help.com>
Mon, 2 Nov 2015 22:21:20 +0000 (09:21 +1100)
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

diff --git a/perl.c b/perl.c
index f0d056f..b64975b 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1806,15 +1806,20 @@ S_Internals_V(pTHX_ CV *cv)
     PUSHs(Perl_newSVpvn_flags(aTHX_ non_bincompat_options,
                              sizeof(non_bincompat_options) - 1, SVs_TEMP));
 
     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_
     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));
                              SVs_TEMP));
-#  endif
 #else
     PUSHs(&PL_sv_undef);
 #endif
 #else
     PUSHs(&PL_sv_undef);
 #endif