by April 7, 2013
onCompiling and building of portage packages takes quite a while when using the Raspberry Pi. Fortunately there is a nice way to use your main workstation’s (probably much greater) computation power to your Pi’s good: distcc
Diclaimer : This article expects your build servers to run gentoo linux as well and to be configured to cross compile Raspberry Pi compatible ARM (arm6j-hardfloat-linux-gnueabi) binaries. Until I find some time to write a small howto for that you can read the respective gentoo documentation on distcc cross-compiling.
At first we are going to prepare all your build servers that should assist your Raspberry Pi during the compilation process.
First you have to install sys-devel/distcc:
$ emerge -av sys-devel/distcc
After you have successfully installed distcc on your build server(s) you can adjust the configuration to your likings. The configuration file usually can be found at /etc/conf.d/distcc
.
# set the access rights for your distcc daemon to the right network subnet
# you can also list single IP addresses
DISTCCD_OPTS="${DISTCCD_OPTS} --allow 192.168.1.0/24"
# especially during the setup phase I found increasing the log level very helpful
DISTCCD_OPTS="${DISTCCD_OPTS} --log-file /var/log/distccd"
DISTCCD_OPTS="${DISTCCD_OPTS} --log-level info"
Now you can start your distcc daemon using the init scripts:
$ /etc/init.d/distccd start
Additionally you may want to add the distcc service to your default runlevel:
$ rc-update add distccd default
After you prepared your build server(s) you can move on to setup your Raspberry Pi.
You have to install distcc on your Raspberry Pi as well:
$ emerge -av sys-devel/distcc
Additionally you have to add distcc to your portage features. Edit your make.conf
appropriately:
FEATURES="distcc"
Now you have to specify which build servers should be taken into account when using distcc. In the /etc/distcc/hosts
file you can list all server addresses. The order defines the priorities:
Finally you have to tell distcc which compiler has to be used instead of gcc
- you can use a wrapper script like this for this purpose:
Now you just have to replace the existing symbolic links like this:
# move in your distcc folder
$ cd /usr/lib/distcc/bin
# set the executable flag on the wrapper script
$ chmod +x wrapper
# remove the old symlinks
$ rm cc c++ gcc g++
# link to the wrapper script
$ ln -s wrapper cc
$ ln -s wrapper c++
$ ln -s wrapper gcc
$ ln -s wrapper g++
Now that all necessary steps are taken you can test the distcc setup when emerging a cross-compile compatible package.
$ emerge -va htop
You can observe the distcc daemon log on one of your build servers in order to check if your build servers are utilized during the compilation phase:
$ tail -f /var/log/distccd