Site search

Site menu:

Tags

Recent favourite

  1. cd cover

dgomes@twitter

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 1:23 pm

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 :( )

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

Cool Stuff! Thanks a lot for this info.

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

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

Write a comment