Distcc 是一个被设计用来将编译任务发布到网络上特定主机的程序。 它由一个服务器 distccd和一个客户端 distcc>程序组成.
说白了就是能利用空闲的的电脑,服务器加快编译速度。
distcc项目地址
distcc文档地址
想要运行distcc需要服务端与客户端上一些包的版本相同,不然会出现奇奇怪怪的问题。
暂时已知需相同版本的包
从https://github.com/distcc/distcc/releases获取源码。解压后
./configure && make && sudo make install
windows上可以用cygwin来运行distcc,不过在我实际编译的时候编译报错。网上有大佬说是有些库win和linux不太一样。
~ $ distccd --help
distccd 3.3.3 x86_64-pc-linux-gnu
(protocols 1, 2 and 3) (default port 3632)
built Jul 17 2020 06:13:00
Copyright (C) 2002, 2003, 2004 by Martin Pool.
Includes miniLZO (C) 1996-2002 by Markus Franz Xaver Johannes Oberhumer.
Portions Copyright (C) 2007-2008 Google.
Usage:
distccd [OPTIONS]
Options:
--help explain usage and exit
--version show version and exit
--show-principal show current GSS-API principal and exit
-P, --pid-file FILE save daemon process id to file
-N, --nice LEVEL lower priority, 20=most nice
--user USER if run by root, change to this persona
--jobs, -j LIMIT maximum tasks at any time
--job-lifetime SECONDS maximum lifetime of a compile request
Networking:
-p, --port PORT TCP port to listen on
--listen ADDRESS IP address to listen on
-a, --allow IP[/BITS] client address access control
--auth enable GSS-API based mutual authenticaton
--blacklist=FILE control client access through a blacklist
--whitelist=FILE control client access through a whitelist
--stats enable statistics reporting via HTTP server
--stats-port PORT TCP port to listen on for statistics requests
Debug and trace:
--log-level=LEVEL set detail level for log file
levels: critical, error, warning, notice, info, debug
--verbose set log level to "debug"
--no-detach don't detach from parent (for daemontools, etc)
--log-file=FILE send messages here instead of syslog
--log-stderr send messages to stderr
--wizard for running under gdb
Mode of operation:
--inetd serve client connected to stdin
--daemon bind and listen on socket
distccd runs either from inetd or as a standalone daemon to compile
files submitted by the distcc client.
distccd should only run on trusted networks.
一般来说只要
distccd --daemon --allow 192.168.1.0/24 --log-file=/var/log/distccd.log
其中–allow后的ip可以换成客户端的ip。
首先先看一下帮助
distcc 3.3.3 x86_64-pc-linux-gnu
Usage:
distcc [--scan-includes] [COMPILER] [compile options] -o OBJECT -c SOURCE
distcc [--help|--version|--show-hosts|-j]
Options:
COMPILER Defaults to "cc".
--help Explain usage, and exit.
--version Show version, and exit.
--show-hosts Show host list, and exit.
-j Show the concurrency level, as calculated from
the host list, and exit.
--scan-includes Show the files that distcc would send to the
remote machine, and exit. (Pump mode only.)
--show-principal Show current distccd GSS-API principal and exit.
如果需要添加服务端的话,编辑/etc/distcc/hosts
文件。
将服务端ip加入这个文件中。值得一提的是如果不加入127.0.0.1的话,distcc将不使用本地编译。
在/etc/portage/make.conf
中加入
MAKEOPTS="-j15 -l6 "
FEATURES="distcc"
参数-jN(N为数字)N表示使用本地cpu核心+远程cpu核心的和。-lM(M为数字)M表示本地cpu核心数量