patches/binutils/2.20/130-ld-sysroot.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Sep 12 23:51:25 2010 +0200 (2010-09-12)
changeset 2123 ff2181adbd28
parent 1614 3f76cdbceb6e
permissions -rw-r--r--
cc/gcc: disable complibs if not selected

Force gcc to not link with some companion libraries when
there are not needed (because selected-out).

There is no option to tell gcc *not* to build the Graphite and/or
LTO stuff. They *will* be built if gcc finds the suitable companion
libraries. If we do not provide them, but the host has them, then
gcc *will* find them, and link with them.

Consider the following:
- host has suitable PPL and CLooG (eg. Debian Squeeze)
- user wants to build gcc>=4.4
- user de-selects GRAPHITE
- gcc will find the hosts PPL and CLooG, and will use them
- the user moves the toolchain to an older host that does
not have them (eg. Debian Lenny)
- the toolchain fails, when it was properly setup not to

So, explicitly tell gcc *not* to use unneeded companion libs.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 Signed-off-by: Sven Rebhan <odinshorse@googlemail.com>
     2 
     3 Always try to prepend the sysroot prefix to absolute filenames first.
     4 
     5 http://bugs.gentoo.org/275666
     6 http://sourceware.org/bugzilla/show_bug.cgi?id=10340
     7 
     8 --- binutils/ld/ldfile.c
     9 +++ binutils/ld/ldfile.c
    10 @@ -308,18 +308,24 @@
    11       directory first.  */
    12    if (! entry->is_archive)
    13      {
    14 -      if (entry->sysrooted && IS_ABSOLUTE_PATH (entry->filename))
    15 +      /* For absolute pathnames, try to always open the file in the
    16 +	 sysroot first. If this fails, try to open the file at the
    17 +	 given location. */
    18 +      entry->sysrooted = is_sysrooted_pathname(entry->filename, FALSE);
    19 +      if (IS_ABSOLUTE_PATH (entry->filename) && ld_sysroot && ! entry->sysrooted)
    20  	{
    21  	  char *name = concat (ld_sysroot, entry->filename,
    22  			       (const char *) NULL);
    23  	  if (ldfile_try_open_bfd (name, entry))
    24  	    {
    25  	      entry->filename = name;
    26 +	      entry->sysrooted = TRUE;
    27  	      return TRUE;
    28  	    }
    29  	  free (name);
    30  	}
    31 -      else if (ldfile_try_open_bfd (entry->filename, entry))
    32 +
    33 +      if (ldfile_try_open_bfd (entry->filename, entry))
    34  	{
    35  	  entry->sysrooted = IS_ABSOLUTE_PATH (entry->filename)
    36  	    && is_sysrooted_pathname (entry->filename, TRUE);