From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:50482) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJPgt-0007mP-Jo for guix-patches@gnu.org; Tue, 31 Mar 2020 18:49:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJPgr-00084G-TZ for guix-patches@gnu.org; Tue, 31 Mar 2020 18:49:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53887) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJPgr-000842-QK for guix-patches@gnu.org; Tue, 31 Mar 2020 18:49:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jJPgr-0001qq-ND for guix-patches@gnu.org; Tue, 31 Mar 2020 18:49:01 -0400 Subject: [bug#40362] [PATCH] gnu: cross-base: Add mingw-w64 specific binutils patches. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:49463) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJPga-0007lz-3a for guix-patches@gnu.org; Tue, 31 Mar 2020 18:48:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJPgU-0007AB-VQ for guix-patches@gnu.org; Tue, 31 Mar 2020 18:48:41 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:35724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJPgR-000727-Si for guix-patches@gnu.org; Tue, 31 Mar 2020 18:48:36 -0400 Date: Tue, 31 Mar 2020 22:48:24 +0000 From: Carl Dong Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Carl Dong Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40362@debbugs.gnu.org These patches were originally found at the debian mingw-w64 team's binutils repo, and should improve the reproducibility of our mingw-w64 toolchain. * gnu/packages/patches/binutils-mingw-w64-reproducible-import-libraries.pat= ch: New file. * gnu/packages/patches/binutils-mingw-w64-specify-timestamp.patch: New file. * gnu/packages/cross-base.scm (cross-binutils): Apply relevant patches if target is mingw-w64. (package-with-extra-patches): New procedure. --- gnu/packages/cross-base.scm | 21 ++- ...gw-w64-reproducible-import-libraries.patch | 22 +++ ...binutils-mingw-w64-specify-timestamp.patch | 137 ++++++++++++++++++ 3 files changed, 175 insertions(+), 5 deletions(-) create mode 100755 gnu/packages/patches/binutils-mingw-w64-reproducible-im= port-libraries.patch create mode 100755 gnu/packages/patches/binutils-mingw-w64-specify-timesta= mp.patch diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index ab866eebc6..571a47f72a 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -76,6 +76,12 @@ (source (origin (inherit (package-source original)) (patches (list patch)))))) +(define (package-with-extra-patches original patches) + "Return package ORIGINAL with all PATCHES appended to its list of patche= s." + (package-with-patch original + `(,@(origin-patches (package-source original)) + ,@patches)) + (define (cross-binutils target) "Return a cross-Binutils for TARGET." (let ((binutils (package (inherit binutils) @@ -97,11 +103,16 @@ `(cons "--with-sysroot=3D/" ,flags))))))) ;; For Xtensa, apply Qualcomm's patch. - (cross (if (string-prefix? "xtensa-" target) - (package-with-patch binutils - (search-patch - "ath9k-htc-firmware-binutils.patch")) - binutils) + (cross (cond ((string-prefix? "xtensa-" target) + (package-with-patch binutils + (search-patch + "ath9k-htc-firmware-binutils.patch"= ))) + ((target-mingw? target) + (package-with-extra-patches binutils + (search-patches + "binutils-mingw-w64-specify= -timestamp.patch" + "binutils-mingw-w64-reprodu= cible-import-libraries.patch"))) + (else binutils)) target))) (define (cross-gcc-arguments target xgcc libc) diff --git a/gnu/packages/patches/binutils-mingw-w64-reproducible-import-li= braries.patch b/gnu/packages/patches/binutils-mingw-w64-reproducible-import= -libraries.patch new file mode 100755 index 0000000000..3e48b87935 --- /dev/null +++ b/gnu/packages/patches/binutils-mingw-w64-reproducible-import-libraries= .patch @@ -0,0 +1,22 @@ +This following patch was originally found at the debian mingw-w64 team's +binutils repo located here: +https://salsa.debian.org/mingw-w64-team/binutils-mingw-w64.git + +Invoke the following in the aforementioned repo to see the original patch: + + $ git show da63f6b:debian/patches/reproducible-import-libraries.patch + +Description: Make DLL import libraries reproducible +Author: Benjamin Moody +Bug-Debian: https://bugs.debian.org/915055 + +--- a/ld/pe-dll.c ++++ b/ld/pe-dll.c +@@ -2844,6 +2844,7 @@ + + bfd_set_format (outarch, bfd_archive); + outarch->has_armap =3D 1; ++ outarch->flags |=3D BFD_DETERMINISTIC_OUTPUT; + + /* Work out a reasonable size of things to put onto one line. */ + ar_head =3D make_head (outarch); diff --git a/gnu/packages/patches/binutils-mingw-w64-specify-timestamp.patc= h b/gnu/packages/patches/binutils-mingw-w64-specify-timestamp.patch new file mode 100755 index 0000000000..b785043b62 --- /dev/null +++ b/gnu/packages/patches/binutils-mingw-w64-specify-timestamp.patch @@ -0,0 +1,137 @@ +This following patch was originally found at the debian mingw-w64 team's +binutils repo located here: +https://salsa.debian.org/mingw-w64-team/binutils-mingw-w64.git + +Invoke the following in the aforementioned repo to see the original patch: + + $ git show da63f6b:debian/patches/specify-timestamp.patch + +Description: Allow the PE timestamp to be specified +Author: Stephen Kitt + +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -70,6 +70,9 @@ + #include + #endif + ++#include ++#include ++ + /* NOTE: it's strange to be including an architecture specific header + in what's supposed to be general (to PE/PEI) code. However, that's + where the definitions are, and they don't vary per architecture +@@ -879,10 +882,38 @@ + + /* 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); +- else ++ if (pe_data (abfd)->insert_timestamp) { ++ time_t now; ++ char *source_date_epoch; ++ unsigned long long epoch; ++ char *endptr; ++ ++ now =3D time(NULL); ++ source_date_epoch =3D getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ errno =3D 0; ++ epoch =3D strtoull(source_date_epoch, &endptr, 10); ++ if ((errno =3D=3D ERANGE && (epoch =3D=3D ULLONG_MAX || epoch =3D= =3D 0)) ++ || (errno !=3D 0 && epoch =3D=3D 0)) { ++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: strt= oull: %s\n", ++ strerror(errno)); ++ } else if (endptr =3D=3D source_date_epoch) { ++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: No d= igits were found: %s\n", ++ endptr); ++ } else if (*endptr !=3D '\0') { ++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: Trai= ling garbage: %s\n", ++ endptr); ++ } else if (epoch > ULONG_MAX) { ++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: valu= e must be smaller than or equal to: %lu but was found to be: %llu\n", ++ ULONG_MAX, epoch); ++ } else { ++ now =3D epoch; ++ } ++ } ++ H_PUT_32 (abfd, now, filehdr_out->f_timdat); ++ } else { + H_PUT_32 (abfd, 0, filehdr_out->f_timdat); ++ } + + PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, + =09=09 filehdr_out->f_symptr); +--- a/ld/pe-dll.c ++++ b/ld/pe-dll.c +@@ -26,6 +26,8 @@ + #include "filenames.h" + #include "safe-ctype.h" + ++#include ++#include + #include + + #include "ld.h" +@@ -1202,8 +1204,36 @@ + + memset (edata_d, 0, edata_sz); + +- if (pe_data (abfd)->insert_timestamp) +- H_PUT_32 (abfd, time (0), edata_d + 4); ++ if (pe_data (abfd)->insert_timestamp) { ++ time_t now; ++ char *source_date_epoch; ++ unsigned long long epoch; ++ char *endptr; ++ ++ now =3D time(NULL); ++ source_date_epoch =3D getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) { ++ errno =3D 0; ++ epoch =3D strtoull(source_date_epoch, &endptr, 10); ++ if ((errno =3D=3D ERANGE && (epoch =3D=3D ULLONG_MAX || epoch =3D= =3D 0)) ++=09 || (errno !=3D 0 && epoch =3D=3D 0)) { ++=09einfo("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n", ++=09 strerror(errno)); ++ } else if (endptr =3D=3D source_date_epoch) { ++=09einfo("Environment variable $SOURCE_DATE_EPOCH: No digits were found: = %s\n", ++=09 endptr); ++ } else if (*endptr !=3D '\0') { ++=09einfo("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n= ", ++=09 endptr); ++ } else if (epoch > ULONG_MAX) { ++=09einfo("Environment variable $SOURCE_DATE_EPOCH: value must be smaller = than or equal to: %lu but was found to be: %llu\n", ++=09 ULONG_MAX, epoch); ++ } else { ++=09now =3D epoch; ++ } ++ } ++ H_PUT_32 (abfd, now, edata_d + 4); ++ } + + if (pe_def_file->version_major !=3D -1) + { +--- a/ld/emultempl/pe.em ++++ b/ld/emultempl/pe.em +@@ -303,7 +303,7 @@ + OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, + {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERS= CORE}, + {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE}, +- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP}, ++ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP= }, + {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP= }, + #ifdef DLL_SUPPORT + /* getopt allows abbreviations, so we do this to stop it +--- a/ld/emultempl/pep.em ++++ b/ld/emultempl/pep.em +@@ -321,7 +321,7 @@ + {"no-bind", no_argument, NULL, OPTION_NO_BIND}, + {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER}, + {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE}, +- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP}, ++ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP= }, + {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP= }, + {"build-id", optional_argument, NULL, OPTION_BUILD_ID}, + {NULL, no_argument, NULL, 0} -- 2.25.1