Toggle diff (99 lines)
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 890d57941f..5c523ae7ad 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -997,13 +997,15 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
(inherit binutils)
(name "binutils-mesboot0")
(version "2.14")
- (source (origin
- (method url-fetch)
- (uri (string-append "mirror://gnu/binutils/binutils-"
- version ".tar.gz"))
- (sha256
- (base32
- "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
+ (source (bootstrap-origin
+ (origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnu/binutils/binutils-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))
+ (patches (search-patches "binutils-2.14-deterministic-ar.patch")))))
(inputs '())
(propagated-inputs '())
(native-inputs (%boot-tcc-inputs))
diff --git a/gnu/packages/patches/binutils-2.14-deterministic-ar.patch b/gnu/packages/patches/binutils-2.14-deterministic-ar.patch
new file mode 100644
index 0000000000..7f9310e994
--- /dev/null
+++ b/gnu/packages/patches/binutils-2.14-deterministic-ar.patch
@@ -0,0 +1,66 @@
+Old binutils do not have support for creating deterministic archives.
+Backported from upstream commit 36e4dce69dd23bea9ea2258dea35f034b6d6351c
+
+Patch by Chris Demetriou <cgd@google.com> (2009), adapted by
+Andrius Štikonas <andrius@stikonas.eu> (2021).
+
+--- a/bfd/archive.c 2021-03-01 00:05:54.888301655 +0000
++++ b/bfd/archive.c 2021-03-02 21:53:51.001617689 +0000
+@@ -1396,10 +1396,6 @@
+ {
+ /* Assume we just "made" the member, and fake it. */
+ struct bfd_in_memory *bim = (struct bfd_in_memory *) member->iostream;
+- time (&status.st_mtime);
+- status.st_uid = getuid ();
+- status.st_gid = getgid ();
+- status.st_mode = 0644;
+ status.st_size = bim->size;
+ }
+ else if (stat (filename, &status) != 0)
+@@ -1408,6 +1404,11 @@
+ return NULL;
+ }
+
++ status.st_mtime = 0;
++ status.st_uid = 0;
++ status.st_gid = 0;
++ status.st_mode = 0644;
++
+ amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
+ ared = (struct areltdata *) bfd_zalloc (abfd, amt);
+ if (ared == NULL)
+@@ -2003,13 +2004,11 @@
+ stat (arch->filename, &statbuf);
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ sprintf (hdr.ar_name, RANLIBMAG);
+- /* Remember the timestamp, to keep it holy. But fudge it a little. */
+- bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
+ bfd_ardata (arch)->armap_datepos = (SARMAG
+ + offsetof (struct ar_hdr, ar_date[0]));
+- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
+- sprintf (hdr.ar_uid, "%ld", (long) getuid ());
+- sprintf (hdr.ar_gid, "%ld", (long) getgid ());
++ sprintf (hdr.ar_date, "%ld", 0);
++ sprintf (hdr.ar_uid, "%ld", 0);
++ sprintf (hdr.ar_gid, "%ld", 0);
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+ strncpy (hdr.ar_fmag, ARFMAG, 2);
+ for (i = 0; i < sizeof (struct ar_hdr); i++)
+@@ -2082,6 +2081,8 @@
+ struct ar_hdr hdr;
+ unsigned int i;
+
++ return TRUE;
++
+ /* Flush writes, get last-write timestamp from file, and compare it
+ to the timestamp IN the file. */
+ bfd_flush (arch);
+@@ -2169,7 +2170,7 @@
+ memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
+ hdr.ar_name[0] = '/';
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+- sprintf (hdr.ar_date, "%ld", (long) time (NULL));
++ sprintf (hdr.ar_date, "%ld", 0);
+ /* This, at least, is what Intel coff sets the values to. */
+ sprintf ((hdr.ar_uid), "%d", 0);
+ sprintf ((hdr.ar_gid), "%d", 0);