Cross compilation

Most Linux users do not compile anything at all on their Linux machine, so installing the bootstrap compiler to compile the full blown gcc complier to compile a Linux kernel sounds behind their scope.

Usually you use the PC to compile source code for the PC itself. This is obviously the default. Cross compiling is when you compile for an other CPU type as a small micro controller used for embedded applications.


If variable CHOST found in /etc/portage/make.conf is not the same, cross compilation is required. So i586 is not i686.

It is very important that the native system (or host) system tool chain is kept separated from the one that is used for cross compiling. If a mess would happen the host system might become lost and a re-install would be the fastest way to get it back.

Your probably Gentoo computer has already a tool-chain installed. This is the host tool-chain that allows you to compile binaries for to be run on your host.

What you need is a cross tool-chain for the selected CPU architecture is required. Tool-chains contain:

  1. binutils - Essential utilities for handling binaries (includes assembler and linker)

  2. gcc - The GNU Compiler Collection (the C and C++ compiler)

  3. glibc or uclibc or newlib - The system C Library

  4. linux-headers - Kernel headers needed by the system C Library

  5. gdb - The GNU debugger

To deal and create cross tool-chains that do not get in conflict with the host tool-chain gentoo uses a program called crossdev. If you are still worried about accidentally damage your system consider a gentoo installation in a virtual PC as VirtualBox offers. Finally emerge crossdev. To get help crossdev --help or crossdev -t help

As examples for avr microprocessors, crossdev creates the cross-avr/avr-libc, cross-avr/binutils, cross-avr/gcc and cross-avr/gdb ebuilds in a local overlay as/usr/local/portage/local-overlay and emerges them afterwards.

Therefore make sure you have a local overlay, a directory where those automatically created ebuilds go.


Per default it takes the fist overlay seen when echo $PORTDIR_OVERLAY. So check first what comes back, and if it is not what you want edit /etc/portage/make.conf to simply have your crossdev local overlay first.

source /var/lib/layman/make.conf
PORTDIR_OVERLAY="/usr/local/portage/local-overlay $PORTDIR_OVERLAY"

and then run source /etc/portage/make.conf and check with echo $PORTDIR_OVERLAY the first overlay, there is where the crossdev ebuilds go.

To get a tool-chain for arm Linux systems (be aware it takes a bit of time to install)

crossdev -t arm-linux-gnu

PORTDIR_OVERLAY is not an exported environmental variable, so check if the correct Overlay appears. If not, crossdev seems to struggle with that -oO <path> can be used to force it crossdev -oO /usr/local/portage/local-overlay -t avr


If please convert /etc/portage/package.keywords to a directory appearsdo it by renaming the file into package.keywords.file and copy it tin the manually new created directory. However this is not enough repeat it for /etc/portage/package.mask and whatever crossdev -t asks for.

And to get rid of them

crossdev --clean arm-linux-gnu

The stuff installed goes into /usr/target directory

Per default crossdev generates those ebuilds with the latest stable version, therefore it is quite probable that building the avr cross tool-chain will fail since not all (binutils, ...) versions are supported by every target. Therefore options can be set to crossdev to select specific versions. If you run into troubles check the forum and for the news.

To get specific versions

crossdev --b 2.17 -t avr gets binutils version 2.17

crossdev -oO /usr/local/portage/local-overlay --g 4.8.3 -t avr

Linurs Servernest startpage