[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser-build/master] Bug 26148: Update binutils to 2.31.1



commit 5631b327ab3654af5f2b329cf46fd67921004f41
Author: Nicolas Vigier <boklm@xxxxxxxxxxxxxx>
Date:   Thu Jan 10 21:59:07 2019 +0100

    Bug 26148: Update binutils to 2.31.1
    
    With older versions of binutils, the order in which .o files were
    included in an .a archive did not affect the output when linking a
    program or library, which is no longer the case with recent versions of
    binutils. To avoid reproducibility issues we patch the libtool version
    included in gcc to make the creation `libstdc++.a` reproducible.
---
 keyring/binutils.gpg                               |  Bin 1169 -> 3184 bytes
 projects/binutils/build                            |   12 +-
 projects/binutils/config                           |   11 +-
 .../binutils/fix-windows-reproducibility.patch     | 1034 --------------------
 projects/binutils/peXXigen.patch                   |   29 -
 projects/mingw-w64/build                           |    4 +
 projects/mingw-w64/config                          |    1 +
 projects/mingw-w64/libtool-sort.patch              |   67 ++
 8 files changed, 77 insertions(+), 1081 deletions(-)

diff --git a/keyring/binutils.gpg b/keyring/binutils.gpg
index 2de205d..d13540e 100644
Binary files a/keyring/binutils.gpg and b/keyring/binutils.gpg differ
diff --git a/projects/binutils/build b/projects/binutils/build
index 0d1c062..ee22a1c 100644
--- a/projects/binutils/build
+++ b/projects/binutils/build
@@ -16,18 +16,12 @@ distdir=/var/tmp/dist/binutils
   ln -s /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++_pic.a libstdc++.a
   export LDFLAGS="-L$rootdir -lstdc++"
 [% END %]
-tar xf [% project %]-[% c("version") %].tar.bz2
+tar xf [% project %]-[% c("version") %].tar.xz
 cd [% project %]-[% c("version") %]
 [% IF c('var/windows') -%]
-  # XXX: This is needed due to bug 10102.
-  sed 's/= extern_rt_rel_d;/= extern_rt_rel_d;\n  memset (extern_rt_rel_d, 0, PE_IDATA5_SIZE);/' -i ld/pe-dll.c
-  # Zeroing timestamps in PE headers reliably, see bug 12753.
-  patch -p1 < ../peXXigen.patch
-  # Needed for the hardening...
+  # Needed for the hardening... The upstream ticket is:
+  # https://sourceware.org/bugzilla/show_bug.cgi?id=17321
   patch -p1 < ../enable-reloc-section-ld.patch
-  # fix build reproducibility of Windows builds by reverting commit 13e570f80c.
-  # See bug 16472.
-  patch -p1 < ../fix-windows-reproducibility.patch
 [% END -%]
 [% IF c('var/windows-x86_64') -%]
   patch -p1 < ../64bit-fixups.patch
diff --git a/projects/binutils/config b/projects/binutils/config
index 1f992a2..2367280 100644
--- a/projects/binutils/config
+++ b/projects/binutils/config
@@ -1,5 +1,5 @@
 # vim: filetype=yaml sw=2
-version: 2.26.1
+version: 2.31.1
 filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
 var:
   configure_opt: '--disable-multilib --enable-gold --enable-deterministic-archives --enable-plugins'
@@ -10,12 +10,9 @@ targets:
   windows:
     var:
       configure_opt: '--target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-deterministic-archives'
-      arch_deps:
-        # texinfo required for fix-windows-reproducibility.patch
-        - texinfo
 
 input_files:
-  - URL: https://ftp.gnu.org/gnu/binutils/binutils-[% c("version") %].tar.bz2
+  - URL: https://ftp.gnu.org/gnu/binutils/binutils-[% c("version") %].tar.xz
     sig_ext: sig
     file_gpg_id: 1
     gpg_keyring: binutils.gpg
@@ -24,7 +21,3 @@ input_files:
     enable: '[% c("var/windows") %]'
   - filename: 64bit-fixups.patch
     enable: '[% c("var/windows-x86_64") %]'
