Gcc+binutils+libc cross-compiling: path to libc.so.6 malformed in "ld".

Kaz Kylheku kaz@zeugmasystems.com
Thu Aug 24 19:04:00 GMT 2006

Kai Ruottu wrote:
> Kaz Kylheku wrote:
> > GCC is version 4.1.1
> > Binutils 2.17
> > Glibc is CVS head.
> >
> > When configuring gcc, I used --with-sysroot=/path/to/sysroot,
> > where glibc is installed under usr/. The header files are
> > found correctly.
> >   
>  What about the binutils, was the same '--with-sysroot='
> given in their configure?

I did rebuild binutils using --with-sysroot, only because the they
complain that they were not built with sysroot support and bail out.

It doesn't matter at all what the --with-sysroot argument is for
configuring binutils. You can even omit it.

If I take the non-working collect2 command line (captured from gcc -v),
and edit out the --sysroot, it links! It's the --sysroot being passed
down to ld that is screwing things up.

The gcc front end is already passing nice absolute path names down for
everything: the crtN modules, the -L option to find libs, etc. 

I think I just have to figure out the way to configure gcc to do all
that exactly as it is doing now, but not generate the --sysroot option.
I really want to avoid patching it.

There is an Autoconf check in gcc to test whether the linker understands
--sysroot. That should have worked the first time when I built gcc using
--with-sysroot with binutils compiled without sysroot. Ah, but the
problem is that the configure script only runs "ld --help" and greps
that for --sysroot. If you build ld without sysroot, it still has that
option listed in its --help output. Oops!

>  Finding the headers happens with the built-in 'cpp' in the
> 'cc1', 'cc1plus' etc. real compilers, so only the GCC config
> options will have any influence to this.
> > When the linker is invoked, it is given
> >
> >   --sysroot=/path/to/sysroot.
> >   
>  Maybe this option is aimed for a 'ld' which was NOT configured
> using the '--with-sysroot='...

Shrug. I don't see the point of giving a sysroot to a tool, and at the
same time, giving it absolute path names to all of the objects and
directories. It would perhaps make sense if the paths were relative to
the root.

>  I myself haven't used the '--with-sysroot=', only made 
> symlinks like :
>      $prefix/$target/include  ->  $sysroot/usr/include
>      $prefix/$target/lib  ->  $sysroot/usr/lib

I thought about symlinks, but the problem is they are too much of a

This stuff is supposed to work, right?

If we can't get gcc to cleanly play along with binutils, where are we?

More information about the Gcc-help mailing list