Difference between revisions of "Distcc"

From ArchWiki
Jump to navigation Jump to search
(32-bit x86 (i686): fix broken section links)
m (Client: add link to aur package)
 
(20 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 +
{{Lowercase title}}
 +
[[Category:Distributed computing]]
 +
[[Category:Development]]
 
[[Category:Package development]]
 
[[Category:Package development]]
[[Category:Distributed computing]]
 
 
[[it:Distcc]]
 
[[it:Distcc]]
 
[[ja:Distcc]]
 
[[ja:Distcc]]
Line 10: Line 12:
 
{{Related articles end}}
 
{{Related articles end}}
  
Distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network to speed up building. It 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. Further, one can use it together with native Arch build tools such as makepkg.
+
[[Wikipedia:distcc|distcc]] is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network to speed up building. It 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. Further, one can use it together with native Arch build tools such as makepkg.
  
 
== Terms ==
 
== Terms ==
  
; master: The master is the computer which initiates the compilation.
+
; client: The client is the computer initiating the compilation.
; slave: The slave accepts compilation requests send by the master.  One can setup multiple slave systems or just a single one.
+
; volunteer: The volunteer is the computer accepting compilation requests send by the client.  One can setup multiple volunteers or just a single one.
 
 
  
 
== Getting started ==
 
== Getting started ==
  
[[Install]] the {{pkg|distcc}} package on all participating  PCs in the distcc cluster.  For other distros, or even operating systems including Windows through using Cygwin, refer to the [http://distcc.samba.org/doc.html distcc docs].
+
[[Install]] the {{pkg|distcc}} package on all participating  PCs in the distcc cluster.  For other distros, or even operating systems including Windows through using Cygwin, refer to the [http://distcc.samba.org/doc.html distcc docs].  Be sure to allow traffic on the port on which distcc runs (the default is 3632/tcp), see [[:Category:Firewalls]] and {{man|1|distcc}}.
  
 
== Configuration ==
 
== Configuration ==
  
=== Slaves ===
+
=== Volunteers ===
  
The configuration for the slave machine is stored in {{ic|/etc/conf.d/distccd}}. At a minimum, configure the allowed address ranges in [[wikipedia:Classless_Inter-Domain_Routing|CIDR]] format:
+
The configuration for the volunteer is stored in {{ic|/etc/conf.d/distccd}}. At a minimum, configure the allowed address ranges in [[wikipedia:Classless_Inter-Domain_Routing|CIDR]] format:
  
  DISTCC_ARGS="--allow 192.168.0.0/24"
+
  DISTCC_ARGS="--allow 192.168.10.0/24"
  
A nice tool for converting address ranges to CIDR format can be found here: [http://www.ipaddressguide.com/cidr CIDR Utility Tool].  Other commandline options can be defined as well.  Refer to {{man|1|distcc}}.
+
A nice tool for converting address ranges to CIDR format can be found here: [http://www.ipaddressguide.com/cidr CIDR Utility Tool].  Other commandline options can be defined as well.  Refer to {{man|1|distcc}}.  
  
[[Start]] {{ic|distccd.service}} on every participating slave. To have {{ic|distccd.service}} start at boot-up, [[enable]] it.
+
[[Start]] {{ic|distccd.service}} on every participating volunteer. To have {{ic|distccd.service}} start at boot-up, [[enable]] it.
  
=== Master ===
+
=== Client ===
 
==== For use with makepkg ====
 
==== For use with makepkg ====
  
Line 40: Line 41:
  
 
# The BUILDENV array will need to have ''distcc'' unbanged i.e. list it without exclamation point.
 
# The BUILDENV array will need to have ''distcc'' unbanged i.e. list it without exclamation point.
# Uncomment the ''DISTCC_HOSTS'' line and add the IP addresses of the slaves then a slash and the number of threads they are to use.  The subsequent IP address/threads should be separated by a white space.  This list is ordered from most powerful to least powerful (processing power).
+
# Uncomment the ''DISTCC_HOSTS'' line and add the host name or IP addresses of the volunteers. Optionally, follow this with a forward slash and the max number of threads they are to use.  The subsequent nodes should be separated by a white space.  This list should be ordered from most powerful to least powerful (processing power).
 
# Adjust the MAKEFLAGS variable to correspond to the number of sum of the number of individual values specified for the max threads per server.  In the example below, this is 5+3+3=11.
 
# Adjust the MAKEFLAGS variable to correspond to the number of sum of the number of individual values specified for the max threads per server.  In the example below, this is 5+3+3=11.
 
{{Note|The number of threads is commonly set as the number of cores plus 1.  Do this on a per-server basis, ''not'' in the {{ic|MAKEFLAGS}} variable.}}
 
  
 
Example using relevant lines:
 
Example using relevant lines:
Line 49: Line 48:
 
  BUILDENV=(distcc fakeroot color !ccache check !sign)
 
  BUILDENV=(distcc fakeroot color !ccache check !sign)
 
  MAKEFLAGS="-j11"
 
  MAKEFLAGS="-j11"
  DISTCC_HOSTS="192.168.0.2/5 192.168.0.3/3 192.168.0.4/3"
+
  DISTCC_HOSTS="192.168.10.2/5 192.168.10.3/3 192.168.10.4/3"
  
{{Note|The {{ic|1=-march=native}} flag cannot be used in the {{ic|CFLAGS}} and {{ic|CXXFLAGS}} variables, otherwise distccd will not distribute work to other machines.}}
+
{{Warning|The {{ic|1=-march=native}} flag cannot be used in the {{ic|CFLAGS}} and {{ic|CXXFLAGS}} variables, otherwise distccd will not distribute work to other machines.}}
  
 
==== For use without makepkg ====
 
==== For use without makepkg ====
  
The minimal configuration for distcc on the master includes the setting of the available slaves. This can either be done by setting the addresses in the environment variable {{ic|DISTCC_HOSTS}} or in either of the configuration files {{ic|$DISTCC_HOSTS}}, {{ic|$DISTCC_DIR/hosts}}, {{ic|~/.distcc/hosts}} or {{ic|/etc/distcc/hosts}}.
+
The minimal configuration for distcc on the client includes the setting of the available volunteers. This can either be done by setting the addresses in the environment variable {{ic|DISTCC_HOSTS}} or in either of the configuration files {{ic|$DISTCC_HOSTS}}, {{ic|$DISTCC_DIR/hosts}}, {{ic|~/.distcc/hosts}} or {{ic|/etc/distcc/hosts}}.
  
Example for setting the slave address using {{ic|DISTCC_HOSTS}}:
+
Example for setting the volunteer address using {{ic|DISTCC_HOSTS}}:
  
  $ export DISTCC_HOSTS="192.168.0.3,lzo,cpp 192.168.0.4,lzo,cpp"
+
  $ export DISTCC_HOSTS="192.168.10.3,lzo,cpp 192.168.10.4,lzo,cpp"
  
 
{{Note|This is a white space separated list.}}
 
{{Note|This is a white space separated list.}}
  
Example for setting the slave addresses in the hosts configuration file:
+
Example for setting the volunteer addresses in the hosts configuration file:
  
 
{{hc|~/.distcc/hosts|
 
{{hc|~/.distcc/hosts|
192.168.0.3,lzo,cpp 192.168.0.4,lzo,cpp
+
192.168.10.3,lzo,cpp 192.168.10.4,lzo,cpp
 
}}
 
}}
  
Instead of explicitly listing the server addresses one can also use the avahi zeroconf mode. To use this mode {{ic|+zeroconf}} must be in place instead of the server addresses and the distcc daemons on the slaves have to be started using the {{ic|--zeroconf}} option. Note that this option does not support the pump mode!
+
Instead of explicitly listing the server addresses one can also use the avahi zeroconf mode. To use this mode {{ic|+zeroconf}} must be in place instead of the server addresses and the distcc daemons on the volunteers have to be started using the {{ic|--zeroconf}} option. Note that this option does not support the pump mode!
  
 
The examples add the following options to the address:
 
The examples add the following options to the address:
  
* {{ic|lzo}}: Enables LZO compression for this TCP or SSH host (slave).
+
* {{ic|lzo}}: Enables LZO compression for this TCP or SSH host (volunteer).
* {{ic|cpp}}: Enables distcc-pump mode for this host (slave). Note: the build command must be wrapped in the pump script in order to start the include server.
+
* {{ic|cpp}}: Enables distcc-pump mode for this host (volunteer). Note: the build command must be wrapped in the pump script in order to start the include server.
  
A description for the pump mode can be found here: [http://distcc.googlecode.com/svn%20...%20%3Cdiv%20class=/trunk/doc/web/man/distcc_1.html#TOC_8 HOW DISTCC-PUMP MODE WORKS] and [http://google-opensource.blogspot.de/2008/08/distccs-pump-mode-new-design-for.html distcc's pump mode: A New Design for Distributed C/C++ Compilation ]
+
A description for the pump mode can be found here: [http://google-opensource.blogspot.de/2008/08/distccs-pump-mode-new-design-for.html distcc's pump mode: A New Design for Distributed C/C++ Compilation ]
  
To use distcc-pump mode for a slave, users must start the compilation using the pump script otherwise the compilation will fail.
+
To use distcc-pump mode for a volunteer, users must start the compilation using the pump script otherwise the compilation will fail.
  
 
== Compile ==
 
== Compile ==
Line 109: Line 108:
  
 
{{bc|$ distccmon-text 3
 
{{bc|$ distccmon-text 3
29291 Preprocess  probe_64.c                                192.168.0.2[0]
+
29291 Preprocess  probe_64.c                                192.168.10.2[0]
30954 Compile    apic_noop.c                                192.168.0.2[0]
+
30954 Compile    apic_noop.c                                192.168.10.2[0]
30932 Preprocess  kfifo.c                                    192.168.0.2[0]
+
30932 Preprocess  kfifo.c                                    192.168.10.2[0]
30919 Compile    blk-core.c                                192.168.0.2[1]
+
30919 Compile    blk-core.c                                192.168.10.2[1]
30969 Compile    i915_gem_debug.c                          192.168.0.2[3]
+
30969 Compile    i915_gem_debug.c                          192.168.10.2[3]
30444 Compile    block_dev.c                                192.168.0.3[1]
+
30444 Compile    block_dev.c                                192.168.10.3[1]
30904 Compile    compat.c                                  192.168.0.3[2]
+
30904 Compile    compat.c                                  192.168.10.3[2]
30891 Compile    hugetlb.c                                  192.168.0.3[3]
+
30891 Compile    hugetlb.c                                  192.168.10.3[3]
30458 Compile    catalog.c                                  192.168.0.4[0]
+
30458 Compile    catalog.c                                  192.168.10.4[0]
30496 Compile    ulpqueue.c                                192.168.0.4[2]
+
30496 Compile    ulpqueue.c                                192.168.10.4[2]
30506 Compile    alloc.c                                    192.168.0.4[0]
+
30506 Compile    alloc.c                                    192.168.10.4[0]
 
}}
 
}}
  
== "Cross Compiling" with distcc ==
+
== Cross Compiling with distcc ==
 
+
One can use distcc to help cross compile.   
=== 32-bit x86 (i686) ===
+
* A machine running the target architecture should be used as the client.
{{out of date|The [[Install bundled 32-bit system in 64-bit system]] article has been archived}}
+
* Non-native architecture volunteers will help compile but they require the corresponding toolchain to be installed and their distcc to point to it.  
There are currently two methods from which to select to have the ability of distcc distribution of tasks over a cluster building i686 packages from a native x86_64 environmentNeither is ideal, but to date, there are the only two methods documented on the wiki.
 
 
 
An ideal setup is one that uses the unmodified ARCH packages for distccd running only once one each node regardless of building from the native environment or from within a chroot AND one that works with makepkg.  Again, this Utopian setup is not currently known.
 
 
 
A [https://bbs.archlinux.org/viewtopic.php?id=129762 discussion thread] has been started on the topic; feel free to contribute.
 
 
 
==== Chroot method (preferred) ====
 
 
 
{{Note|This method works, but is not very elegant requiring duplication of distccd on all nodes AND need to have a 32-bit chroots on all nodes.}}
 
 
 
Assuming the user has a [[Install bundled 32-bit system in 64-bit system|32-bit chroot]] setup and configured on '''each node''' of the distcc cluster, the strategy is to have two separate instances of distccd running on different ports on each node -- one runs in the native x86_64 environment and the other in the x86 chroot on a modified port.  Start makepkg via a {{man|1|schroot}}  command invoking makepkg.
 
 
 
===== Add port numbers to DISTCC_HOSTS on the i686 chroot =====
 
 
 
Append the port number defined eariler (3692) to each of the hosts in {{ic|/opt/arch32/etc/makepkg.conf}} as follows:
 
 
 
DISTCC_HOSTS="192.168.1.101/5:3692 192.168.1.102/5:3692 192.168.1.103/3:3692"
 
 
 
{{Note|This only needs to be setup on the "master" i686 chroot.  Where "master" is defined as the one from which the compilation will take place.}}
 
 
 
===== Invoke makepkg from the Native Environment =====
 
 
 
Set up {{Pkg|schroot}} on the native x86_64 environment.  Invoke makepkg to build an i686 package from the native x86_64 environment, simply by:
 
 
 
$ schroot -p -- makepkg -src
 
 
 
==== Multilib GCC method (not recommended) ====
 
 
 
See [[Makepkg#Build 32-bit packages on a 64-bit system]].
 
  
=== Other architectures ===
+
=== Arch Linux ARM ===
==== Arch Linux ARM ====
+
==== Volunteers ====
When building on an Arch Linux ARM device, the developers ''highly'' recommend using the official project [https://archlinuxarm.org/wiki/Distcc_Cross-Compiling toolchains] which should be installed on the x86_64 slave machine(s).  Rather than manually managing these, the [[AUR]] provides all four toolchains as well as simple systemd service units:
+
The developers ''highly'' recommend using the official project [https://archlinuxarm.org/wiki/Distcc_Cross-Compiling toolchains] which should be installed on the x86_64 volunteer(s).  Rather than manually managing these, the [[AUR]] provides all four toolchains as well as simple systemd service units:
 
* {{AUR|distccd-alarm-armv5}}
 
* {{AUR|distccd-alarm-armv5}}
 
* {{AUR|distccd-alarm-armv6h}}
 
* {{AUR|distccd-alarm-armv6h}}
Line 164: Line 134:
 
* {{AUR|distccd-alarm-armv8}}
 
* {{AUR|distccd-alarm-armv8}}
  
Setup on the slave machine containing the toolchain is identical to [[#Slaves]] except that the name of the configuration file matches that of the respective package.  For example, {{ic|/etc/conf.d/distccd-armv7h}}.
+
Setup on the volunteer containing the toolchain is identical to [[#Volunteers]] except that the name of the configuration and systemd service file matches that of the respective package.  For example, for armv7h the config file is {{ic|/etc/conf.d/distccd-armv7h}} and the systemd service unit is {{ic|distccd-armv7h.service}}.
  
A systemd service unit is provided for each respective packageFor example, {{ic|distccd-armv7h.service}}.
+
Note that each of the toolchains runs on a unique port thus allowing them to co-exist on the volunteer if neededBe sure to allow traffic to the port on which distcc runs see [[:Category:Firewalls]] and {{man|1|distcc}}.
  
==== Additional toolchains ====
+
{| class="wikitable" align="center"
 +
|-
 +
! Target architecture !! Distcc Port
 +
|-
 +
| ''armv5'' || 3633
 +
|-
 +
| ''armv6h'' || 3634
 +
|-
 +
| ''armv7h'' || 3635
 +
|-
 +
| ''armv8h/aarch64'' || 3636
 +
|-
 +
|}
 +
 
 +
==== Client ====
 +
Setup of the client is identical to [[#Client]] except, one needs to modify the following two files to define the now non-standard port the volunteers are expected to use.  Refer to the table above if using the AUR package.
 +
# {{ic|/etc/conf.d/distcc}}: example on an armv7h machine: {{ic|1=DISTCC_ARGS="--allow 127.0.0.1 --allow 192.168.10.0/24 --port 3635}}
 +
# {{ic|/etc/makepkg.conf}}: example on an armv7h machine: {{ic|1=DISTCC_HOSTS="192.168.10.2/5:3635 192.168.10.3/5:3635"}}
 +
 
 +
Alternatively, the {{AUR|distccd-arch-arm}} package will provide the needed systemd service files to enable distccd compilation.
 +
 
 +
=== Additional toolchains ===
 
* [https://embtoolkit.org/ EmbToolkit]: Tool for creating cross compilation tool chain; supports ARM and MIPS architectures; supports building of an LLVM based tool chain
 
* [https://embtoolkit.org/ EmbToolkit]: Tool for creating cross compilation tool chain; supports ARM and MIPS architectures; supports building of an LLVM based tool chain
 
* [http://crosstool-ng.org/ crosstool-ng]: Similar to EmbToolkit; supports more architectures (see website for more information)
 
* [http://crosstool-ng.org/ crosstool-ng]: Similar to EmbToolkit; supports more architectures (see website for more information)
Line 183: Line 174:
 
  $ journalctl $(which distccd) -e --since "5 min ago"
 
  $ journalctl $(which distccd) -e --since "5 min ago"
  
=== code 110 ===
+
=== Adjust log level ===
  
Make sure that the tool chain works for the user account under which the distcc daemon process gets started (default is nobody). The following will test if the tool chain works for user nobody. In {{ic|/etc/passwd}} change the login for the nobody user to the following:
+
By default, distcc will log to {{ic|/var/log/messages.log}} as it goes along.  One trick (actually recommended in the distccd manpage) is to log to an alternative file directly.  Again, one can locate this in RAM via /tmp.  Another trick is to lower to log level of minimum severity of error that will be included in the log file.  Useful if only wanting to see error messages rather than an entry for each connection.  LEVEL can be any of the standard syslog levels, and in particular critical, error, warning, notice, info, or debug.
  
{{hc|$ cat /etc/passwd|
+
Either call distcc with the arguments mentioned here on the client or appended it to DISTCC_ARGS in {{ic|/etc/conf.d/distccd}} on the volunteers:
...
 
nobody:x:99:99:nobody:/:/bin/bash
 
...
 
}}
 
  
Then cd into the directory containing the cross compiler binaries and try to execute the compiler:
+
DISTCC_ARGS="--allow 192.168.10.0/24 --log-level error --log-file /tmp/distccd.log"
  
# su nobody
+
=== Limit HDD/SSD usage by relocating $HOME/.distcc ===
$ ./gcc --version
 
bash: ./gcc: Permission denied
 
  
Users experiencing this error should make sure that groups permissions as described in [[#Other architectures]] are correctly in setup.
+
By default, distcc creates {{ic|$HOME/.distcc}} which stores transient relevant info as it serves up work for nodes to compile. This will avoid needless HDD read/writes and is particularly important for SSDs.
  
Make sure to change back {{ic|/etc/passwd}} to its original state after these modifications.
+
$ export DISTCC_DIR=/tmp/distcc
  
Alternatively, use sudo without changing the shell in /etc/passwd.
+
=== For distccd-alarm ===
 +
==== No such file or directory ====
 +
Errors similar to the following indicate that the user is mistakenly running the distccd service provided by {{pkg|distcc}} and NOT provided by the distccd-alarm packages (ie {{AUR|distccd-alarm-armv5}}, {{AUR|distccd-alarm-armv6h}}, {{AUR|distccd-alarm-armv7h}}, or {{AUR|distccd-alarm-armv8}}.)
  
  # sudo -u nobody gcc --version
+
Be sure to start the correct service for the target architecture.
  
=== Adjust log level ===
+
{{bc|distcc[25479] (dcc_execvp) ERROR: failed to exec armv7l-unknown-linux-gnueabihf-g++: No such file or directory
 +
}}
  
By default, distcc will log to {{ic|/var/log/messages.log}} as it goes along.  One trick (actually recommended in the distccd manpage) is to log to an alternative file directly.  Again, one can locate this in RAM via /tmp. Another trick is to lower to log level of minimum severity of error that will be included in the log file.  Useful if only wanting to see error messages rather than an entry for each connection.  LEVEL can be any of the  standard syslog levels, and in particular critical, error, warning, notice, info, or debug.
+
==== Monitoring does not work ====
 +
Since the distccd-alarm-arm* services use the {{ic|nobody}} user, {{ic|/usr/bin/distccmon-text}} does not work to monitor compilation.  One can inspect the output of the actually distcc log to troubleshoot if needed, {{ic|tail -f /tmp/distccd-armv7h.log}} for example.
  
Either call distcc with the arguments mentioned here on the master or appended it to DISTCC_ARGS in {{ic|/etc/conf.d/distccd}} on the slaves:
+
== See also ==
  
DISTCC_ARGS="--allow 192.168.0.0/24 --log-level error --log-file /tmp/distccd.log"
+
* https://github.com/distcc/distcc
  
=== Limit HDD/SSD usage by relocating $HOME/.distcc ===
+
* {{AUR|icecream}} - An easier to configure fork of distcc that some find brings notably better results and improved utilisation of available cores.
 
 
By default, distcc creates {{ic|$HOME/.distcc}} which stores transient relevant info as it serves up work for nodes to compile. This will avoid needless HDD read/writes and is particularly important for SSDs.
 
 
 
$ export DISTCC_DIR=/tmp/distcc
 

Latest revision as of 18:20, 12 May 2019

distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network to speed up building. It 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. Further, one can use it together with native Arch build tools such as makepkg.

Terms

client
The client is the computer initiating the compilation.
volunteer
The volunteer is the computer accepting compilation requests send by the client. One can setup multiple volunteers or just a single one.

Getting started

Install the distcc package on all participating PCs in the distcc cluster. For other distros, or even operating systems including Windows through using Cygwin, refer to the distcc docs. Be sure to allow traffic on the port on which distcc runs (the default is 3632/tcp), see Category:Firewalls and distcc(1).

Configuration

Volunteers

The configuration for the volunteer is stored in /etc/conf.d/distccd. At a minimum, configure the allowed address ranges in CIDR format:

DISTCC_ARGS="--allow 192.168.10.0/24"

A nice tool for converting address ranges to CIDR format can be found here: CIDR Utility Tool. Other commandline options can be defined as well. Refer to distcc(1).

Start distccd.service on every participating volunteer. To have distccd.service start at boot-up, enable it.

Client

For use with makepkg

Edit /etc/makepkg.conf in the following sections:

  1. The BUILDENV array will need to have distcc unbanged i.e. list it without exclamation point.
  2. Uncomment the DISTCC_HOSTS line and add the host name or IP addresses of the volunteers. Optionally, follow this with a forward slash and the max number of threads they are to use. The subsequent nodes should be separated by a white space. This list should be ordered from most powerful to least powerful (processing power).
  3. Adjust the MAKEFLAGS variable to correspond to the number of sum of the number of individual values specified for the max threads per server. In the example below, this is 5+3+3=11.

Example using relevant lines:

BUILDENV=(distcc fakeroot color !ccache check !sign)
MAKEFLAGS="-j11"
DISTCC_HOSTS="192.168.10.2/5 192.168.10.3/3 192.168.10.4/3"
Warning: The -march=native flag cannot be used in the CFLAGS and CXXFLAGS variables, otherwise distccd will not distribute work to other machines.

For use without makepkg

The minimal configuration for distcc on the client includes the setting of the available volunteers. This can either be done by setting the addresses in the environment variable DISTCC_HOSTS or in either of the configuration files $DISTCC_HOSTS, $DISTCC_DIR/hosts, ~/.distcc/hosts or /etc/distcc/hosts.

Example for setting the volunteer address using DISTCC_HOSTS:

$ export DISTCC_HOSTS="192.168.10.3,lzo,cpp 192.168.10.4,lzo,cpp"
Note: This is a white space separated list.

Example for setting the volunteer addresses in the hosts configuration file:

~/.distcc/hosts
192.168.10.3,lzo,cpp 192.168.10.4,lzo,cpp

Instead of explicitly listing the server addresses one can also use the avahi zeroconf mode. To use this mode +zeroconf must be in place instead of the server addresses and the distcc daemons on the volunteers have to be started using the --zeroconf option. Note that this option does not support the pump mode!

The examples add the following options to the address:

  • lzo: Enables LZO compression for this TCP or SSH host (volunteer).
  • cpp: Enables distcc-pump mode for this host (volunteer). Note: the build command must be wrapped in the pump script in order to start the include server.

A description for the pump mode can be found here: distcc's pump mode: A New Design for Distributed C/C++ Compilation

To use distcc-pump mode for a volunteer, users must start the compilation using the pump script otherwise the compilation will fail.

Compile

With makepkg

Compile via makepkg as normal.

Without makepkg

To compile a source file using the distcc pump mode, use the following command:

$ pump distcc g++ -c hello_world.cpp

In this case the pump script will execute distcc which in turn calls g++ with "-c hello_world.cpp" as parameter.

To compile a Makefile project, first find out which variables are set by the compiler. For example in gzip-1.6, one can find the following line in the Makefile: CC = gcc -std=gnu99. Normally the variables are called CC for C projects and CXX for C++ projects. To compile the project using distcc it would look like this:

$ wget ftp://ftp.gnu.org/pub/gnu/gzip/gzip-1.6.tar.xz
$ tar xf gzip-1.6.tar.xz
$ cd gzip-1.6
$ ./configure
$ pump make -j2 CC="distcc gcc -std=gnu99"

This example would compile gzip using distcc's pump mode with two compile threads. For the correct -j setting have a look at What -j level to use?

Monitoring progress

distcc ships with a cli monitor distccmon-text and a gtk monitor distccmon-gnome one can use to check on compilation status.

The cli monitor can run continuously by appending a space followed by integer to the command which corresponds to the number of sec to wait for a repeat query:

$ distccmon-text 3
29291 Preprocess  probe_64.c                                 192.168.10.2[0]
30954 Compile     apic_noop.c                                192.168.10.2[0]
30932 Preprocess  kfifo.c                                    192.168.10.2[0]
30919 Compile     blk-core.c                                 192.168.10.2[1]
30969 Compile     i915_gem_debug.c                           192.168.10.2[3]
30444 Compile     block_dev.c                                192.168.10.3[1]
30904 Compile     compat.c                                   192.168.10.3[2]
30891 Compile     hugetlb.c                                  192.168.10.3[3]
30458 Compile     catalog.c                                  192.168.10.4[0]
30496 Compile     ulpqueue.c                                 192.168.10.4[2]
30506 Compile     alloc.c                                    192.168.10.4[0]

Cross Compiling with distcc

One can use distcc to help cross compile.

  • A machine running the target architecture should be used as the client.
  • Non-native architecture volunteers will help compile but they require the corresponding toolchain to be installed and their distcc to point to it.

Arch Linux ARM

Volunteers

The developers highly recommend using the official project toolchains which should be installed on the x86_64 volunteer(s). Rather than manually managing these, the AUR provides all four toolchains as well as simple systemd service units:

Setup on the volunteer containing the toolchain is identical to #Volunteers except that the name of the configuration and systemd service file matches that of the respective package. For example, for armv7h the config file is /etc/conf.d/distccd-armv7h and the systemd service unit is distccd-armv7h.service.

Note that each of the toolchains runs on a unique port thus allowing them to co-exist on the volunteer if needed. Be sure to allow traffic to the port on which distcc runs see Category:Firewalls and distcc(1).

Target architecture Distcc Port
armv5 3633
armv6h 3634
armv7h 3635
armv8h/aarch64 3636

Client

Setup of the client is identical to #Client except, one needs to modify the following two files to define the now non-standard port the volunteers are expected to use. Refer to the table above if using the AUR package.

  1. /etc/conf.d/distcc: example on an armv7h machine: DISTCC_ARGS="--allow 127.0.0.1 --allow 192.168.10.0/24 --port 3635
  2. /etc/makepkg.conf: example on an armv7h machine: DISTCC_HOSTS="192.168.10.2/5:3635 192.168.10.3/5:3635"

Alternatively, the distccd-arch-armAUR package will provide the needed systemd service files to enable distccd compilation.

Additional toolchains

  • EmbToolkit: Tool for creating cross compilation tool chain; supports ARM and MIPS architectures; supports building of an LLVM based tool chain
  • crosstool-ng: Similar to EmbToolkit; supports more architectures (see website for more information)
  • Linaro: Provides tool chains for ARM development

The EmbToolkit provides a nice graphical configuration menu (make xconfig) for configuring the tool chain.

Troubleshooting

Journalctl

Use journalctl to find out what was going wrong:

$ journalctl $(which distccd) -e --since "5 min ago"

Adjust log level

By default, distcc will log to /var/log/messages.log as it goes along. One trick (actually recommended in the distccd manpage) is to log to an alternative file directly. Again, one can locate this in RAM via /tmp. Another trick is to lower to log level of minimum severity of error that will be included in the log file. Useful if only wanting to see error messages rather than an entry for each connection. LEVEL can be any of the standard syslog levels, and in particular critical, error, warning, notice, info, or debug.

Either call distcc with the arguments mentioned here on the client or appended it to DISTCC_ARGS in /etc/conf.d/distccd on the volunteers:

DISTCC_ARGS="--allow 192.168.10.0/24 --log-level error --log-file /tmp/distccd.log"

Limit HDD/SSD usage by relocating $HOME/.distcc

By default, distcc creates $HOME/.distcc which stores transient relevant info as it serves up work for nodes to compile. This will avoid needless HDD read/writes and is particularly important for SSDs.

$ export DISTCC_DIR=/tmp/distcc

For distccd-alarm

No such file or directory

Errors similar to the following indicate that the user is mistakenly running the distccd service provided by distcc and NOT provided by the distccd-alarm packages (ie distccd-alarm-armv5AUR, distccd-alarm-armv6hAUR, distccd-alarm-armv7hAUR, or distccd-alarm-armv8AUR.)

Be sure to start the correct service for the target architecture.

distcc[25479] (dcc_execvp) ERROR: failed to exec armv7l-unknown-linux-gnueabihf-g++: No such file or directory

Monitoring does not work

Since the distccd-alarm-arm* services use the nobody user, /usr/bin/distccmon-text does not work to monitor compilation. One can inspect the output of the actually distcc log to troubleshoot if needed, tail -f /tmp/distccd-armv7h.log for example.

See also

  • icecreamAUR - An easier to configure fork of distcc that some find brings notably better results and improved utilisation of available cores.