Distcc/es

Distcc is a program designed to distribute compiling tasks across a network to participating hosts. It is comprised of a server,, and a client program,. Distcc can work transparently with ccache, Portage, and Automake with a little setup.

When planning on using to help bootstrap a Gentoo installation, make sure to read Using distcc to bootstrap.

Instalación
Before configuring, let's first look into the installation of the package on all hosts.

Requisitos para todos los equipos
In order to use, all of the computers on the network need to have the same GCC versions. For example, mixing 3.3.x (where the x varies) is okay, but mixing 3.3.x with 3.2.x may result in compilation errors or runtime errors.

Instalar el software
Distcc ships with a graphical monitor to monitor tasks that a computer is sending away for compilation. This monitor is enabled when the  USE flag is set.

After configuring the USE setting, install the package:

Auto iniciar el demonio distcc
In order to have started automatically, follow the next set of instructions, depending on the init system used.

Usar OpenRC
Edit and make sure to set the   directive to allow only trusted clients. For added security, use the  directive to tell the  daemon what IP to listen on (for multi-homed systems). More information on security can be found at Distcc security notes.

The following example allows the distcc clients running at  and   to connect to the  server running locally:

Now start the daemon on all the participating computers:

Usar systemd
Editar y añadir los clientes permitidos en formato CIDR. A continuación se muestra un ejemplo:

Recargar los fichero de unidad después de realizar estos cambios:

Enable auto-starting and then start the service:

Configuración
Let's now look into the configuration of.

Especificar las máquinas participantes
Use the command to set the list of hosts.

The following is an example list of host definitions. In most cases, variants of lines 1 and 2 suffice. The latter uses the  syntax to inform  about the maximum amount of jobs to be launched on this node. More information about the syntax used in lines 3 and 4 can be found in the distcc manual page.

There are also several other methods of setting up hosts. See the man page ( man distcc ) for more details.

Si se van a realizar compilaciones en la máquina local debería escribir  en la lista de máquinas. Contrariamente, si no se va a utilizar la máquina local para compilar, omítala de la lista de máquinas. En una máquina lenta usar localhost puede de hecho hacer las cosas más lentas. Asegúrese de comprobar los ajustes para mejorar el rendimiento.

Let's configure to use the hosts mentioned on the first line in the example:

Usar distcc con Portage
Setting up Portage to use is easy. It is a matter of enabling the feature, and setting a decent value for the number of simultaneous build jobs (as  increases the amount of build resources).

Ajuste la variable  y la variable   tal y como se describe abajo.

Una estrategia común es
 * Definir el valor de  al doble del número total (local + remotas) de núcleos de CPU + 1, y
 * Definir el valor de  al número de núcleos de CPU locales

The use of  in the   variable will prevent spawning too many tasks when some of the  cluster hosts are unavailable (increasing the amount of simultaneous jobs on the other systems) or when an ebuild is configured to disallow remote builds (such as with gcc). This is accomplished by refusing to start additional jobs when the system load is at or above the value of.

For instance, when there are two quad-core host PCs running and the local PC has a dual core CPU, then the   variable could look like this:

While editing the file, make sure that it does not have   in the   or   variables. will not distribute work to other machines if  is set to. The appropriate  value can be obtained by running the following command:

See Inlining  for distcc for more information.

Usar distcc con automake
This is, in some cases, easier than the Portage setup. All that is needed is to update the  variable to include  in front of the directory that contains. However, there is a caveat. If is used, then put the  location after the  one:

Coloque esto en el archivo del usuario  o fichero equivalente para tener configurada la variable   cada vez que que el usuario entre en el sistema o defínala globlamente en un fichero en

Instead of calling alone, add in   (where   is an integer). The value of  depends on the network and the types of computers that are used to compile. A heuristic approach to the right value is given earlier in this article.

Utilizar distcc para realizar el bootstrap
Using to bootstrap (i.e. build a working toolchain before installing the remainder of the system) requires some additional steps to take.

