gentoo下利用distcc分布式编译


顶不住了,用了gentoo,感觉编译好慢啊,顶不住了。chromium编译了差不多6个小时。必须找了点办法加速一下。

distcc

distcc介绍

Distcc 是一个被设计用来将编译任务发布到网络上特定主机的程序。 它由一个服务器 distccd和一个客户端 distcc>程序组成.

说白了就是能利用空闲的的电脑,服务器加快编译速度。
distcc项目地址
distcc文档地址

注意事项

想要运行distcc需要服务端与客户端上一些包的版本相同,不然会出现奇奇怪怪的问题。

暂时已知需相同版本的包

  • distcc
  • gcc
  • glibc
  • linux-headers(不确定)
  • binutils

源码安装

https://github.com/distcc/distcc/releases获取源码。解压后

./configure && make && sudo make install

windows上安装

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将不使用本地编译。

portage使用

/etc/portage/make.conf中加入

MAKEOPTS="-j15 -l6 "
FEATURES="distcc"

参数-jN(N为数字)N表示使用本地cpu核心+远程cpu核心的和。-lM(M为数字)M表示本地cpu核心数量

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值