Distcc/it

Distcc è un programma progettato per distribuire i processi di compilazione, attraverso una rete, a degli host partecipanti. È composto da un server,, e da un client,. Distcc funziona in modo trasparente con ccache, Portage e perfino Automake, con un po di lavoro.

Se stai pensando di usare distcc per facilitare il bootstrap di una installazione di Gentoo, assicurati di leggere la sezione Usare Distcc per il Bootstrap.

Dipendenze
Per poter usare Distcc, tutti i computer sulla rete devono avere la stessa versione di GCC. Ad esempio, mescolare GCC 3.3.x (dove la x è variabile) non è un problema, ma mescolare 3.3.x e 3.2.x potrebbe generare errori in fase di compilazione o di esecuzione.

Installazione di Distcc
Ci sono un paio di opzioni che dovresti conoscere prima di cominciare a installare distcc.

Distcc viene distribuito con un monitor grafico per controllare i task che il computer destina alla compilazione. Se si usa Gnome, occorre inserire 'gnome' tra le flag USE. Nel caso in cui non si usi Gnome ma si volesse comunque avere il monitor grafico, allora la flag USE da inserire sarebbe 'gtk'.

Configurare portage all'uso di Distcc
Far usare distcc a Portage è semplice. Eseguire i passaggi seguenti su tutti i sistemi che partecipano alla compilazione distribuita:

Adesso, impostare le variabili  e   come mostrato sotto. Una strategia comune consiste nell'impostare N al doppio del numero totale delle CPU (locali+remote)+1, ed M al numero delle CPU locali. NEl caso in cui non siano disponibili host distcc, o che l'ebuild richieda una compilazione esplicitamente locale (ad esempio, gcc), la flag  preverrà l'apertura di troppi task.

Specifying Participating Hosts
Use the  command to set the list of hosts. Here is an example of some hosts that might be in your list:

Examples of host definitions

There are also several other methods of setting up hosts. See the distcc manpage for more details.

If you wish to compile on the local machine you should put 'localhost' in the hosts list. Conversely if you do not wish to use the local machine to compile (which is often the case) omit it from the hosts list. On a slow machine using localhost may actually slow things down. Make sure to test your settings for performance.

It may all look complicated, but in most cases a variant of line 1 or 2 will work.

Since most people won't be using lines 3 or 4, I'll refer to the distcc docs (man distcc) for more information, which includes being able to run distcc over an SSH connection.

For instance, to set the first line in the previous example:

Edit to your needs and be sure to set the   directive to allow only hosts you trust. For added security, you should also use the  directive to tell the distcc daemon what IP to listen on (for multi-homed systems). More information on distcc security can be found at Distcc Security Design.

Now start the distcc daemon on all the participating computers:

Setting up Distcc to Work With Automake
This is, in some cases, easier than the Portage setup. What you have to do is update your  variable to include  in front of the directory that contains. However, there is a caveat. If you use ccache you have to put distcc after the ccache part:

You can put this in your or equivalent file to have the PATH set every time you log in.

Then, as you would normally type , you would type   (where N is an integer). The value of N depends on your network and the types of computers you are using to compile. Test your own settings to find the number that yields the best performance.

Cross-Compiling
Cross-compiling is using one architecture to build programs for another architecture. This can be as simple as using an Athlon (i686) to build a program for a K6-2 (i586), or using a Sparc to build a program for a ppc. This is documented in our DistCC Cross-compiling Guide.

Step 1: Configure Portage
Boot your new box with a Gentoo Linux LiveCD and follow the installation instructions up until the bootstrapping part. (See the Gentoo FAQ for more information about bootstrapping.) Then configure Portage to use distcc:

Step 2: Getting Distcc
Install distcc:

Step 3: Setting Up Distcc
Run  to setup distcc; substitute   with the IP addresses or hostnames of the participating DistCC nodes.

Distcc is now set up to bootstrap! Continue with the official installation instructions and do not forget to re-emerge distcc after. This is to make sure that all of the dependencies you want are installed as well.

Some Packages Don't Use Distcc
As you emerge various packages, you'll notice that some of them aren't being distributed (and aren't being built in parallel). This may happen because the package's Makefile doesn't support parallel operations or the maintainer of the ebuild has explicitly disabled parallel operations due to a known problem.

Sometimes distcc might cause a package to fail to compile. If this happens for you, please report it to us.

Mixed GCC Versions
If you have different GCC versions on your hosts, there will likely be very weird problems. The solution is to make certain all hosts have the same GCC version.

Recent Portage updates have made Portage use  instead of. This means that if you're mixing i686 machines with other types (i386, i586) you will run into problems. A workaround for this may be to  or to put it in.

-march=native
Starting with GCC 4.3.0, the compiler supports the  switch which turns on CPU autodetection and optimizations that are worth being enabled on the processor the GCC is running at. This is a problem with  as it allows mixing of code optimized for different processors (like AMD Athlon and Intel Pentium). Don't use  or   in your   or   when compiling with.

To know the flags that GCC would enable when called with, execute the following:

Distcc Monitors
Distcc ships with two monitors. The text-based one is always built and is called. Running it for the first time can be a bit confusing, but it is really quite easy to use. If you run the program with no parameter it will run once. However, if you pass it a number it will update every N seconds, where N is the argument you passed.

The other monitor is only turned on if you enabled  or   in your   flags. This one is GTK+ based, runs in an X environment and it is quite lovely. For Gentoo the GUI monitor has been called  for less confusion. Elsewhere it may be referred to as.

or run :

To monitor Portage's distcc usage you can use:

Acknowledgements
We would like to thank the following authors and editors for their contributions to this guide:


 * Lisa Seelye
 * Mike Frysinger
 * Erwin
 * Sven Vermeulen
 * Lars Weiler
 * Tiemo Kieft
 * nightmorph