📄 distcc.1
字号:
.TH distcc 1 "28 July 2004".SH "NAME"distcc \- distributed C/C++/ObjC compiler.SH "SYNOPSIS".B distcc .I <compiler> [COMPILER OPTIONS] .PP.B distcc.I [COMPILER OPTIONS].PP.B <compiler>.I [COMPILER OPTIONS].SH "DESCRIPTION".P distcc distributes compilation of C code across several machines on anetwork. distcc should always generate the same results as a localcompile, is simple to install and use, and is often much faster than alocal compile..PPdistcc sends the complete preprocessed source code and compilerarguments across the network for each job, so the machines do not needto share a filesystem, have the same headers or libraries installed,or have synchronized clocks..PPCompilation is driven by a "client" machine, which is typically thedeveloper's workstation or laptop. The distcc client runs on thismachine, as does make, the preprocessor, the linker, and other stagesof the build process. Any number of "volunteer" machines help theclient to build the program, by running the .B distccd(1) daemon, C compiler and assembleras required..PPdistcc can run across either TCP sockets (on port 3632 by default), orthrough a tunnel command such as ssh(1). For TCP connections thevolunteers must run the distccd(1) daemon either directly or from inetd.For SSH connections distccd must be installed but should.B notbe listening for connections. .PPTCP connections should only be used on secure networks because thereis no user authentication or protection of source or object code. SSHconnections are typically 25% slower because of processor overhead forencryption, although this can vary greatly depending on CPUs, networkand the program being built..PPdistcc is intended to be used with GNU Make's.B -j option, which runs several compiler processes concurrently. distccspreads the jobs across both local and remote CPUs. Because distcc isable to distribute most of the work across the network a higherconcurrency level can be used than for local builds. The.B -j value should normally be set to about twice the total number ofavailable CPUs, to allow for some tasks being blocked waiting for diskor network IO. distcc can also work with other build control toolssuch as SCons..PPIt is strongly recommended that you install the same compiler versionon all machines participating in a build. Incompatible compilers maycause mysterious compile or link failures..SH "QUICKSTART".TP1For each machine, download distcc, unpack, and install..TP2On each of the servers, run .B distccd --daemonoptionally with .B --allowoptions to restrict access..TP 3Put the names of the servers in your environment:.RS$ export DISTCC_HOSTS='localhost red green blue'.RE.TP4Build!.RS$ make -j8 CC=distcc.RE.SH "HOW IT WORKS"distcc only ever runs the compiler and assembler remotely.The preprocessor must always run locally because it needs toaccess various header files on the local machine which maynot be present, or may not be the same, on the volunteer.The linker similarly needs to examine libraries and objectfiles, and so must run locally..PPThe compiler and assembler take only a single input file (thepreprocessed source) and produce a single output (the object file).distcc ships these two files across the network and can therefore runthe compiler/assembler remotely..PPFortunately, for most programs running the preprocessor isrelatively cheap, and the linker is called relativelyinfrequent, so most of the work can be distributed..PPdistcc examines its command line to determine which of thesephases are being invoked, and whether the job can bedistributed..SH "OPTION SUMMARY"Most options passed to distcc are interpreted as compiler options.Two options are understood by distcc itself:.TP .B --helpDisplays summary instructions..TP.B --versionDisplays the distcc client version..SH "INSTALLING DISTCC"There are three different ways to call distcc, to suit differentcircumstances:.RS.PPdistcc can be installed under the name of the real compiler, tointercept calls to it and run them remotely. This "masqueraded"compiler has the widest compatibility with existing source trees, andis convenient when you want to use distcc for all compilation. Thefact that distcc is being used is transparent to the makefiles..PPdistcc can be prepended to compiler command lines, such as "distcc cc-c hello.c" or CC="distcc gcc". This is convenient when you want touse distcc for only some compilations or to try it out, but can causetrouble with some makefiles or versions of libtool that assume $CCdoes not contain a space..PPFinally, distcc can be used directly as a compiler. "cc" is alwaysused as the name of the real compiler in this "implicit" mode. Thiscan be convenient for interactive use when "explicit" mode does notwork but is not really recommended for new use..RE.PPRemember that you should not use two methods for calling distcc at thesame time. If you are using a masquerade directory, don't change CC and/orCXX, just put the dirirectory early on your PATH. If you're not usinga masquerade directory, you'll need to either change CC and/or CXX, ormodify the makefile(s) to call distcc explicitly..SH "MASQUERADING"The basic idea is to create a "masquerade directory" which containslinks from the name of the real compiler to the distcc binary. Thisdirectory is inserted early on the PATH, so that calls to the compilerare intercepted and distcc is run instead. distcc then removes itselffrom the PATH to find the real compiler..PPFor example:.PP.RS.nf# mkdir /usr/lib/distcc/bin# cd /usr/lib/distcc/bin# ln -s ../../../bin/distcc gcc# ln -s ../../../bin/distcc cc# ln -s ../../../bin/distcc g++# ln -s ../../../bin/distcc c++.fi.RE.PPThen, to use distcc, a user just needs to put the directory/usr/lib/distcc/bin early in the PATH, and have set a host list inDISTCC_HOSTS or a file. distcc will handle the rest. .PPNote that this masquerade directory must occur on the PATH earlierthan the directory that contains the actual compilers of the samenames, and that any auxiliary programs that these compilers call (suchas as or ld) must also be found on the PATH in a directory after themasquerade directory since distcc calls out to the real compiler witha PATH value that has all directory up to and including the masqueradedirectory trimmed off..PPIt is possible to get a "recursion error" in masquerade mode, whichmeans that distcc is somehow finding itself again, not the realcompiler. This can indicate that you have two masquerade directorieson the PATH, possibly because of having two distcc installations indifferent locations. It can also indicate that you're trying to mix"masqueraded" and "explicit" operation..SH "USING DISTCC WITH CCACHE"ccache is a program that speeds software builds by caching the resultsof compilations. ccache is normally called before distcc, so thatresults are retrieved from a normal cache. Some experimentation maybe required for idiosyncratic makefiles to make everything work together..PPThe most reliable method is to set.IP.B CCACHE_PREFIX="distcc".PPThis tells ccache to run distcc as a wrapper around the realcompiler. ccache still uses the real compiler to detect compilerupgrades..PPccache can then be run using either a masquerade directory .I or bysetting.IP.B CC="ccache gcc".PPAs of version 2.2, ccache does not cache compilation from preprocessedsource and so will never get a cache hit if it is run from distccd ordistcc. It must be run only on the client side and before distcc tobe any use..SH "HOST SPECIFICATIONS"A "host list" tells distcc which machines to use for compilation. Inorder, distcc looks in the .B $DISTCC_HOSTSenvironment variable, the user's .B $DISTCC_DIR/hostsfile, and the system-wide host file. If no host list can be found, distcc emits a warning andcompiles locally..PPThe host list is a simple whitespace separated list of hostspecifications. The simplest and most common form is a host names,such as.PP.RS.B localhost red green blue.RE.PPdistcc prefers hosts towards the start of the list, so machines shouldbe listed in descending order of speed. In particular, when only asingle compilation can be run (such as from a configure script), thefirst machine listed is used. .PPPlacing .I localhostat the right point in the list is important to getting goodperformance. Because overhead for running jobs locally is low,localhost should normally be first. However, it is important that theclient have enough cycles free to run the local jobs and the distccclient. If the client is slower than the volunteers, or if there aremany volunteers, then the client should be put later in the list ornot at all. As a general rule, if the aggregate CPU speed of theclient is less than one fifth of the total, then the client should beleft out of the list..PPPerformance depends on the details of the source and makefiles usedfor the project, and the machine and network speeds. Experimentingwith different settings for the host list and -j factor may improveperformance..PPThe syntax is.PP.nf DISTCC_HOSTS = HOSTSPEC ... HOSTSPEC = LOCAL_HOST | SSH_HOST | TCP_HOST | OLDSTYLE_TCP_HOST LOCAL_HOST = localhost[/LIMIT] SSH_HOST = [USER]@HOSTID[/LIMIT][:COMMAND][OPTIONS] TCP_HOST = HOSTID[:PORT][/LIMIT][OPTIONS] OLDSTYLE_TCP_HOST = HOSTID[/LIMIT][:PORT][OPTIONS] HOSTID = HOSTNAME | IPV4 OPTIONS = ,OPTION[OPTIONS] OPTION = lzo.fi.PPHere are some individual examples of the syntax:.TP.B localhostThe literal word "localhost" is interpreted specially to causecompilations to be directly executed, rather than passed to a daemonon the local machine. If you do want to connect to a daemon on thelocal machine for testing, then give the machine's IP address or realhostname. (This will be slower.).TP.B IPV4A literal IPv4 address, such as .B 10.0.0.1.TP.B HOSTNAMEA hostname to be looked up using the resolver..TP.B :PORTConnect to a specified decimal port number, rather than the default of3632..TP.B @HOSTIDConnect to the host over SSH, rather than TCP. Options for the SSHconnection can be set in .B ~/.ssh/config.TP.B USER@Connect to the host over SSH as a specified username..TP.B :COMMAND Connect over SSH, and use a specified path to find the distccd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -