Distcc/ko

distcc 는 네트워크를 통해 호스트가 참여하여 분산 컴파일 작업을 수행하도록 설계한 프로그램입니다. 서버와 클라이언트로 구성되어 있습니다. distcc는 ccache, 포티지en, 약간의 설정 과정을 거치는 automake로 감쪽같이 처리할 수 있습니다.

젠투 설치 초기에 도움을 받으려 를 사용한다면, 부트스트랩 과정에 distcc 사용 섹션을 읽어보십시오.

설치
를 설정하기 전, 우선 모든 호스트에 대한 꾸러미 설치 과정을 살펴보겠습니다.

모든 호스트에 대한 의존성
를 사용하려면 네트워크상의 모든 컴퓨터에 같은 gcc 버전이 있어야 합니다. 예를 들어 3.3.x(x는 바뀔 수 있음)는 괜찮지만 3.3.x와 3.2.x를 같이 사용하면, 컴파일 오류 또는 실행시간 오류가 나타날지도 모릅니다.

프로그램 설치
distcc에는 컴파일 작업을 보내는 컴퓨터의 작업을 지켜볼 때 사용하는 그래픽 감시 프로그램이 있습니다. 이 감시 프로그램은  USE 플래그를 설정했을 때 쓸 수 있습니다.

After configuring the USE setting, install the package:

Auto-starting the distcc daemon
In order to have started automatically, follow the next set of instructions, depending on the init system used.

Using 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:

Using systemd
Edit and add the allowed clients in CIDR format. Here is an example:

Reload the unit files after making such changes:

Enable auto-starting and then start the service:

Configuration
Let's now look into the configuration of.

참여 호스트 지정
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  for more details.

만약 로컬 머신에서도 컴파일해야한다면 호스트 목록에 를 추가해야 합니다. 반대로 로컬 머신을 컴파일할 때 활용하지 않으면 호스트 목록에서 생략해야 합니다. 느린 장치에서 로컬호스트를 사용하는 것은 실제로 컴파일을 느리게 만듭니다. 성능을 위해 설정을 시험하여 확인하십시오.

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

Using distcc with 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).

Set the MAKEOPTS variable and FEATURES variable as shown below.

A common strategy is to
 * set the value of  to twice the number of total (local + remote) CPU cores + 1, and
 * set the value of  to the number of local CPU cores

The use of  in the MAKEOPTS 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 MAKEOPTS variable could look like this:

While editing the file, make sure that it does not have   in the CFLAGS or CXXFLAGS 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.

Using distcc with automake
This is, in some cases, easier than the Portage setup. All that is needed is to update the PATH 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:

Put this in the user's or equivalent file to have the PATH set every time the user logs in, or set it globally through an  file.

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.

부트스트랩 과정에 distcc 사용
Using to bootstrap (i.e. build a working toolchain before installing the remainder of the system) requires some additional steps to take.

1단계: 포티지 설정
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 :

마찬가지로 설치 세션에서  변수를 업데이트하십시오:

2단계: distcc 가져오기
를 설치하십시오:

3단계: 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.

추가 distcc 요소
The application has additional features and applications to support working in a  environment.

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:

A trick is to set DISTCC_DIR in environment variables:

Now update the environment:

Finally, start the GUI application:

Using SSH for distcc communication
Setting up distcc via SSH includes some pitfalls. First, generate an SSH key pair without password setup. Be aware that portage compiles programs as the Portage user (or as root if  is not set). The home folder of the Portage user is, which means the keys need to be stored in

두번째로, SSH 설정 파일에 각 호스트에 대한 섹션을 만드십시오:

Send the public key to each compilation node:

Also make sure that each host is available in the file:

Fix the file permissions as follows:

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.

문제 해결
If a problem occurs while using, then this section might help in resolving the problem.

ERROR: failed to open
As of January 22nd, 2015 emerging fails to create the proper file in. This apparently only effects version 3.1-r8 of distcc. This bug is in the process of being corrected (see ). It is possible to work around this by manually creating the log file, giving it proper ownership, and restarting the distccd daemon:

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

Finally, restart the distccd service:

Some packages do not use distcc
다양한 꾸러미를 emerge 할 때, 꾸러미 일부를 분산처리하지 않는다는 점(그리고 병렬로 빌드하지 않는다는 점)을 주의하셔야 합니다. 이것은 패키지의 이 병렬 처리를 지원하지 않거나 ebuild의 관리자가 알려진 문제점때문에 확실하게 병렬 처리를 사용하지 않도록 했기 때문입니다.

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

혼합 GCC 버전
각각의 환경에서 다른 GCC 버전을 사용하면, 이상한 문제가 생길 수 있습니다. 해결 방법은 모든 호스트의 GCC 버전을 같게 하는 것입니다.

Recent Portage updates have made Portage use  (minus gcc) instead of. This means that if i686 machines are mixed with other types (i386, i586) then the builds will run into troubles. A workaround for this may be to run:

It is also possible to set the CC and CXX variables in to the values list in the command above.

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

다음 경고에 주의하십시오:

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

외부 자료

 * Inlining  for distcc
 * Distcc homepage