Difference between revisions of "Distcc (简体中文)"

From ArchWiki
Jump to: navigation, search
(update interlanguage links)
(Tag: wiki-scripts)
(Update translation.)
 
Line 5: Line 5:
 
[[ja:Distcc]]
 
[[ja:Distcc]]
 
[[ru:Distcc]]
 
[[ru:Distcc]]
 +
{{Related articles start (简体中文)}}
 +
{{Related|TORQUE}}
 +
{{Related|Slurm}}
 +
{{Related articles end}}
 +
{{翻译状态|Distcc|2018-07-13|520230}}
 
Distcc 是一个将 C、C++、Objective C 或 Objective C++ 等程序的编译任务分发到网络中多个主机的程序。distcc 的结果和本地编译一模一样,安装后使用方便,通常比本地编译快很多。
 
Distcc 是一个将 C、C++、Objective C 或 Objective C++ 等程序的编译任务分发到网络中多个主机的程序。distcc 的结果和本地编译一模一样,安装后使用方便,通常比本地编译快很多。
  
 
==名词定义==
 
==名词定义==
; distcc daemon: 运行着distcc的计算机与服务器分布式的编译代码. daemon编译一部分代源代码并发送另一部分源代码给''DISTCC_HOSTS''中定义的主机。
 
  
; distcc server:计算机与服务器编译从daemon中获取的代码,编译完成后,把编译后的目标代码发送回daemon,然后再接收下一部分代码(如果编译还没完成的话)。
+
; 主机: 启动编译的机器.
 +
; 从机: 接受 master 的编译请求,一个系统可以包含一个或多个从机。
  
 
==开始==
 