-  - filename: peXXigen.patch
-    enable: '[% c("var/windows") %]'
-  - filename: fix-windows-reproducibility.patch
-    enable: '[% c("var/windows") %]'
diff --git a/projects/binutils/fix-windows-reproducibility.patch b/projects/binutils/fix-windows-reproducibility.patch
deleted file mode 100644
index 1fc5987..0000000
--- a/projects/binutils/fix-windows-reproducibility.patch
+++ /dev/null
@@ -1,1034 +0,0 @@
-From c6df45304e92aa2d7e9f2d8311ae5a0b1543daa8 Mon Sep 17 00:00:00 2001
-From: Nicolas Vigier <boklm@xxxxxxxxxxxxxx>
-Date: Wed, 16 May 2018 11:07:52 +0200
-Subject: [PATCH] Revert "Fix LTO vs. COFF archives"
-
-This reverts commit 13e570f80cbfb299a8858ce6830e91a6cb40ab7b.
----
- bfd/aoutx.h     |   2 -
- bfd/cofflink.c  | 116 +++++++++++++++---
- bfd/ecoff.c     | 164 +++++++++++++++++++++++--
- bfd/elflink.c   |  53 ++++++--
- bfd/libbfd-in.h |   4 +-
- bfd/libbfd.h    |   4 +-
- bfd/linker.c    | 366 ++++++++++++++++++++++++++++++++++++++++----------------
- bfd/pdp11.c     |   4 +-
- bfd/xcofflink.c |   4 +-
- 9 files changed, 560 insertions(+), 157 deletions(-)
-
-diff --git a/bfd/aoutx.h b/bfd/aoutx.h
-index 9385a98..6ca9c58 100644
---- a/bfd/aoutx.h
-+++ b/bfd/aoutx.h
-@@ -3405,8 +3405,6 @@ aout_link_check_ar_symbols (bfd *abfd,
- static bfd_boolean
- aout_link_check_archive_element (bfd *abfd,
- 				 struct bfd_link_info *info,
--				 struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED,
--				 const char *name ATTRIBUTE_UNUSED,
- 				 bfd_boolean *pneeded)
- {
-   bfd *oldbfd;
-diff --git a/bfd/cofflink.c b/bfd/cofflink.c
-index 2782795..3a82640 100644
---- a/bfd/cofflink.c
-+++ b/bfd/cofflink.c
-@@ -29,11 +29,9 @@
- #include "libcoff.h"
- #include "safe-ctype.h"
- 
--static bfd_boolean coff_link_add_object_symbols (bfd *, struct bfd_link_info *);
--static bfd_boolean coff_link_check_archive_element
--  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *,
--   bfd_boolean *);
--static bfd_boolean coff_link_add_symbols (bfd *, struct bfd_link_info *);
-+static bfd_boolean coff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info);
-+static bfd_boolean coff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, bfd_boolean *pneeded);
-+static bfd_boolean coff_link_add_symbols (bfd *abfd, struct bfd_link_info *info);
- 
- /* Return TRUE if SYM is a weak, external symbol.  */
- #define IS_WEAK_EXTERNAL(abfd, sym)			\
-@@ -192,6 +190,74 @@ coff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
-   return TRUE;
- }
- 
-+/* Look through the symbols to see if this object file should be
-+   included in the link.  */
-+
-+static bfd_boolean
-+coff_link_check_ar_symbols (bfd *abfd,
-+			    struct bfd_link_info *info,
-+			    bfd_boolean *pneeded,
-+			    bfd **subsbfd)
-+{
-+  bfd_size_type symesz;
-+  bfd_byte *esym;
-+  bfd_byte *esym_end;
-+
-+  *pneeded = FALSE;
-+
-+  symesz = bfd_coff_symesz (abfd);
-+  esym = (bfd_byte *) obj_coff_external_syms (abfd);
-+  esym_end = esym + obj_raw_syment_count (abfd) * symesz;
-+  while (esym < esym_end)
-+    {
-+      struct internal_syment sym;
-+      enum coff_symbol_classification classification;
-+
-+      bfd_coff_swap_sym_in (abfd, esym, &sym);
-+
-+      classification = bfd_coff_classify_symbol (abfd, &sym);
-+      if (classification == COFF_SYMBOL_GLOBAL
-+	  || classification == COFF_SYMBOL_COMMON)
-+	{
-+	  const char *name;
-+	  char buf[SYMNMLEN + 1];
-+	  struct bfd_link_hash_entry *h;
-+
-+	  /* This symbol is externally visible, and is defined by this
-+             object file.  */
-+	  name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
-+	  if (name == NULL)
-+	    return FALSE;
-+	  h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
-+
-+	  /* Auto import.  */
-+	  if (!h
-+	      && info->pei386_auto_import
-+	      && CONST_STRNEQ (name, "__imp_"))
-+	    h = bfd_link_hash_lookup (info->hash, name + 6, FALSE, FALSE, TRUE);
-+
-+	  /* We are only interested in symbols that are currently
-+	     undefined.  If a symbol is currently known to be common,
-+	     COFF linkers do not bring in an object file which defines
-+	     it.  */
-+	  if (h != (struct bfd_link_hash_entry *) NULL
-+	      && h->type == bfd_link_hash_undefined)
-+	    {
-+	      if (!(*info->callbacks
-+		    ->add_archive_element) (info, abfd, name, subsbfd))
-+		return FALSE;
-+	      *pneeded = TRUE;
-+	      return TRUE;
-+	    }
-+	}
-+
-+      esym += (sym.n_numaux + 1) * symesz;
-+    }
-+
-+  /* We do not need this object file.  */
-+  return TRUE;
-+}
-+
- /* Check a single archive element to see if we need to include it in
-    the link.  *PNEEDED is set according to whether this element is
-    needed in the link or not.  This is called via
-@@ -200,23 +266,41 @@ coff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
- static bfd_boolean
- coff_link_check_archive_element (bfd *abfd,
- 				 struct bfd_link_info *info,
--				 struct bfd_link_hash_entry *h,
--				 const char *name,
- 				 bfd_boolean *pneeded)
- {
--  *pneeded = FALSE;
-+  bfd *oldbfd;
-+  bfd_boolean needed;
- 
--  /* We are only interested in symbols that are currently undefined.
--     If a symbol is currently known to be common, COFF linkers do not
--     bring in an object file which defines it.  */
--  if (h->type != bfd_link_hash_undefined)
--    return TRUE;
-+  if (!_bfd_coff_get_external_symbols (abfd))
-+    return FALSE;
- 
--  if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd))
-+  oldbfd = abfd;
-+  if (!coff_link_check_ar_symbols (abfd, info, pneeded, &abfd))
-     return FALSE;
--  *pneeded = TRUE;
- 
--  return coff_link_add_object_symbols (abfd, info);
-+  needed = *pneeded;
-+  if (needed)
-+    {
-+      /* Potentially, the add_archive_element hook may have set a
-+	 substitute BFD for us.  */
-+      if (abfd != oldbfd)
-+	{
-+	  if (!info->keep_memory
-+	      && !_bfd_coff_free_symbols (oldbfd))
-+	    return FALSE;
-+	  if (!_bfd_coff_get_external_symbols (abfd))
-+	    return FALSE;
-+	}
-+      if (!coff_link_add_symbols (abfd, info))
-+	return FALSE;
-+    }
-+
-+  if (!info->keep_memory || !needed)
-+    {
-+      if (!_bfd_coff_free_symbols (abfd))
-+	return FALSE;
-+    }
-+  return TRUE;
- }
- 
- /* Add all the symbols from an object file to the hash table.  */
-diff --git a/bfd/ecoff.c b/bfd/ecoff.c
-index 01f51e6..2c915f0 100644
---- a/bfd/ecoff.c
-+++ b/bfd/ecoff.c
-@@ -3500,29 +3500,171 @@ ecoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
-   return FALSE;
- }
- 
-+/* Factored out from ecoff_link_check_archive_element.  */
-+
-+static bfd_boolean
-+read_ext_syms_and_strs (HDRR **symhdr, bfd_size_type *external_ext_size,
-+	bfd_size_type *esize, void **external_ext, char **ssext, bfd *abfd,
-+	const struct ecoff_backend_data * const backend)
-+{
-+  if (! ecoff_slurp_symbolic_header (abfd))
-+    return FALSE;
-+
-+  /* If there are no symbols, we don't want it.  */
-+  if (bfd_get_symcount (abfd) == 0)
-+    return TRUE;
-+
-+  *symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
-+
-+  *external_ext_size = backend->debug_swap.external_ext_size;
-+  *esize = (*symhdr)->iextMax * *external_ext_size;
-+  *external_ext = bfd_malloc (*esize);
-+  if (*external_ext == NULL && *esize != 0)
-+    return FALSE;
-+
-+  if (bfd_seek (abfd, (file_ptr) (*symhdr)->cbExtOffset, SEEK_SET) != 0
-+      || bfd_bread (*external_ext, *esize, abfd) != *esize)
-+    return FALSE;
-+
-+  *ssext = (char *) bfd_malloc ((bfd_size_type) (*symhdr)->issExtMax);
-+  if (*ssext == NULL && (*symhdr)->issExtMax != 0)
-+    return FALSE;
-+
-+  if (bfd_seek (abfd, (file_ptr) (*symhdr)->cbSsExtOffset, SEEK_SET) != 0
-+      || (bfd_bread (*ssext, (bfd_size_type) (*symhdr)->issExtMax, abfd)
-+	  != (bfd_size_type) (*symhdr)->issExtMax))
-+    return FALSE;
-+  return TRUE;
-+}
-+
-+static bfd_boolean
-+reread_ext_syms_and_strs (HDRR **symhdr, bfd_size_type *external_ext_size,
-+	bfd_size_type *esize, void **external_ext, char **ssext, bfd *abfd,
-+	const struct ecoff_backend_data * const backend)
-+{
-+  if (*external_ext != NULL)
-+    free (*external_ext);
-+  *external_ext = NULL;
-+  if (*ssext != NULL)
-+    free (*ssext);
-+  *ssext = NULL;
-+  return read_ext_syms_and_strs (symhdr, external_ext_size, esize,
-+				external_ext, ssext, abfd, backend);
-+}
-+
- /* This is called if we used _bfd_generic_link_add_archive_symbols
-    because we were not dealing with an ECOFF archive.  */
- 
- static bfd_boolean
- ecoff_link_check_archive_element (bfd *abfd,
- 				  struct bfd_link_info *info,
--				  struct bfd_link_hash_entry *h,
--				  const char *name,
- 				  bfd_boolean *pneeded)
- {
-+  const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
-+  void (* const swap_ext_in) (bfd *, void *, EXTR *)
-+    = backend->debug_swap.swap_ext_in;
-+  HDRR *symhdr;
-+  bfd_size_type external_ext_size = 0;
-+  void * external_ext = NULL;
-+  bfd_size_type esize = 0;
-+  char *ssext = NULL;
-+  char *ext_ptr;
-+  char *ext_end;
-+
-   *pneeded = FALSE;
- 
--  /* Unlike the generic linker, we do not pull in elements because
--     of common symbols.  */
--  if (h->type != bfd_link_hash_undefined)
--    return TRUE;
-+  /* Read in the external symbols and external strings.  */
-+  if (!read_ext_syms_and_strs (&symhdr, &external_ext_size, &esize,
-+	&external_ext, &ssext, abfd, backend))
-+    goto error_return;
- 
--  /* Include this element.  */
--  if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd))
--    return FALSE;
--  *pneeded = TRUE;
-+  /* If there are no symbols, we don't want it.  */
-+  if (bfd_get_symcount (abfd) == 0)
-+    goto successful_return;
- 
--  return ecoff_link_add_object_symbols (abfd, info);
-+  /* Look through the external symbols to see if they define some
-+     symbol that is currently undefined.  */
-+  ext_ptr = (char *) external_ext;
-+  ext_end = ext_ptr + esize;
-+  for (; ext_ptr < ext_end; ext_ptr += external_ext_size)
-+    {
-+      EXTR esym;
-+      bfd_boolean def;
-+      const char *name;
-+      bfd *oldbfd;
-+      struct bfd_link_hash_entry *h;
-+
-+      (*swap_ext_in) (abfd, (void *) ext_ptr, &esym);
-+
-+      /* See if this symbol defines something.  */
-+      if (esym.asym.st != stGlobal
-+	  && esym.asym.st != stLabel
-+	  && esym.asym.st != stProc)
-+	continue;
-+
-+      switch (esym.asym.sc)
-+	{
-+	case scText:
-+	case scData:
-+	case scBss:
-+	case scAbs:
-+	case scSData:
-+	case scSBss:
-+	case scRData:
-+	case scCommon:
-+	case scSCommon:
-+	case scInit:
-+	case scFini:
-+	case scRConst:
-+	  def = TRUE;
-+	  break;
-+	default:
-+	  def = FALSE;
-+	  break;
-+	}
-+
-+      if (! def)
-+	continue;
-+
-+      name = ssext + esym.asym.iss;
-+      h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
-+
-+      /* Unlike the generic linker, we do not pull in elements because
-+	 of common symbols.  */
-+      if (h == NULL
-+	  || h->type != bfd_link_hash_undefined)
-+	continue;
-+
-+      /* Include this element.  */
-+      oldbfd = abfd;
-+      if (!(*info->callbacks
-+	    ->add_archive_element) (info, abfd, name, &abfd))
-+	goto error_return;
-+      /* Potentially, the add_archive_element hook may have set a
-+	 substitute BFD for us.  */
-+      if (abfd != oldbfd
-+	  && !reread_ext_syms_and_strs (&symhdr, &external_ext_size, &esize,
-+					&external_ext, &ssext, abfd, backend))
-+	goto error_return;
-+      if (! ecoff_link_add_externals (abfd, info, external_ext, ssext))
-+	goto error_return;
-+
-+      *pneeded = TRUE;
-+      goto successful_return;
-+    }
-+
-+ successful_return:
-+  if (external_ext != NULL)
-+    free (external_ext);
-+  if (ssext != NULL)
-+    free (ssext);
-+  return TRUE;
-+ error_return:
-+  if (external_ext != NULL)
-+    free (external_ext);
-+  if (ssext != NULL)
-+    free (ssext);
-+  return FALSE;
- }
- 
- /* Add the symbols from an archive file to the global hash table.
-diff --git a/bfd/elflink.c b/bfd/elflink.c
-index 94ab762..164df6b 100644
---- a/bfd/elflink.c
-+++ b/bfd/elflink.c
-@@ -2933,6 +2933,13 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef)
-   if (! bfd_check_format (abfd, bfd_object))
-     return FALSE;
- 
-+  /* If we have already included the element containing this symbol in the
-+     link then we do not need to include it again.  Just claim that any symbol
-+     it contains is not a definition, so that our caller will not decide to
-+     (re)include this element.  */
-+  if (abfd->archive_pass)
-+    return FALSE;
-+
-   /* Select the appropriate symbol table.  */
-   if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0)
-     hdr = &elf_tdata (abfd)->symtab_hdr;
-@@ -4929,8 +4936,20 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd,
- }
- 
- /* Add symbols from an ELF archive file to the linker hash table.  We
--   don't use _bfd_generic_link_add_archive_symbols because we need to
--   handle versioned symbols.
-+   don't use _bfd_generic_link_add_archive_symbols because of a
-+   problem which arises on UnixWare.  The UnixWare libc.so is an
-+   archive which includes an entry libc.so.1 which defines a bunch of
-+   symbols.  The libc.so archive also includes a number of other
-+   object files, which also define symbols, some of which are the same
-+   as those defined in libc.so.1.  Correct linking requires that we
-+   consider each object file in turn, and include it if it defines any
-+   symbols we need.  _bfd_generic_link_add_archive_symbols does not do
-+   this; it looks through the list of undefined symbols, and includes
-+   any object file which defines them.  When this algorithm is used on
-+   UnixWare, it winds up pulling in libc.so.1 early and defining a
-+   bunch of symbols.  This means that some of the other objects in the
-+   archive are not included in the link, which is incorrect since they
-+   precede libc.so.1 in the archive.
- 
-    Fortunately, ELF archive handling is simpler than that done by
-    _bfd_generic_link_add_archive_symbols, which has to allow for a.out
-@@ -4945,7 +4964,8 @@ static bfd_boolean
- elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
- {
-   symindex c;
--  unsigned char *included = NULL;
-+  bfd_boolean *defined = NULL;
-+  bfd_boolean *included = NULL;
-   carsym *symdefs;
-   bfd_boolean loop;
-   bfd_size_type amt;
-@@ -4969,10 +4989,11 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
-   if (c == 0)
-     return TRUE;
-   amt = c;
--  amt *= sizeof (*included);
--  included = (unsigned char *) bfd_zmalloc (amt);
--  if (included == NULL)
--    return FALSE;
-+  amt *= sizeof (bfd_boolean);
-+  defined = (bfd_boolean *) bfd_zmalloc (amt);
-+  included = (bfd_boolean *) bfd_zmalloc (amt);
-+  if (defined == NULL || included == NULL)
-+    goto error_return;
- 
-   symdefs = bfd_ardata (abfd)->symdefs;
-   bed = get_elf_backend_data (abfd);
-@@ -4997,7 +5018,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
- 	  struct bfd_link_hash_entry *undefs_tail;
- 	  symindex mark;
- 
--	  if (included[i])
-+	  if (defined[i] || included[i])
- 	    continue;
- 	  if (symdef->file_offset == last)
- 	    {
-@@ -5032,8 +5053,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
- 	  else if (h->root.type != bfd_link_hash_undefined)
- 	    {
- 	      if (h->root.type != bfd_link_hash_undefweak)
--		/* Symbol must be defined.  Don't check it again.  */
--		included[i] = TRUE;
-+		defined[i] = TRUE;
- 	      continue;
- 	    }
- 
-@@ -5045,6 +5065,16 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
- 	  if (! bfd_check_format (element, bfd_object))
- 	    goto error_return;
- 
-+	  /* Doublecheck that we have not included this object
-+	     already--it should be impossible, but there may be
-+	     something wrong with the archive.  */
-+	  if (element->archive_pass != 0)
-+	    {
-+	      bfd_set_error (bfd_error_bad_value);
-+	      goto error_return;
-+	    }
-+	  element->archive_pass = 1;
-+
- 	  undefs_tail = info->hash->undefs_tail;
- 
- 	  if (!(*info->callbacks
-@@ -5082,11 +5112,14 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
-     }
-   while (loop);
- 
-+  free (defined);
-   free (included);
- 
-   return TRUE;
- 
-  error_return:
-+  if (defined != NULL)
-+    free (defined);
-   if (included != NULL)
-     free (included);
-   return FALSE;
-diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
-index 50a46ac..90c6018 100644
---- a/bfd/libbfd-in.h
-+++ b/bfd/libbfd-in.h
-@@ -596,9 +596,7 @@ extern bfd_boolean _bfd_generic_link_add_symbols_collect
- /* Generic archive add symbol routine.  */
- extern bfd_boolean _bfd_generic_link_add_archive_symbols
-   (bfd *, struct bfd_link_info *,
--   bfd_boolean (*) (bfd *, struct bfd_link_info *,
--		    struct bfd_link_hash_entry *, const char *,
--		    bfd_boolean *));
-+   bfd_boolean (*) (bfd *, struct bfd_link_info *, bfd_boolean *));
- 
- /* Forward declaration to avoid prototype errors.  */
- typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-diff --git a/bfd/libbfd.h b/bfd/libbfd.h
-index 6c48f82..ffb6ea4 100644
---- a/bfd/libbfd.h
-+++ b/bfd/libbfd.h
-@@ -601,9 +601,7 @@ extern bfd_boolean _bfd_generic_link_add_symbols_collect
- /* Generic archive add symbol routine.  */
- extern bfd_boolean _bfd_generic_link_add_archive_symbols
-   (bfd *, struct bfd_link_info *,
--   bfd_boolean (*) (bfd *, struct bfd_link_info *,
--		    struct bfd_link_hash_entry *, const char *,
--		    bfd_boolean *));
-+   bfd_boolean (*) (bfd *, struct bfd_link_info *, bfd_boolean *));
- 
- /* Forward declaration to avoid prototype errors.  */
- typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-diff --git a/bfd/linker.c b/bfd/linker.c
-index abdf5b0..4cff1e7 100644
---- a/bfd/linker.c
-+++ b/bfd/linker.c
-@@ -229,16 +229,28 @@ SUBSUBSECTION
- @findex _bfd_generic_link_add_archive_symbols
- 	In most cases the work of looking through the symbols in the
- 	archive should be done by the
--	<<_bfd_generic_link_add_archive_symbols>> function.
-+	<<_bfd_generic_link_add_archive_symbols>> function.  This
-+	function builds a hash table from the archive symbol table and
-+	looks through the list of undefined symbols to see which
-+	elements should be included.
- 	<<_bfd_generic_link_add_archive_symbols>> is passed a function
- 	to call to make the final decision about adding an archive
- 	element to the link and to do the actual work of adding the
--	symbols to the linker hash table.  If the element is to
-+	symbols to the linker hash table.
-+
-+	The function passed to
-+	<<_bfd_generic_link_add_archive_symbols>> must read the
-+	symbols of the archive element and decide whether the archive
-+	element should be included in the link.  If the element is to
- 	be included, the <<add_archive_element>> linker callback
- 	routine must be called with the element as an argument, and
- 	the element's symbols must be added to the linker hash table
- 	just as though the element had itself been passed to the
--	<<_bfd_link_add_symbols>> function.
-+	<<_bfd_link_add_symbols>> function.  The <<add_archive_element>>
-+	callback has the option to indicate that it would like to
-+	replace the element archive with a substitute BFD, in which
-+	case it is the symbols of that substitute BFD that must be
-+	added to the linker hash table instead.
- 
- 	When the a.out <<_bfd_link_add_symbols>> function receives an
- 	archive, it calls <<_bfd_generic_link_add_archive_symbols>>
-@@ -407,14 +419,11 @@ static bfd_boolean generic_link_add_object_symbols
- static bfd_boolean generic_link_add_symbols
-   (bfd *, struct bfd_link_info *, bfd_boolean);
- static bfd_boolean generic_link_check_archive_element_no_collect
--  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *,
--   bfd_boolean *);
-+  (bfd *, struct bfd_link_info *, bfd_boolean *);
- static bfd_boolean generic_link_check_archive_element_collect
--  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *,
--   bfd_boolean *);
-+  (bfd *, struct bfd_link_info *, bfd_boolean *);
- static bfd_boolean generic_link_check_archive_element
--  (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *,
--   bfd_boolean *, bfd_boolean);
-+  (bfd *, struct bfd_link_info *, bfd_boolean *, bfd_boolean);
- static bfd_boolean generic_link_add_symbol_list
-   (bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **,
-    bfd_boolean);
-@@ -908,32 +917,138 @@ generic_link_add_object_symbols (bfd *abfd,
-   return generic_link_add_symbol_list (abfd, info, symcount, outsyms, collect);
- }
- 
-+/* We build a hash table of all symbols defined in an archive.  */
-+
-+/* An archive symbol may be defined by multiple archive elements.
-+   This linked list is used to hold the elements.  */
-+
-+struct archive_list
-+{
-+  struct archive_list *next;
-+  unsigned int indx;
-+};
-+
-+/* An entry in an archive hash table.  */
-+
-+struct archive_hash_entry
-+{
-+  struct bfd_hash_entry root;
-+  /* Where the symbol is defined.  */
-+  struct archive_list *defs;
-+};
-+
-+/* An archive hash table itself.  */
-+
-+struct archive_hash_table
-+{
-+  struct bfd_hash_table table;
-+};
-+
-+/* Create a new entry for an archive hash table.  */
-+
-+static struct bfd_hash_entry *
-+archive_hash_newfunc (struct bfd_hash_entry *entry,
-+		      struct bfd_hash_table *table,
-+		      const char *string)
-+{
-+  struct archive_hash_entry *ret = (struct archive_hash_entry *) entry;
-+
-+  /* Allocate the structure if it has not already been allocated by a
-+     subclass.  */
-+  if (ret == NULL)
-+    ret = (struct archive_hash_entry *)
-+        bfd_hash_allocate (table, sizeof (struct archive_hash_entry));
-+  if (ret == NULL)
-+    return NULL;
-+
-+  /* Call the allocation method of the superclass.  */
-+  ret = ((struct archive_hash_entry *)
-+	 bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-+
-+  if (ret)
-+    {
-+      /* Initialize the local fields.  */
-+      ret->defs = NULL;
-+    }
-+
-+  return &ret->root;
-+}
-+
-+/* Initialize an archive hash table.  */
-+
-+static bfd_boolean
-+archive_hash_table_init
-+  (struct archive_hash_table *table,
-+   struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
-+				      struct bfd_hash_table *,
-+				      const char *),
-+   unsigned int entsize)
-+{
-+  return bfd_hash_table_init (&table->table, newfunc, entsize);
-+}
-+
-+/* Look up an entry in an archive hash table.  */
-+
-+#define archive_hash_lookup(t, string, create, copy) \
-+  ((struct archive_hash_entry *) \
-+   bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
-+
-+/* Allocate space in an archive hash table.  */
-+
-+#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size))
-+
-+/* Free an archive hash table.  */
-+
-+#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table)
-+
- /* Generic function to add symbols from an archive file to the global
-    hash file.  This function presumes that the archive symbol table
-    has already been read in (this is normally done by the
--   bfd_check_format entry point).  It looks through the archive symbol
--   table for symbols that are undefined or common in the linker global
--   symbol hash table.  When one is found, the CHECKFN argument is used
--   to see if an object file should be included.  This allows targets
--   to customize common symbol behaviour.  CHECKFN should set *PNEEDED
--   to TRUE if the object file should be included, and must also call
--   the bfd_link_info add_archive_element callback function and handle
--   adding the symbols to the global hash table.  CHECKFN must notice
--   if the callback indicates a substitute BFD, and arrange to add
--   those symbols instead if it does so.  CHECKFN should only return
--   FALSE if some sort of error occurs.  */
-+   bfd_check_format entry point).  It looks through the undefined and
-+   common symbols and searches the archive symbol table for them.  If
-+   it finds an entry, it includes the associated object file in the
-+   link.
-+
-+   The old linker looked through the archive symbol table for
-+   undefined symbols.  We do it the other way around, looking through
-+   undefined symbols for symbols defined in the archive.  The
-+   advantage of the newer scheme is that we only have to look through
-+   the list of undefined symbols once, whereas the old method had to
-+   re-search the symbol table each time a new object file was added.
-+
-+   The CHECKFN argument is used to see if an object file should be
-+   included.  CHECKFN should set *PNEEDED to TRUE if the object file
-+   should be included, and must also call the bfd_link_info
-+   add_archive_element callback function and handle adding the symbols
-+   to the global hash table.  CHECKFN must notice if the callback
-+   indicates a substitute BFD, and arrange to add those symbols instead
-+   if it does so.  CHECKFN should only return FALSE if some sort of
-+   error occurs.
-+
-+   For some formats, such as a.out, it is possible to look through an
-+   object file but not actually include it in the link.  The
-+   archive_pass field in a BFD is used to avoid checking the symbols
-+   of an object files too many times.  When an object is included in
-+   the link, archive_pass is set to -1.  If an object is scanned but
-+   not included, archive_pass is set to the pass number.  The pass
-+   number is incremented each time a new object file is included.  The
-+   pass number is used because when a new object file is included it
-+   may create new undefined symbols which cause a previously examined
-+   object file to be included.  */
- 
- bfd_boolean
- _bfd_generic_link_add_archive_symbols
-   (bfd *abfd,
-    struct bfd_link_info *info,
--   bfd_boolean (*checkfn) (bfd *, struct bfd_link_info *,
--			   struct bfd_link_hash_entry *, const char *,
--			   bfd_boolean *))
-+   bfd_boolean (*checkfn) (bfd *, struct bfd_link_info *, bfd_boolean *))
- {
--  bfd_boolean loop;
--  bfd_size_type amt;
--  unsigned char *included;
-+  carsym *arsyms;
-+  carsym *arsym_end;
-+  register carsym *arsym;
-+  int pass;
-+  struct archive_hash_table arsym_hash;
-+  unsigned int indx;
-+  struct bfd_link_hash_entry **pundef;
- 
-   if (! bfd_has_map (abfd))
-     {
-@@ -944,103 +1059,148 @@ _bfd_generic_link_add_archive_symbols
-       return FALSE;
-     }
- 
--  amt = bfd_ardata (abfd)->symdef_count;
--  if (amt == 0)
--    return TRUE;
--  amt *= sizeof (*included);
--  included = (unsigned char *) bfd_zmalloc (amt);
--  if (included == NULL)
-+  arsyms = bfd_ardata (abfd)->symdefs;
-+  arsym_end = arsyms + bfd_ardata (abfd)->symdef_count;
-+
-+  /* In order to quickly determine whether an symbol is defined in
-+     this archive, we build a hash table of the symbols.  */
-+  if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc,
-+				 sizeof (struct archive_hash_entry)))
-     return FALSE;
-+  for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
-+    {
-+      struct archive_hash_entry *arh;
-+      struct archive_list *l, **pp;
- 
--  do
-+      arh = archive_hash_lookup (&arsym_hash, arsym->name, TRUE, FALSE);
-+      if (arh == NULL)
-+	goto error_return;
-+      l = ((struct archive_list *)
-+	   archive_hash_allocate (&arsym_hash, sizeof (struct archive_list)));
-+      if (l == NULL)
-+	goto error_return;
-+      l->indx = indx;
-+      for (pp = &arh->defs; *pp != NULL; pp = &(*pp)->next)
-+	;
-+      *pp = l;
-+      l->next = NULL;
-+    }
-+
-+  /* The archive_pass field in the archive itself is used to
-+     initialize PASS, sine we may search the same archive multiple
-+     times.  */
-+  pass = abfd->archive_pass + 1;
-+
-+  /* New undefined symbols are added to the end of the list, so we
-+     only need to look through it once.  */
-+  pundef = &info->hash->undefs;
-+  while (*pundef != NULL)
-     {
--      carsym *arsyms;
--      carsym *arsym_end;
--      carsym *arsym;
--      unsigned int indx;
--      file_ptr last_ar_offset = -1;
--      bfd_boolean needed = FALSE;
--      bfd *element = NULL;
--
--      loop = FALSE;
--      arsyms = bfd_ardata (abfd)->symdefs;
--      arsym_end = arsyms + bfd_ardata (abfd)->symdef_count;
--      for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
-+      struct bfd_link_hash_entry *h;
-+      struct archive_hash_entry *arh;
-+      struct archive_list *l;
-+
-+      h = *pundef;
-+
-+      /* When a symbol is defined, it is not necessarily removed from
-+	 the list.  */
-+      if (h->type != bfd_link_hash_undefined
-+	  && h->type != bfd_link_hash_common)
- 	{
--	  struct bfd_link_hash_entry *h;
--	  struct bfd_link_hash_entry *undefs_tail;
-+	  /* Remove this entry from the list, for general cleanliness
-+	     and because we are going to look through the list again
-+	     if we search any more libraries.  We can't remove the
-+	     entry if it is the tail, because that would lose any
-+	     entries we add to the list later on (it would also cause
-+	     us to lose track of whether the symbol has been
-+	     referenced).  */
-+	  if (*pundef != info->hash->undefs_tail)
-+	    *pundef = (*pundef)->u.undef.next;
-+	  else
-+	    pundef = &(*pundef)->u.undef.next;
-+	  continue;
-+	}
- 
--	  if (included[indx])
--	    continue;
--	  if (needed && arsym->file_offset == last_ar_offset)
-+      /* Look for this symbol in the archive symbol map.  */
-+      arh = archive_hash_lookup (&arsym_hash, h->root.string, FALSE, FALSE);
-+      if (arh == NULL)
-+	{
-+	  /* If we haven't found the exact symbol we're looking for,
-+	     let's look for its import thunk */
-+	  if (info->pei386_auto_import)
-+	    {
-+	      bfd_size_type amt = strlen (h->root.string) + 10;
-+	      char *buf = (char *) bfd_malloc (amt);
-+	      if (buf == NULL)
-+		return FALSE;
-+
-+	      sprintf (buf, "__imp_%s", h->root.string);
-+	      arh = archive_hash_lookup (&arsym_hash, buf, FALSE, FALSE);
-+	      free(buf);
-+	    }
-+	  if (arh == NULL)
- 	    {
--	      included[indx] = 1;
-+	      pundef = &(*pundef)->u.undef.next;
- 	      continue;
- 	    }
-+	}
-+      /* Look at all the objects which define this symbol.  */
-+      for (l = arh->defs; l != NULL; l = l->next)
-+	{
-+	  bfd *element;
-+	  bfd_boolean needed;
-+
-+	  /* If the symbol has gotten defined along the way, quit.  */
-+	  if (h->type != bfd_link_hash_undefined
-+	      && h->type != bfd_link_hash_common)
-+	    break;
- 
--	  h = bfd_link_hash_lookup (info->hash, arsym->name,
--				    FALSE, FALSE, TRUE);
-+	  element = bfd_get_elt_at_index (abfd, l->indx);
-+	  if (element == NULL)
-+	    goto error_return;
- 
--	  if (h == NULL
--	      && info->pei386_auto_import
--	      && CONST_STRNEQ (arsym->name, "__imp_"))
--	    h = bfd_link_hash_lookup (info->hash, arsym->name + 6,
--				      FALSE, FALSE, TRUE);
--	  if (h == NULL)
-+	  /* If we've already included this element, or if we've
-+	     already checked it on this pass, continue.  */
-+	  if (element->archive_pass == -1
-+	      || element->archive_pass == pass)
- 	    continue;
- 
--	  if (h->type != bfd_link_hash_undefined
--	      && h->type != bfd_link_hash_common)
-+	  /* If we can't figure this element out, just ignore it.  */
-+	  if (! bfd_check_format (element, bfd_object))
- 	    {
--	      if (h->type != bfd_link_hash_undefweak)
--		/* Symbol must be defined.  Don't check it again.  */
--		included[indx] = 1;
-+	      element->archive_pass = -1;
- 	      continue;
- 	    }
- 
--	  if (last_ar_offset != arsym->file_offset)
--	    {
--	      last_ar_offset = arsym->file_offset;
--	      element = _bfd_get_elt_at_filepos (abfd, last_ar_offset);
--	      if (element == NULL
--		  || !bfd_check_format (element, bfd_object))
--		goto error_return;
--	    }
--
--	  undefs_tail = info->hash->undefs_tail;
--
- 	  /* CHECKFN will see if this element should be included, and
- 	     go ahead and include it if appropriate.  */
--	  if (! (*checkfn) (element, info, h, arsym->name, &needed))
-+	  if (! (*checkfn) (element, info, &needed))
- 	    goto error_return;
- 
--	  if (needed)
-+	  if (! needed)
-+	    element->archive_pass = pass;
-+	  else
- 	    {
--	      unsigned int mark;
-+	      element->archive_pass = -1;
- 
--	      /* Look backward to mark all symbols from this object file
--		 which we have already seen in this pass.  */
--	      mark = indx;
--	      do
--		{
--		  included[mark] = 1;
--		  if (mark == 0)
--		    break;
--		  --mark;
--		}
--	      while (arsyms[mark].file_offset == last_ar_offset);
--
--	      if (undefs_tail != info->hash->undefs_tail)
--		loop = TRUE;
-+	      /* Increment the pass count to show that we may need to
-+		 recheck object files which were already checked.  */
-+	      ++pass;
- 	    }
- 	}
--    } while (loop);
- 
--  free (included);
-+      pundef = &(*pundef)->u.undef.next;
-+    }
-+
-+  archive_hash_table_free (&arsym_hash);
-+
-+  /* Save PASS in case we are called again.  */
-+  abfd->archive_pass = pass;
-+
-   return TRUE;
- 
-  error_return:
--  free (included);
-+  archive_hash_table_free (&arsym_hash);
-   return FALSE;
- }
- 
-@@ -1050,14 +1210,12 @@ _bfd_generic_link_add_archive_symbols
-    for finding them.  */
- 
- static bfd_boolean
--generic_link_check_archive_element_no_collect (bfd *abfd,
-+generic_link_check_archive_element_no_collect (
-+					       bfd *abfd,
- 					       struct bfd_link_info *info,
--					       struct bfd_link_hash_entry *h,
--					       const char *name,
- 					       bfd_boolean *pneeded)
- {
--  return generic_link_check_archive_element (abfd, info, h, name, pneeded,
--					     FALSE);
-+  return generic_link_check_archive_element (abfd, info, pneeded, FALSE);
- }
- 
- /* See if we should include an archive element.  This version is used
-@@ -1067,12 +1225,9 @@ generic_link_check_archive_element_no_collect (bfd *abfd,
- static bfd_boolean
- generic_link_check_archive_element_collect (bfd *abfd,
- 					    struct bfd_link_info *info,
--					    struct bfd_link_hash_entry *h,
--					    const char *name,
- 					    bfd_boolean *pneeded)
- {
--  return generic_link_check_archive_element (abfd, info, h, name, pneeded,
--					     TRUE);
-+  return generic_link_check_archive_element (abfd, info, pneeded, TRUE);
- }
- 
- /* See if we should include an archive element.  Optionally collect
-@@ -1081,8 +1236,6 @@ generic_link_check_archive_element_collect (bfd *abfd,
- static bfd_boolean
- generic_link_check_archive_element (bfd *abfd,
- 				    struct bfd_link_info *info,
--				    struct bfd_link_hash_entry *h,
--				    const char *name ATTRIBUTE_UNUSED,
- 				    bfd_boolean *pneeded,
- 				    bfd_boolean collect)
- {
-@@ -1098,6 +1251,7 @@ generic_link_check_archive_element (bfd *abfd,
-   for (; pp < ppend; pp++)
-     {
-       asymbol *p;
-+      struct bfd_link_hash_entry *h;
- 
-       p = *pp;
- 
-diff --git a/bfd/pdp11.c b/bfd/pdp11.c
-index 593c5ca..5111a51 100644
---- a/bfd/pdp11.c
-+++ b/bfd/pdp11.c
-@@ -251,7 +251,7 @@ HOWTO( 1,	       0,  1,  16,  TRUE,  0, complain_overflow_signed,0,"DISP16",	TRU
- #define TABLE_SIZE(TABLE)	(sizeof(TABLE)/sizeof(TABLE[0]))
- 
- 
--static bfd_boolean aout_link_check_archive_element (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *, bfd_boolean *);
-+static bfd_boolean aout_link_check_archive_element (bfd *, struct bfd_link_info *, bfd_boolean *);
- static bfd_boolean aout_link_add_object_symbols    (bfd *, struct bfd_link_info *);
- static bfd_boolean aout_link_add_symbols           (bfd *, struct bfd_link_info *);
- static bfd_boolean aout_link_write_symbols         (struct aout_final_link_info *, bfd *);
-@@ -2682,8 +2682,6 @@ aout_link_check_ar_symbols (bfd *abfd,
- static bfd_boolean
- aout_link_check_archive_element (bfd *abfd,
- 				 struct bfd_link_info *info,
--				 struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED,
--				 const char *name ATTRIBUTE_UNUSED,
- 				 bfd_boolean *pneeded)
- {
-   bfd *oldbfd;
-diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
-index 9522974..dcfd58f 100644
---- a/bfd/xcofflink.c
-+++ b/bfd/xcofflink.c
-@@ -2384,8 +2384,6 @@ xcoff_link_check_ar_symbols (bfd *abfd,
- static bfd_boolean
- xcoff_link_check_archive_element (bfd *abfd,
- 				  struct bfd_link_info *info,
--				  struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED,
--				  const char *name ATTRIBUTE_UNUSED,
- 				  bfd_boolean *pneeded)
- {
-   bfd_boolean keep_syms_p;
-@@ -2465,7 +2463,7 @@ _bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
- 		bfd_boolean needed;
- 
- 		if (! xcoff_link_check_archive_element (member, info,
--							NULL, NULL, &needed))
-+							&needed))
- 		  return FALSE;
- 		if (needed)
- 		  member->archive_pass = -1;
diff --git a/projects/binutils/peXXigen.patch b/projects/binutils/peXXigen.patch
deleted file mode 100644
index c2a689a..0000000
--- a/projects/binutils/peXXigen.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From f8e8f1daf12e30d3197b25d6bd10c03d1f932e20 Mon Sep 17 00:00:00 2001
-From: Nick Clifton <nickc@xxxxxxxxxx>
-Date: Tue, 27 Sep 2016 12:08:19 +0100
-Subject: [PATCH] Ensure that the timestamp in PE/COFF headers is always
- initialised.
-
-	PR ld/20634
-	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Put 0 in the
-	timestamp field if real time values are not being stored.
----
- bfd/peXXigen.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
-index c92c1ea..d713d96 100644
---- a/bfd/peXXigen.c
-+++ b/bfd/peXXigen.c
-@@ -879,6 +879,8 @@ _bfd_XXi_only_swap_filehdr_out (bfd * abfd, void * in, void * out)
-   /* Only use a real timestamp if the option was chosen.  */
-   if ((pe_data (abfd)->insert_timestamp))
-     H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
-+  else
-+    H_PUT_32 (abfd, 0, filehdr_out->f_timdat);
- 
-   PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
- 		      filehdr_out->f_symptr);
--- 
-2.1.4
-
diff --git a/projects/mingw-w64/build b/projects/mingw-w64/build
index b2117c5..4be660d 100644
--- a/projects/mingw-w64/build
+++ b/projects/mingw-w64/build
@@ -22,6 +22,10 @@ cd /var/tmp/build
 mkdir gcc
 cd gcc
 tar xJf $rootdir/gcc-[% c("var/gcc_version") %].tar.xz
