Paludis/Cross-compiling

With Portage, you can use crossdev to setup a cross-compiling environment. With paludis, you are less lucky, but it's not too hard, especially since you can use this guide, which is based on the official documentation on creating a cross-compiler. Note that that document is aimed at portage users, which is why you should keep on reading this one after all.

This guide will setup a compiler for x86_64 binaries. In the next section, we'll create a category for this compiler, which is named cross-64, but with a bit of creativity you could create a different cross-compiler, which you would probably want to give a different category name and CTARGET.

Creating a cross_overlay repository
To distinguish the packages for different architectures from the ones you use to run your system, we'll create a new repository. Put this file in :

Now create the necessary files.

Configuring CTARGET and other compile options
Luckily, autoconf has some builtin configuration settings to compile for other platforms. Add this to :

Working towards a cross-compiler
Now you should be ready to start building. Because we'll need the target architecture name a few times, save it in a variable. Replace x86_64-pc-linux-gnu with the right value below.

Binutils
Binutils contains vital tools to build object files. Build this first.

linux-headers
You will need linux-headers to build glibc.

glibc headers
You'll need glibc headers to build GCC, which you need to build glibc, which you need to build... GCC. So now install glibc headers the rough way. Get the glibc tarball with the same version as the one you'll be installing later (try ) (this tarball might just be in, so look there first), and unpack it.

Now make a build directory and install the header files to our sysroot.

GCC stage 1
You should now be able to build GCC, so let's try.

Glibc
And now that we have a cross-compiler, build it a libc.

GCC stage 2
And now that you have glibc, you can build the entire gcc. Modify and set CROSS_GCC_STAGE to "2". Now reinstall gcc.

You should now have a complete cross-compiler.

Restore default gcc
Finally, make sure that the default gcc is your host gcc, not the cross-compiler, since the gcc compiles likely changed this to the cross-compiler.