[cfe-commits] [PATCH] Improved cross-compiling support for calling helper programs

Joerg Sonnenberger joerg at britannica.bec.de
Thu Mar 17 15:11:01 PDT 2011


On Fri, Mar 18, 2011 at 12:37:07AM +0300, Anton Korobeynikov wrote:
> Hi Joerg,
> 
> > the attached patch changes the driver to look for "x86_64--netbsd-ld"
> > and "x86_64--netbsd-as" when compiling for x86_64--netbsd as target
> > triple. If they can't be found, it falls back to the normal "ld" and
> > "as" lookup. This simplifies the cross compiling setup quite a bit.
> > What other platforms are interested in this behavior?
> Just quick q: does NetBSD use cross-directory layout? So, do you have
> something like /usr/x86_64-netbsd/bin/as?

The NetBSD build system is essentially always using cross-compilation.
There are three pathes that influence the build:
- tooldir
- objdir
- destdir

The tooldir contains the various native programs, prefix to not conflict
with normal $PATH content. This includes make, the compiler, binutils
and whatever else is needed for the build. Let's consider building for
i386. This uses i486--netbsdelf as target for various reasons. Under
tooldir, this creates:

...
bin/i486--netbsdelf-as
bin/i486--netbsdelf-ld
bin/i486--netbsdelf-gcc
...
bin/nbmake-i386
...
i486--netbsdelf/as
i486--netbsdelf/gcc
i486--netbsdelf/ld

but the i486--netbsdelf is only really used for the ldscripts and
hardlinks for the GNU stuff also found in bin/.

This tooldir can now be used for different objdir/destdir pairs to
compile the tree. At the moment, it is using -B$DESTDIR/usr/lib,
-nostdlib -L$DESTDIR/usr/lib -lgcc -lc, 
-nostdinc -isysroot $DESTDIR/usr/include -cxx-isysroot
$DESTDIR/usr/include/c++

...but with the exception of the first -B, that's what --sysroot $DESTDIR
gives.

I would expect a sane cross-compiling setup for other platforms to be
quite similar. With some additional changes to make the look up for
crt0.o and libgcc honour --sysroot, all that is needed for
cross-compiliation is using "clang -ccc-host-triple i486--netbsdelf
--sysroot $DESTDIR" or adding a symlink and using "i486--netbsdelf-clang
--sysroot $DESTDIR".

Joerg



More information about the cfe-commits mailing list