Paso 1: Configurar Portage
Boot the new box with a Gentoo Linux LiveCD and follow the installation instructions, while keeping track of the instructions in the Gentoo FAQ for information about bootstrapping. Then configure Portage to use :

Actualice también la variable  en la sesión de instalación:

Paso 2: Obtener distcc
Instale :

Paso 3: Configurar distcc
Run to setup distcc; substitute the   in the example with the IP addresses or hostnames of the participating nodes.

Distcc is now set up to bootstrap! Continue with the proper installation instructions and do not forget to run after running. This is to make sure that all of the necessary dependencies are installed.

Extras de distcc
The application has additional features and applications to support working in a  environment.

Monitores de distcc
Distcc ships with two monitoring utilities. The text-based monitoring utility 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 the program is run with no parameter it will run just once. However, if it is passed a number it will update every  seconds, where   is the argument that was passed.

The other monitoring utility is only enabled when the  USE flag is set. This one is GTK+ based, runs in an X environment, and it is quite lovely. For Gentoo, the GUI monitor has been renamed to to make it less confusing (it is originally called ).

To monitor Portage's usage:

Un truco consisten en definir  en variables de entorno:

Ahora actualice el entorno:

Para terminar, arranque la aplicación GUI:

Usar SSH para la comunicación de distcc
La configuración de distcc a través de SSH incluye algunos detalles. En primer lugar, genere un par de claves SSH sin contraseña. Observe que portage compila los programas con el usuario Portage (o como root si no se ha definido ). La carpeta de inicio del usuario Portage es lo que implica que las claves se deben almacenar en.

A continuación cree una sección para cada máquina en el fichero de configuración de SSH:

Envíe la clave pública a cada nodo de compilación:

También asegúrese de que todas las máquinas están listadas en el fichero :

Corrija los permisos del fichero como se muestra a continuación:

To set up the hosts  and , run:

Please note the  (@ sign), which specifies ssh hosts for distcc.

Finally, tell which SSH binary to use:

It is not necessary to run the initscript on the hosts when  communicates via SSH.

Solución a problemas
If a problem occurs while using, then this section might help in resolving the problem.

ERROR: failed to open
A partir del 22 de enero de 2015 la instalación no crea el fichero apropiado en. Esto afecta aparentemente solo a la versión 3.1-r8 de distcc. Esta incidencia está en proceso de solución (ver ). Es posible evitar este problema creando manualmente el fichero de registro, asignarle el propietario adecuado y reiniciando el demonio distccd:

Next update the path of the  configuration file in  to the  directory created in the step before:

Para terminar, reinicie el servicio distccd:

Algunos paquetes no utilizan distcc
A medida que se instalan algunos paquetes, los usuarios observarán que la construcción de algunos de ellos no se está realizando (y por tanto no se están construyendo en paralelo). Esto puede ocurrir porque el fichero del paquete no soporta operaciones en paralelo o el mantenedor del ebuild ha deshabilitado explícitamente dichas operaciones en paralelo debido un problema conocido.

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

Versiones mezcladas de GCC
Si el entorno aloja versiones diferentes de GCC, probablemente tenga problemas extraños. La solución es asegurarse de que todas las máquinas tengan la misma versión.

Las actualizaciones de Portage más recientes utilizan  (menos gcc) en lugar de. Esto significa que si se mezclan máquinas i686 con otros tipos de máquina (i386, i586) entonces las construcciones darán problemas. Una solución temporal a esto es lanzar:

También es posible definir las variables  y   en  a los valores listados en la orden de arriba.

-march=native
Starting with GCC 4.3.0, the compiler supports the  option which turns on CPU auto-detection and optimizations that are worth being enabled on the processor on which GCC is running. This creates a problem when using because it allows the mixing of code optimized for different processors. For example, running with   on a system that has an AMD Athlon processor and doing the same on another system that has an Intel Pentium processor will mix code compiled on both processors together.

Preste atención a la siguiente advertencia:

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

Ver también

 * The DistCC Cross-compiling guide explains how using one architecture to build programs for another architecture is done through . 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 PowerPC.

Recursos externos

 * Inlining  for distcc
 * Distcc homepage