Cross Compilation Across Several Networked Computers on Gentoo

This tutorial covers crossdev and distcc that allow users to cross compile across several networked computers on Gentoo.

I used it on an Intel Celeron (i686) which ran the emerge and my Dell with an Intel i5 (x86_64), which worked as the helper box.

Setup Network

First of all, we setup a network of computers. I connected the two computers via an ethernet cable and ran a dhcp server on the Dell. The Dell running the server had the IP address and the Celeron was assigned

Find Target Architecture

Now, we have to find out the CHOST of the target architecture (the box running emerge):

# cat /etc/portage/make.conf | grep CHOST

In my case, the output was:


Thus we find out the target architecture which was in my case i686-pc-linux-gnu.

Configure distcc for Cross Compilation

Now we have to configure distcc to cross compile correctly. We will perform the following steps on our helper box.

First of all we convert /etc/portage/package.use to a directory:

# mv /etc/portage/package.use /etc/portage/package.use.old
# mkdir /etc/portage/package.use
# cp /etc/portage/package.use.old /etc/portage/package.use/my_package_use


# emerge crossdev
# crossdev -t i686-pc-linux-gnu

Replace i686-pc-linux-gnu with your target architecture.

The following steps are to be performed only on the box running the emerge:

# cd /usr/lib/distcc/bin
# rm c++ g++ gcc cc

Next, fire up your favorite editor and create a file with the following text, then save it as i686-pc-linux-gnu-wrapper. Remember to change the CHOST:

exec /usr/lib/distcc/bin/i686-pc-linux-gnu-g${0:$[-2]} "$@"

Next, we’ll make the script executable and create the proper symlinks:

# chmod a+x i686-pc-linux-gnu-wrapper
# ln -s i686-pc-linux-gnu-wrapper cc
# ln -s i686-pc-linux-gnu-wrapper gcc
# ln -s i686-pc-linux-gnu-wrapper g++
# ln -s i686-pc-linux-gnu-wrapper c++

Installing and Setting up distcc

Perform the following steps on all the participating computers:

# emerge distcc

Now, edit make.conf:

# nano -w /etc/portage/make.conf
(Set N to a suitable number for your particular setup)
 (A common strategy is setting N as twice the number of total CPUs + 1 available)
(Add distcc to your FEATURES)

Edit /etc/conf.d/distccd, here is my example:

# nano -w /etc/conf.d/distccd
DISTCCD_OPTS="${DISTCCD_OPTS} --log-level notice"

With –log-level notice we can see syslog(tail -f /var/log/messages) which compilation units are sent to the helper box.

Finally edit /etc/distcc/hosts and put the hosts that are participating in the process. You may also run the following:

# /usr/bin/distcc-config --set-hosts ""

Remember to change the hosts according to your network.

Don’t forget to regenerate your environment:

# env-update

Now, run distccd daemon on all the participating computers:

# /etc/init.d/distccd start

That is it. Run emerge on the target machine (the Celeron in my case) and test the configuration.

You may also look at the Gentoo Linux article on distcc and cross compilation.