Site menu:

Search

Tag Cloud

Lifestream

My Web

Last.fm  Delicious  Facebook  Flickr  LinkedIn  Twitter  Technorati  My TV shows  Prt.sc  Brightkite  Adegga  

DISTCC + AVAHI

When considering a project involving a large number of source files, compilation time is always an issue.
DistCC is in these cases a very good solution.
From DistCC site:

distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network. distcc should always generate the same results as a local build, is simple to install and use, and is usually much faster than a local compile

My problem was how to keep the $DISTCC_HOSTS variable updated, since computers in my lab never seam to be left alone (after all… this is a lab :) ).

My idea was therefore to use AVAHI and to come up with a simple unix pipe that would feed the $DISTCC_DIR/hosts file.

Here is my hack:

  1. created /etc/avahi/services/distcc.service:

    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
    <name replace-wildcards="yes">Distcc on %h</name>
    <service>
    <type>_distcc._tcp</type>
    </service>
    </service-group>

  2. Install distcc and avahi-utils

    apt-get install distcc avahi-utils

  3. edit /etc/defaultdistcc accordingly
  4. add the following command to crontab:
  5. avahi-browse _distcc._tcp -t -r | grep address | egrep -v : | cut -d [ -f 2 | cut -d ] -f 1 | paste -s -d' ' > ~/.distcc/hosts

That’s it!

There is also a patch available for distcc to integrate avahi functionality in a more robust manner (for instance by hack will cause problems when compiling during the update of the file), but I didn’t want to patch my Ubuntu distcc version. Best of all it is much easier to distribute the distcc.service file then a patched version of distcc ;) .

Comments

Comment from dgomes
Time 21 August, 2007 at 13:23

In step 4. you can ignore the “egrep -v :”.
It is only meant to disable IPv6 hosts (my distcc doesn’t behave well over IPv6 :( )

[Reply]

Comment from Zeeshan Ali
Time 11 September, 2008 at 20:12

Cool Stuff! Thanks a lot for this info.

[Reply]

Comment from Brad Phelan
Time 15 October, 2008 at 10:20

Nice…. I’ve been looking around for this.

[Reply]

Comment from Stargazer
Time 7 January, 2009 at 12:35

Nice shot, guess I’ll try that with the kde4 svn builds now :)

[Reply]

Comment from Miguel Luis
Time 2 March, 2009 at 19:38

Nice trick! Now if we get ccache in the mix we might improve recompilation time even more! :)

[Reply]

Write a comment