distcc with Ubuntu and Gentoo – Knowing your defaults

I didn’t use distcc for quite a while. Usually modern dual or quad CPUs are fast in enough to compile in a reasonable time, but after compiling PHP 100 times, I wanted to make things faster and use distcc with my server which otherwise just idles around. My laptop, where I usually compile PHP, is a 1.2Ghz dual core with 2gb ram running Ubuntu 8.10 beta. The server is an up-to-date Gentoo on a 2.7 Ghz dual core with 4GB ram. If you install distcc, which is pretty straight forward, and start compiling you might run into the following error:

/usr/include/bits/stdio2.h:98: undefined reference to `__builtin_va_arg_pack’


At that moment just one thing came into my mind: WTF! Well but as usually, the web knows the answer, as long as you know how to find it.

So let’s go back and start over how to setup distcc on both machines:

ubuntu $ sudo apt-get install distcc
gentoo $ emerge distcc
gentoo $ rc-update add distccd default
gentoo $ vi /etc/conf.d/distccd
and set DISTCCD_OPTS=”${DISTCCD_OPTS} –allow 192.168.1.0/24″
save the file and quit vi.

gentoo $ /etc/init.d/distccd start

Get PHP and extract it on the ubuntu machine:

ubuntu $ wget “http://www.php.net/get/php-5.2.6.tar.bz2/from/www.php.net/mirror”
ubuntu $ tar xjvf php-5.2.6.tar.bz2
ubuntu $ cd php-5.2.6/

So know here is the trick. The undefined reference error occurs as gcc(1) on ubuntu compiles with -fstack-protector, which is not enabled by default on Gentoo. We have to set it during configure so that the option is passed to the gentoo machine and the compilation fits:

ubuntu $ ./configure CC=”distcc” CFLAGS=”-fstack-protector”
ubuntu $ export DISTCC_HOSTS=”localhost gentoo”
ubuntu $ make -j6

And it works! Compilation is done!

and now the boring stats:

make -j3 without distcc
198,27s user 43,41s system 184% cpu 2:11,10 total
make -j6 with distcc
62,69s user 38,02s system 186% cpu 54,044 total

One Comment

Leave a Reply