+# https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01115.html
+# From gcc commit 494c17dc2bf45b8155fb9a14178ab48f01bc12a8
+# libtool: Sort output of 'find' to enable deterministic builds.
+patch -p1 -d gcc-[% c("var/gcc_version") %] < $rootdir/libtool-sort.patch
 # We don't want to link against msvcrt.dll due to bug 9084 and want to use
 # pthreads, too, as this is needed for ESR60, at least due to bug 1406542.
 [% c("arch") %]-w64-mingw32-g++ -dumpspecs > $distdir/msvcr100.spec
diff --git a/projects/mingw-w64/config b/projects/mingw-w64/config
index b9185f3..19a7a82 100644
--- a/projects/mingw-w64/config
+++ b/projects/mingw-w64/config
@@ -34,3 +34,4 @@ input_files:
     sha256sum: 850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4
   - name: binutils
     project: binutils
+  - filename: libtool-sort.patch
diff --git a/projects/mingw-w64/libtool-sort.patch b/projects/mingw-w64/libtool-sort.patch
new file mode 100644
index 0000000..7c7fa85
--- /dev/null
+++ b/projects/mingw-w64/libtool-sort.patch
@@ -0,0 +1,67 @@
+From 494c17dc2bf45b8155fb9a14178ab48f01bc12a8 Mon Sep 17 00:00:00 2001
+From: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Thu, 5 Jul 2018 19:13:45 +0000
+Subject: [PATCH 1/1]         * libtool.m4: Sort output of 'find' to enable
+ deterministic builds. 	* ltmain.sh: Likewise.
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262451 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+ ChangeLog  | 5 +++++
+ libtool.m4 | 8 ++++----
+ ltmain.sh  | 4 ++--
+ 3 files changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/libtool.m4 b/libtool.m4
+index 24d13f3..940faaa 100644
+--- a/libtool.m4
++++ b/libtool.m4
+@@ -6005,20 +6005,20 @@ if test "$_lt_caught_CXX_error" != yes; then
+ 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ 		rm -rf $tpldir~
+ 		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+-		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
++		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ 		rm -rf $tpldir~
+ 		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
++		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ 		$RANLIB $oldlib'
+ 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ 		rm -rf $tpldir~
+ 		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
++		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ 		rm -rf $tpldir~
+ 		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
++		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ 	      ;;
+ 	    *) # Version 6 and above use weak symbols
+ 	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+diff --git a/ltmain.sh b/ltmain.sh
+index 9503ec8..79f9ba8 100644
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -2917,7 +2917,7 @@ func_extract_archives ()
+ 	    darwin_file=
+ 	    darwin_files=
+ 	    for darwin_file in $darwin_filelist; do
+-	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
++	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
+ 	      $LIPO -create -output "$darwin_file" $darwin_files
+ 	    done # $darwin_filelist
+ 	    $RM -rf unfat-$$
+@@ -2932,7 +2932,7 @@ func_extract_archives ()
+         func_extract_an_archive "$my_xdir" "$my_xabs"
+ 	;;
+       esac
+-      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
++      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
+     done
+ 
+     func_extract_archives_result="$my_oldobjs"
+-- 
+2.9.3
+

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits