view · edit · print · history


HowTo use a "distcc-farm" to crosscompile for the slug.

I'll try to figure out a easy and seamless way of using "emerge" command at the slug to automaticly start cross-compile on gentoo desktop. Therby greatly reducing compile time on the slug.

Setup a distcc host (gentoo desktop)

  • install distcc
# emerge distcc
  • Edit the /etc/conf.d/distccd to specify allowed hosts
  • Start distcc and set it to run every time you boot up
    • # /etc/init.d/distccd start
    • # rc-update add distccd default
  • Install crossdev
# emerge crossdev
  • Install your cross compiler
The below text assumes that your slug's gentoo installation is big-endian with uclibc. You should use the same value you used for your CHOST in /etc/make.conf (on your slug).
# crossdev armeb-softfloat-linux-uclibc
Note: If the currently unmasked compiler is a different version than the one used on your slug, you will need to specify the gcc version you will be using on your slug.
# crossdev --gcc 3.4.6 armeb-softfloat-linux-uclibc
This won't always result in the exact gcc version, but it should be a binary-compatible version.
This didn't work for me. I first had to switch both compiler profiles to slug compatible versions by doing:

To get a list of available compilers do:

# gcc-config -l

[1] armeb-softfloat-linux-uclibc-3.4.6
[5] x86_64-pc-linux-gnu-3.4.6
followed by:

# gcc-config armeb-softfloat-linux-uclibc-3.4.6 # gcc-config x86_64-pc-linux-gnu-3.4.6

And then continue with the steps noted above.

Setup the slug

  • Install distcc
# emerge distcc
  • Tell portage to use distcc by adding "distcc" to your FEATURES list in /etc/make.conf
  • Increase the number of files compiled at the same time by adding a -jN flag to your MAKEOPTS in /etc/make.conf
I find that -j2 works pretty good. Any more than that and a non-fattened slug will start swapping.
  • Specify the machines to remotely run distcc
# distcc-config --set-hosts "<machine1>/count1 <machine2>/count2"
Replace <machineN> with the name (if it can be resolved) of a distcc host.
The /countN is optional, and can be used to limit the number of concurrent builds on a distcc host.
# distcc-config --set-hosts ""
Note that localhost is NOT in the list. It will fall back to the local host if the remote one is down, but every other compilation should be done on a remote machine to ease the burden on the poor slug.
  • Modify the /usr/lib/distcc/bin directory so the proper compiler will be invoked on the remote distcc hosts.
Here's a script that will correct it for you: DistccCrossCompileFixupScript

Check that it works

  • On your slug, create the normal hello world program. That would be something like this:
#include <stdio.h>
int main(int argc, const char** argv)
  printf("Hello, World\n");
  return 0;
  • Add the distcc directory to your path (portage builds will do this automatically if distcc is in the FEATURES)
# export PATH=/usr/lib/distcc/bin:$PATH
  • Compile your hello world program with lots of distcc verbosity
# DISTCC_VERBOSE=1 gcc -c hello.c -o hello.o
  • Look for a line that says something like this: "compile hello.c on completed ok"
  • You can also check if things are working with "netstat -n 1 | grep ip.of.client.machine"
  • Link your object file into an executable and run it
# gcc hello.o -o hello
# ./hello
Note that distcc will run the preprocessor and linker on the slug so it will not build remotely if your compilation line does linking as well.
  • Repeat the above test with g++ (just to be safe).


view · edit · print · history · Last edited by jaguarondi.
Based on work by jaguarondi, Benjamin Wiedmann, bernied, Kevin Harris, and Stein.
Originally by Stein.
Page last modified on May 07, 2007, at 04:56 PM