Subject: Re: different behaviour of system cc and TOOLDIR/cc
To: None <M.Drochner@fz-juelich.de>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-toolchain
Date: 06/06/2003 10:18:43
On Friday, June 6, 2003, at 08:01  AM, Matthias Drochner wrote:

> Hi -
> just found a strange (or at least for me ununderstandable)
> difference in behaviour of the USE_TOOLS and the maintree compilers:
>
> When building a shared lib with the main one everything looks well:
>
> $ cc -v -shared -o mist.so xxx.o
> Using builtin specs.
> gcc version 2.95.3 20010315 (release) (NetBSD nb4)
>  ld -m elf_i386 -shared -o mist.so /usr/lib/crti.o /usr/lib/crtbeginS.o
> xxx.o -lgcc_pic -lgcc_pic /usr/lib/crtendS.o /usr/lib/crtn.o
>
> The same with "tools" doesn't work:
>
> $ /usr/tools/bin/i386--netbsdelf-gcc -v -shared -o mist.so xxx.o
> Reading specs from /usr/tools/lib/gcc-lib/i386--netbsdelf/2.95.3/specs
> gcc version 2.95.3 20010315 (release) (NetBSD nb4)
>  /usr/tools/lib/gcc-lib/i386--netbsdelf/2.95.3/collect2 -m elf_i386 
> -sha
> red -o mist.so crtbeginS.o 
> -L/usr/tools/lib/gcc-lib/i386--netbsdelf/2.95
> .3 -L/usr/tools/i386--netbsdelf/lib xxx.o crtendS.o
> /usr/tools/i386--netbsdelf/bin/ld: cannot open crtbeginS.o: No such 
> file
>  or directory
>
> Is this a bug or am I missing something?

Since the TOOLDIR version is configured as a cross-compiler, it does 
not look in /usr/lib/... for libraries/crt files.  Instead, it looks in 
the GCC "standard" directories of PREFIX/target-name/lib.

Whenever you use the TOOLDIR gcc, you basically need to do the 
-nostdlib dance and specifiy the libraries/crt files manually, just as 
<bsd.*.mk> do.

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