This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH 2/2] Allow to override build date with SOURCE_DATE_EPOCH
- From: John Darrington <john at darrington dot wattle dot id dot au>
- To: "Bernhard M. Wiedemann" <bwiedemann at suse dot de>
- Cc: binutils at sourceware dot org, Linda Zhang <lindasc at qq dot com>, Nick Clifton <nickc at redhat dot com>
- Date: Fri, 26 Oct 2018 12:54:05 +0200
- Subject: Re: [PATCH 2/2] Allow to override build date with SOURCE_DATE_EPOCH
- References: <20181026055927.23012-1-bwiedemann@suse.de> <20181026055927.23012-2-bwiedemann@suse.de>
I don't agree that this is an elegant solution to the problem.
SOURCE_DATE_EPOCH is a hack at best, to be used when there is no other
practical way to solve the problem.
Binutils already has a --enable-deterministic-archives option so we
should use that instead.
J'
On Fri, Oct 26, 2018 at 07:59:27AM +0200, Bernhard M. Wiedemann wrote: in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.
This helps making xen efi binaries build reproducibly by default
much more elegantly than
https://lists.xenproject.org/archives/html/xen-devel/2018-10/msg01850.html
---
bfd/peXXigen.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index bfa21166ae..778dbf1191 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -880,7 +880,14 @@ _bfd_XXi_only_swap_filehdr_out (bfd * abfd, void * in, void * out)
/* Use a real timestamp by default, unless the no-insert-timestamp
option was chosen. */
if ((pe_data (abfd)->insert_timestamp))
- H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
+ {
+ time_t build_time;
+ const char *source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
+ if (source_date_epoch == NULL
+ || (build_time = strtoll (source_date_epoch, NULL, 10)) <= 0)
+ build_time = time (0);
+ H_PUT_32 (abfd, build_time, filehdr_out->f_timdat);
+ }
else
H_PUT_32 (abfd, 0, filehdr_out->f_timdat);
--
2.16.4
--
Avoid eavesdropping. Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.