Subject: Re: ld confusion
To: None <netbsd-help@netbsd.org>
From: James K.Lowden <jklowden@speakeasy.org>
List: netbsd-help
Date: 05/23/2002 22:33:19
Frederick, 

Thanks very much.  I altered the patch and got going.  A couple of small
questions  about your answer, if I may, below.  

On Thu, 23 May 2002 21:06:59 -0500 (CDT) Frederick Bruckman
<fredb@immanent.net> wrote:
> On Thu, 23 May 2002, James K.Lowden wrote:
> > patch/patch-aa looks like this:
> > +    } elsif ($Config::Config{'osname'} eq 'netbsd') {
> > +       # We need to link with -Wl,-R if we're on NetBSD
> > +       $linkwith = "-Wl,-R$libdir";
> 
> "-Wl" is a "gcc" option, which passes the following argument to the
> linker. Since you're linking directly with "ld", you could just change
> that to "-R$libdir", then run "make distinfo", to regenerate the
> patch's checksum. The normal thing, nowadays, is to link always with
> "gcc"; making the package do so on NetBSD-a.out would be the real fix.

I didn't know about make distinfo.  With patch problems, I rename and hack
the patch, apply it, and then make.  Now I know better.  

Would the maintainer want a pr for this?  I don't know enough about it to
do it myself (I guess that's obvious!).  

> > # ls -l /usr/pkg/lib/*my*
> > total 546
> > -rw-r--r--  1 root  wheel  128970 May 23 20:23 libmysqlclient.a
> > -rwxr-xr-x  1 root  wheel     777 May 23 20:23 libmysqlclient.la
> > -rwxr-xr-x  1 root  wheel  128259 May 23 20:23 libmysqlclient.so.10.0
> 
> That's kind of tricky, the way you presented that. We're actually
> looking at the contents of "/usr/pkg/lib/mysql". 

Oy!  I tricked myself, too.  Sorry about that.  

> In order to have the
> run-time linker find the file there, it has to be told to look there.
> There are other ways to do that, but the best way is to pass the "-R"
> argument to the NetBSD-a.out linker.

If I understand you, you're saying the Makefile should tell gcc to call
upon the NetBSD-a.out linker /instead of/ ld?  Or does ld invoke the
NetBSD linker somehow?  "man -k linker" only turns up ld(1).  If I
memorize the gcc manual, will all this be clear, or is there somewhere
else I'm supposed to have looked?  

Thanks again. Slowly slowly this stuff is starting to make sense. 
Although to tell the truth, every linking environment I've ever seen has
been a bear to work with.  

Regards, 
--jkl