Subject: Re: Building emacs 20.2 fails while linking
To: None <current-users@NetBSD.ORG>
From: Greg A. Woods <>
List: current-users
Date: 04/06/1998 20:43:59
[ On Mon, April 6, 1998 at 08:52:26 (-0400), Todd Vierling wrote: ]
> Subject: Re: Building emacs 20.2 fails while linking
> : > It's just doing its job correctly:
> : > 
> : >      -nostdlib
> : >              Do not search the built-in path (usually ``/usr/lib'') for -l
> : >              specified libraries.
> Note that this is from ld(1), not gcc(1).

Yeah, silly me -- I guess I made one too many levels of assumption about
how things work under the hood and didn't confirm that the documentation
is also correct at all levels!  ;-)

> It took me a moment to realize what was going on with emacs, because NO
> PACKAGE SHOULD BE USING -nostdlib unless it is making standalone programs
> (boot PROMS, etc.).  What it seems to me is that emacs doesn't want
> -nostdlib:  it should actually be using -nostartfiles (which does not
> include crt0.o just like -nostdlib, but does not restrict the library search
> path or leave out -lc).  I'll change this in my local pkgsrc, test, and
> commit.

Ah, Yes!  Using '-nostartfiles' makes a lot more sense!  I guess
everything this elegant is obvious once it's pointed out the first time!

> : gcc.1 states:
> : 
> :    .B \-nostdlib
> :    Don't use the standard system libraries and startup files when linking.
> :    Only the files you specify will be passed to the linker.
> : 
> : To me this is not explicitly indicating that the library search path is changed,
> : only that the default libraries are not included. If the intention is to not
> : search /usr/lib unless mentioned in a -L/usr/lib parameter, the man page should
> : be updated.
> I'll update the page to indicate that the option is passed to ld.  (You can
> then look at ld(1) to find out what ld does with it.)

Actually I think the language in the gcc page was mostly OK, though
perhaps somewhat less technical than it could be, esp. since gcc itself
really doesn't have anything at all to do with what actually happens
when you use this option.  In fact I prefer the gcc.1 explanation over
the ld.1 explanation if those were the only options.  The gcc.1
explanation is far more explicit, though perhaps a slight re-combination
would be best:

    .B \-nostdlib
    Do not use the built-in search paths (usually ``-L/usr/lib'') for
    any libraries (eg. libc) or startup files (eg. crt0.o) when linking.
    Only the files and libraries you explicitly specified will be loaded
    and/or searched to resolve symbols.

Now that I've been reminded I'd always wondered why gcc.1 didn't state
explicitly what gcc handles itself and what it passes on to its more
visible and self-reliant underlings, such as ld and cpp.

> -nostdlib does require a -L/usr/lib if you are going to link with system
> libraries, but if you're using -nostdlib for the sole purpose of leaving out
> crt0.o, you are broken and should be using -nostartfiles instead.

Well, either that or explicilty stating /usr/lib/libc.a and/or whatever,
just like the second sentence says.

							Greg A. Woods

+1 416 443-1734      VE3TCP      <>      <robohack!woods>
Planix, Inc. <>; Secrets of the Weird <>