How to build a cross-ld that behaves like a native ld?

Jon Ringle jringle@vertical.com
Fri Jan 27 22:12:00 GMT 2006


On Friday 27 January 2006 04:54 pm, Daniel Jacobowitz wrote:
> On Fri, Jan 27, 2006 at 04:28:41PM -0500, Jon Ringle wrote:
> > On Friday 27 January 2006 04:06 pm, Daniel Jacobowitz wrote:
> > > On Fri, Jan 27, 2006 at 04:02:44PM -0500, Jon Ringle wrote:
> > > > Hello,
> > > >
> > > > I'm building a cross toolchain for use inside scratchbox
> > > > (http://scratchbox.org). One thing that scratchbox does is go to
> > > > great pains to make your cross toolchain looks and acts like a native
> > > > toolchain. One thing that they did in previous versions of binutils
> > > > is to patch ld/genscripts.sh so that NATIVE=yes. This approach
> > > > doesn't seem to work with binutils-2.16.1.
> > > >
> > > > Can I get any advice as to how I can generate a cross ld that acts
> > > > like a native ld in terms of how it searches for libraries.
> > >
> > > Use --with-sysroot.
> >
> > binutils was built with --with-sysroot but it still doesn't work. I need
> > ld to search /lib and /usr/lib like a native ld would do.
>
> What the heck are you trying to do?  If you want it to use the host
> libraries, use --with-sysroot=/, but that generally defeats the point
> of a cross linker.

I was afraid that I might get a reaction like that :)

Let me try to explain some background in a nutshell (more info at 
http://scratchbox.org):

scratchbox provides a chroot environment that gives you enough tools to cross 
build a system from source. It wraps the execution of binaries so that they 
are run either by CPU emulation (QEMU) or marshalling to a target device if 
the binary is not a native one (I believe this is done via binfmt_misc). When 
you first create a scratchbox you effectively have an empty / directory. So, 
when the cross toolchain is used at first, the linker needs to search the 
target library path as specified in --with-sysroot. However, as I start to 
build things and populate the chroot'd /lib and /usr/lib, I also need the 
toolchain to search these as well.

I hope this makes sense. Scratchbox is really a very cool idea worth looking 
at.

Jon



More information about the Binutils mailing list