Patchwork Request new specs string token for multilib_os_dir

login
register
mail settings
Submitter Steven Drake
Date April 27, 2012, 9:18 a.m.
Message ID <alpine.LNX.2.00.1204272112070.29730@nygne.qenxr.bet.am>
Download mbox | patch
Permalink /patch/155400/
State New
Headers show

Comments

Steven Drake - April 27, 2012, 9:18 a.m.
In the GCC FAQ under "Dynamic linker is unable to find GCC libraries", one
suggestion is to add '-R' or '-rpath' linker option to the *link or *lib 
specs so that the GCC libraries can be found.

E.G. the following line is added to the DRIVER_DEFINES when building gcc
via pkgsrc ('$(LINKER_RPATH_FLAG)' comes from the environment):

  -DLINK_LIBGCC_SPEC="\"%D $(LINKER_RPATH_FLAG)$(libdir) \""

This is needed as the prefix is normally something like '/usr/pkg/gcc47'.

The problem is that this does not allow for multilib os directory's and
there is currently no simple way of dong so.

My solution is to add the '%M' token that expands to multilib_os_dir.

The above line can then be easily change to handle multilib directory's:

  -DLINK_LIBGCC_SPEC="\"%D $(LINKER_RPATH_FLAG)$(libdir)/%M \""


2012-04-27  Steven Drake <sbd@NetBSD.org>

	* gcc.c (do_spec_1): Add %M spec token to output multilib_os_dir.
Joseph S. Myers - May 22, 2012, 3:18 p.m.
On Fri, 27 Apr 2012, Steven Drake wrote:

> 2012-04-27  Steven Drake <sbd@NetBSD.org>
> 
> 	* gcc.c (do_spec_1): Add %M spec token to output multilib_os_dir.

Thanks, I've committed this patch with the addition of %M to the comment 
in gcc.c that documents specs.

Patch

--- gcc/gcc.c.orig	2012-02-28 17:31:38.000000000 +0000
+++ gcc/gcc.c
@@ -5115,6 +5115,13 @@  do_spec_1 (const char *spec, int inswitc
 	      return value;
 	    break;
 
+	  case 'M':
+	    if (multilib_os_dir == NULL)
+	      obstack_1grow (&obstack, '.');
+	    else
+	      obstack_grow (&obstack, multilib_os_dir, strlen(multilib_os_dir));
+	    break;
+
 	  case 'G':
 	    value = do_spec_1 (libgcc_spec, 0, NULL);
 	    if (value != 0)