Subject: Re: how rpath is set in gcc build
To: None <mcmahill@mtl.mit.edu>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-toolchain
Date: 08/31/2002 08:09:42
On Sat, Aug 31, 2002 at 09:54:43AM -0400, mcmahill@mtl.mit.edu wrote:

 > then ldd indicates that the rpath isn't set right.  So my question is,
 > how can I cause the gcc package to pre-pend
 > /usr/pkg/gcc-2.95.3/lib/gcc-lib/alpha--netbsd/2.95.3 to the rpath during
 > linking?  For that matter, how do I check what g++ thinks it should be?  

This is something I've brought up with the GCC folks before.  Basically,
their response was "encoding the rpath is too inflexible; use ld.so.conf".

...which is, of course, a bogus answer :-/

I have a patch to GCC-current (should apply to 3.2 and 3.3) ... it's a
quick hack which simply causes the compiler driver to pass a corresponding
-R for every -L it passes to the linker.  This fixed the problem I was
having with GCC-current.  But it clearly won't be accepted back by the
GCC maintainers .. so I have to figure out a different way to solve it.

(I don't think it can be solved with specs, because the code that passes
-L to the linker doesn't really use specs to do its work...)

Please file a NetBSD PR for this problem, and I'll tidy up my GCC-current
patch to send you ... you can then merge it into 2.95.3 in pkgsrc and
check it in as a stop-gap (sorry, I don't really have time to do this
bit myself).  I'll work with the GCC folks to get this fixed properly for
GCC 3.3 (hopefully!).

 > c++ -dumpspecs shows
 > *link:
 > -m elf64alpha   -e __start   %{O*:-O3} %{!O*:-O1}   %{assert*} %{R*}
 > %{shared:-shared}   %{!shared:     -dc -dp     %{!nostdlib:%{!r*:%{!e*:-e
 > __start}}}     %{
 > !static:       %{rdynamic:-export-dynamic}
 > %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}
 > %{static:-static}}
 > 
 > but i'm not quite sure how to interpret that or if this is even the right
 > thing to look at.

Heh, I can explain it, but let me rewrite it to make it more clear:

-m elf64alpha
	This is passed directly to the linker.

-e __start
	So is this.

%{O*:-O3}
	If "-O<anything>" was given to the compiler,
	pass -O3 to the linker.

%{!O*:-O1}
	If "-O<anything>" was not given to the compiler,
	pass -O1 to the linker.


%{assert*} %{R*}
	If "-assert<anything>" or "-R<anything>" are given to the
	compiler, pass them directly to the linker.

%{shared:-shared}
	If "-shared" is given to the compiler, pass it on to the linker.

%{!shared: -dc -dp
  %{!nostdlib:
    %{!r*:
      %{!e*:-e __start}}}
  %{!static:
    %{rdynamic:-export-dynamic}
    %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}
  %{static:-static}}

...and I think you can figure out what these mean given the above
explanation.  (Sorry, I haven't even finished my first cup of coffee
yet this morning :-)

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>