==开始==
将所有用到的计算机都装上[community] 中的 distcc
+
将所有用到的计算机都[[Install|安装]]软件包 {{pkg|distcc}}。如果是其他的发行版甚至使用 Cygwin 的 Windows 操作系统,请阅读 [http://distcc.samba.org/doc.html distcc 文档]。
 
 
# pacman -S distcc
 
 
 
如果是其他的发行版甚至使用 Cygwin 的 Windows 操作系统,请阅读 [http://distcc.samba.org/doc.html distcc 文档]。
 
  
 
==配置==
 
==配置==
=== Daemon 和 Server 配置===
+
=== 从机配置 ===
 
编辑 {{ic|/etc/conf.d/distccd}},修改唯一没有被注释掉的那一行,设置正确的 IP 地址或整个子网。
 
编辑 {{ic|/etc/conf.d/distccd}},修改唯一没有被注释掉的那一行,设置正确的 IP 地址或整个子网。
 
  DISTCC_ARGS="--user nobody --allow 192.168.0.0/24"
 
  DISTCC_ARGS="--user nobody --allow 192.168.0.0/24"
  
===Daemon 配置===
+
DISTCC_ARGS="--allow 192.168.0.0/24"
在daemon上, 编辑{{ic|/etc/makepkg.conf}}
+
 
#确保 BUILDENV 中的distcc没有被禁用(前面没有感叹号)
+
[http://www.ipaddressguide.com/cidr CIDR Utility Tool]可以帮助进行地址转换,其它设置请参考 {{man|1|distcc}}.
 +
 
 +
在所有从机上[[Start|启动]] 服务 {{ic|distccd.service}}。要开机启动,请[[enable|启用]] 此服务。
 +
 
 +
===主机配置===
 +
==== makepkg 编译 ====
 +
编辑{{ic|/etc/makepkg.conf}}
 +
#确保 BUILDENV 中的 distcc 没有被禁用(前面没有感叹号)
 
#编辑''DISTCC_HOSTS'' ,加入可以使用的编译服务器的 IP 地址 + 反斜杠 + 线程数,不同 IP 地址用空格隔开,按照处理器性能排列
 
#编辑''DISTCC_HOSTS'' ,加入可以使用的编译服务器的 IP 地址 + 反斜杠 + 线程数,不同 IP 地址用空格隔开,按照处理器性能排列
 
#修改 MAKEFLAGS 中的 N 为所有使用线程的和。在下面的示例为 5+3+3=11. 如果超过这个值,超出的线程将会被 distcc阻塞。
 
#修改 MAKEFLAGS 中的 N 为所有使用线程的和。在下面的示例为 5+3+3=11. 如果超过这个值,超出的线程将会被 distcc阻塞。
Line 33: Line 41:
  
 
相关行的示例:
 
相关行的示例:
  BUILDENV=(distcc fakeroot color !ccache !check)
+
 
 +
  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.0.2/5 192.168.0.3/3 192.168.0.4/3"
  
如果通过 SSH 使用 distcc,在 IP 地址前加 "@" 符号。如果未设置基于密钥的认证,将设置 DISTCC_SSH="ssh -i" 以忽略认证。
+
{{注意| {{ic|CFLAGS}} 和 {{ic|CXXFLAGS}} 中不能使用 {{ic|1=-march=native}} 选项,否则 distccd 不会将编译任务发给其它机器。}}
 +
 
 +
==== 非 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}}.
 +
 
 +
Example for setting the slave address using {{ic|DISTCC_HOSTS}}:
 +
 
 +
$ export DISTCC_HOSTS="192.168.0.3,lzo,cpp 192.168.0.4,lzo,cpp"
 +
 
 +
{{Note|This is a white space separated list.}}
 +
 
 +
Example for setting the slave addresses in the hosts configuration file:
 +
 
 +
{{hc|~/.distcc/hosts|
 +
192.168.0.3,lzo,cpp 192.168.0.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!
 +
 
 +
The examples add the following options to the address:
 +
 
 +
* {{ic|lzo}}: Enables LZO compression for this TCP or SSH host (slave).
 +
* {{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.
 +
 
 +
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 ]
  
==添加Daemon==
+
To use distcc-pump mode for a slave, users must start the compilation using the pump script otherwise the compilation will fail.
要使得Server能找到所有的集群Daemon,还需要把所有Daemon的IP地址加入到/etc/distcc/hosts里面:
 
127.0.0.1
 
192.168.1.2
 
192.168.1.3
 
#...
 
  
 
==编译==
 
==编译==
  
在每台参与编译的机器上开启 distcc daemon
+
=== makepkg 编译 ===
  # systemctl start distccd
+
 
 +
然后正常运行 makepkg 即可。
 +
 
 +
=== 非 makepkg 编译 ===
 +
 
 +
To compile a source file using the distcc pump mode, use the following command:
 +
 
 +
  $ pump distcc g++ -c hello_world.cpp
  
要启动自动运行 distcc:
+
In this case the pump script will execute distcc which in turn calls g++ with "-c hello_world.cpp" as parameter.
# systemctl enable distccd
 
  
然后正常运行 makepkg 即可。
+
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: {{ic|1=CC = gcc -std=gnu99}}. Normally the variables are called {{ic|CC}} for C projects and {{ic|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 {{ic|-j}} setting have a look at [https://cdn.rawgit.com/distcc/distcc/master/doc/web/faq.html What -j level to use?]
  
 
==监视进度==
 
==监视进度==
有多种方式可以监视进度。
+
{{Pkg|distcc}} ships with a cli monitor {{ic|distccmon-text}} and a gtk monitor {{ic|distccmon-gnome}} one can use to check on compilation status.
#distccmon-text
+
 
#tailing log file
+
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 检查编译状况:
+
{{bc|$ distccmon-text 3
<pre>$ distccmon-text
 
 
29291 Preprocess  probe_64.c                                192.168.0.2[0]
 
29291 Preprocess  probe_64.c                                192.168.0.2[0]
 
30954 Compile    apic_noop.c                                192.168.0.2[0]
 
30954 Compile    apic_noop.c                                192.168.0.2[0]
Line 74: Line 116:
 
30496 Compile    ulpqueue.c                                192.168.0.4[2]
 
30496 Compile    ulpqueue.c                                192.168.0.4[2]
 
30506 Compile    alloc.c                                    192.168.0.4[0]
 
30506 Compile    alloc.c                                    192.168.0.4[0]
</pre>
+
}}
  
通过 watch 加程序名可以循环执行程序,程序名后面加数字也可以实现重复查询:
+
== "Cross Compiling" with distcc ==
$ watch distccmon-text
 
or
 
$ distccmon-text 2
 
  
在 daemon 上 tail {{ic|/var/log/messages.log}} 也行:
+
=== 32-bit x86 (i686) ===
  # tail -f /var/log/messages.log
+
{{out of date|The [[Install bundled 32-bit system in 64-bit system]] article has been archived}}
 +
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 environment. Neither is ideal, but to date, there are the only two methods documented on the wiki.
  
==为每个编译任务使用distcc==
+
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.
如果你在pacman之外使用distcc,那么你需要做的就是把你加进''/etc/makepkg.conf'' 文件中的"export ..."加到"/etc/profile"里:''/etc/makepkg.conf'' 里的"export"只在"makepkg"或"makeworld"执行的时间读取,而''/etc/profile'' 会在登录的时候执行。
+
 
 +
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 ====
 +
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:
 +
* {{AUR|distccd-alarm-armv5}}
 +
* {{AUR|distccd-alarm-armv6h}}
 +
* {{AUR|distccd-alarm-armv7h}}
 +
* {{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}}.
 +
 
 +
A systemd service unit is provided for each respective package.  For example, {{ic|distccd-armv7h.service}}.
 +
 
 +
==== 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
 +
* [http://crosstool-ng.org/ crosstool-ng]: Similar to EmbToolkit; supports more architectures (see website for more information)
 +
* [https://www.linaro.org/downloads/ Linaro]: Provides tool chains for ARM development
 +
 
 +
The {{ic|EmbToolkit}} provides a nice graphical configuration menu ({{ic|make xconfig}}) for configuring the tool chain.
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Journalctl ===
 +
 
 +
Use {{ic|journalctl}} to find out what was going wrong:
 +
 
 +
$ journalctl $(which distccd) -e --since "5 min ago"
 +
 
 +
=== code 110 ===
 +
 
 +
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:
 +
 
 +
{{hc|$ cat /etc/passwd|
 +
...
 +
nobody:x:99:99:nobody:/:/bin/bash
 +
...
 +
}}
 +
 
 +
Then cd into the directory containing the cross compiler binaries and try to execute the compiler:
 +
 
 +
# su nobody
 +
$ ./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.
 +
 
 +
Make sure to change back {{ic|/etc/passwd}} to its original state after these modifications.
 +
 
 +
Alternatively, use sudo without changing the shell in /etc/passwd.
 +
 
 +
  # sudo -u nobody gcc --version
 +
 
 +
=== 修改 $HOME/.distcc 位置以限制硬盘使用===
  
==技巧==
 
===限制硬盘使用===
 
====修改 $HOME/.distcc 位置====
 
 
distcc 默认会在 {{ic|$HOME/.distcc}} 保存中间结果。在内存 /tmp 中创建 ''.distcc'' 并链接到 $HOME 可以避免磁盘读写。
 
distcc 默认会在 {{ic|$HOME/.distcc}} 保存中间结果。在内存 /tmp 中创建 ''.distcc'' 并链接到 $HOME 可以避免磁盘读写。
$ mv $HOME/.distcc /tmp
 
$ ln -s /tmp/.distcc $HOME/.distcc
 
  
只需要在重启时让 Systemd 重新创建目录即可,创建文件:
+
$ export DISTCC_DIR=/tmp/distcc
{{hc| /etc/tmpfiles.d/tmpfs-create.conf |<nowiki>
 
d /tmp/.distcc 0666 nobody nobody -
 
</nowiki>}}
 
  
====修改日志级别====
+
=== 修改日志级别 ===
  
 
默认日志放在 {{ic|/var/log/messages.log}},也可以放到一个单独的文件,例如通过 /tmp 放到 RAM 中。同时降低日志级别也可以只显示错误信息。LEVEL 可以是任意 syslog 级别,例如 critical, error, warning, notice, info, 或 debug.
 
默认日志放在 {{ic|/var/log/messages.log}},也可以放到一个单独的文件,例如通过 /tmp 放到 RAM 中。同时降低日志级别也可以只显示错误信息。LEVEL 可以是任意 syslog 级别,例如 critical, error, warning, notice, info, 或 debug.
Line 106: Line 216:
  
 
  DISTCC_ARGS="--user nobody --allow 192.168.0.0/24 --log-level error --log-file /tmp/distccd.log"
 
  DISTCC_ARGS="--user nobody --allow 192.168.0.0/24 --log-level error --log-file /tmp/distccd.log"
 
==在使用CMake等工具时出现无法编译的错误==
 
因为CMake使用了gcc的[http://gcc.gnu.org/wiki/Response_Files Response File]特性,但distcc当前版本(3.2)还无法支持这个特性。
 
如果出现这个错误,可以选择打这个[http://code.google.com/p/distcc/issues/detail?id=85&q=response 补丁], 或者使用aur上的{{AUR|distcc-rsp}}{{Broken package link|{{aur-mirror|distcc-rsp}}}}版本。
 

Latest revision as of 05:53, 13 July 2018

翻译状态: 本文是英文页面 Distcc翻译,最后翻译时间:2018-07-13,点击这里可以查看翻译后英文页面的改动。

Distcc 是一个将 C、C++、Objective C 或 Objective C++ 等程序的编译任务分发到网络中多个主机的程序。distcc 的结果和本地编译一模一样,安装后使用方便,通常比本地编译快很多。

名词定义

主机
启动编译的机器.
从机
接受 master 的编译请求,一个系统可以包含一个或多个从机。

开始

将所有用到的计算机都安装软件包 distcc。如果是其他的发行版甚至使用 Cygwin 的 Windows 操作系统,请阅读 distcc 文档

配置

从机配置

编辑 /etc/conf.d/distccd,修改唯一没有被注释掉的那一行,设置正确的 IP 地址或整个子网。

DISTCC_ARGS="--user nobody --allow 192.168.0.0/24"
DISTCC_ARGS="--allow 192.168.0.0/24"

CIDR Utility Tool可以帮助进行地址转换,其它设置请参考 distcc(1).

在所有从机上启动 服务 distccd.service。要开机启动,请启用 此服务。

主机配置

makepkg 编译

编辑/etc/makepkg.conf

  1. 确保 BUILDENV 中的 distcc 没有被禁用(前面没有感叹号)
  2. 编辑DISTCC_HOSTS ,加入可以使用的编译服务器的 IP 地址 + 反斜杠 + 线程数,不同 IP 地址用空格隔开,按照处理器性能排列
  3. 修改 MAKEFLAGS 中的 N 为所有使用线程的和。在下面的示例为 5+3+3=11. 如果超过这个值,超出的线程将会被 distcc阻塞。
Note: 在单机编译时一般定义为 CPU 数加一,仅在单机编译时才是对的,这里不应该使用这个方法。

相关行的示例:

BUILDENV=(distcc fakeroot color !ccache check !sign)
MAKEFLAGS="-j11"
DISTCC_HOSTS="192.168.0.2/5 192.168.0.3/3 192.168.0.4/3"
注意: CFLAGSCXXFLAGS 中不能使用 -march=native 选项,否则 distccd 不会将编译任务发给其它机器。

非 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 DISTCC_HOSTS or in either of the configuration files $DISTCC_HOSTS, $DISTCC_DIR/hosts, ~/.distcc/hosts or /etc/distcc/hosts.

Example for setting the slave address using DISTCC_HOSTS:

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

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

~/.distcc/hosts
192.168.0.3,lzo,cpp 192.168.0.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 slaves 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 (slave).
  • 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.

A description for the pump mode can be found here: HOW DISTCC-PUMP MODE WORKS and 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.

编译

makepkg 编译

然后正常运行 makepkg 即可。

非 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?

监视进度

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.0.2[0]
30954 Compile     apic_noop.c                                192.168.0.2[0]
30932 Preprocess  kfifo.c                                    192.168.0.2[0]
30919 Compile     blk-core.c                                 192.168.0.2[1]
30969 Compile     i915_gem_debug.c                           192.168.0.2[3]
30444 Compile     block_dev.c                                192.168.0.3[1]
30904 Compile     compat.c                                   192.168.0.3[2]
30891 Compile     hugetlb.c                                  192.168.0.3[3]
30458 Compile     catalog.c                                  192.168.0.4[0]
30496 Compile     ulpqueue.c                                 192.168.0.4[2]
30506 Compile     alloc.c                                    192.168.0.4[0]

"Cross Compiling" with distcc

32-bit x86 (i686)

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: The Install bundled 32-bit system in 64-bit system article has been archived (Discuss in Talk:Distcc (简体中文)#)

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 environment. Neither 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 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 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 schroot(1) 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 /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 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

When building on an Arch Linux ARM device, the developers highly recommend using the official project 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:

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, /etc/conf.d/distccd-armv7h.

A systemd service unit is provided for each respective package. For example, distccd-armv7h.service.

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"

code 110

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 /etc/passwd change the login for the nobody user to the following:

$ cat /etc/passwd
...
nobody:x:99:99:nobody:/:/bin/bash
...

Then cd into the directory containing the cross compiler binaries and try to execute the compiler:

# su nobody
$ ./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.

Make sure to change back /etc/passwd to its original state after these modifications.

Alternatively, use sudo without changing the shell in /etc/passwd.

 # sudo -u nobody gcc --version

修改 $HOME/.distcc 位置以限制硬盘使用

distcc 默认会在 $HOME/.distcc 保存中间结果。在内存 /tmp 中创建 .distcc 并链接到 $HOME 可以避免磁盘读写。

$ export DISTCC_DIR=/tmp/distcc

修改日志级别

默认日志放在 /var/log/messages.log,也可以放到一个单独的文件,例如通过 /tmp 放到 RAM 中。同时降低日志级别也可以只显示错误信息。LEVEL 可以是任意 syslog 级别,例如 critical, error, warning, notice, info, 或 debug.

把它们附加/etc/conf.d/distccd 的 DISTCC_ARGS 中。

DISTCC_ARGS="--user nobody --allow 192.168.0.0/24 --log-level error --log-file /tmp/distccd.log"