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 ;) .

Written by Diogo Gomes on August 21, 2007 under English.

Comments

  • dgomes

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

  • Zeeshan Ali

    11 September, 2008 at 20:12


    Cool Stuff! Thanks a lot for this info.

  • Brad Phelan

    15 October, 2008 at 10:20


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

  • Stargazer

    7 January, 2009 at 12:35


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

  • Miguel Luis

    2 March, 2009 at 19:38


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

Add a Comment

* means field is required.

Name *

Mail *

Website

blog comments powered by Disqus