我正在测试 distcc,我发现本教程很容易遵循,我应该说我能够使用CMake + Ninja
编译llvm
,并使用distcc
和CMake + Makefiles
编译docker
没有问题。由于我对 Makefiles 特别感兴趣,我查看了CMake + Ninja
生成的文件,我看到的只是distcc
作为前缀添加到编译器中(例如distcc /usr/bin/gcc
(。所以我想,如果我只使用Makefiles创建一个小项目,我可能会添加distcc
事情就会神奇地工作。好吧,看起来我错过了一些东西,因为我得到的只是:
$ ./mk.sh image
make[1]: Entering directory '/home/user/sandbox/distcc-makefiles'
Compiling Lib/Print.c
Compiling Boot/Main.c
distcc[16644] ERROR: compile Boot/Main.c on 172.17.0.2/1 failed
distcc[16644] (dcc_build_somewhere) Warning: remote compilation of 'Boot/Main.c' failed, retrying locally
distcc[16644] Warning: failed to distribute Boot/Main.c to 172.17.0.2/1, running locally instead
distcc[16644] (dcc_please_send_email_after_investigation) Warning: remote compilation of 'Boot/Main.c' failed, retried locally and got a different result.
distcc[16643] ERROR: compile Lib/Print.c on 172.17.0.2/1 failed
distcc[16643] (dcc_build_somewhere) Warning: remote compilation of 'Lib/Print.c' failed, retrying locally
distcc[16643] Warning: failed to distribute Lib/Print.c to 172.17.0.2/1, running locally instead
distcc[16643] (dcc_please_send_email_after_investigation) Warning: remote compilation of 'Lib/Print.c' failed, retried locally and got a different result.
make[1]: Leaving directory '/home/user/sandbox/distcc-makefiles'
通过运行llvm
示例,我丢弃了所有连接docker
distcc
配置问题,我尝试在互联网上搜索任何想法/示例,但大多数人使用CMake
这不是我的情况。欢迎提出建议,我的演示项目基于我正在处理的真实项目,所以这就是Makefile
的基本外观。
我不知道我错过了什么...
版本:
仅供参考:
$ distcc --version
distcc 3.1 x86_64-pc-linux-gnu
(protocols 1, 2 and 3) (default port 3632)
built Oct 19 2017 11:05:18
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.
$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
$ make --version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
启用调试消息(使用$ export DISTCC_VERBOSE=1
(后,我发现distcc
实际上在服务器中编译,但编译失败,这就是它在本地重试的原因。
它失败了,因为我正在使用外部文件来保留其他选项(请参阅gcc @file(,并且distcc
基本上不会将其解释为文件,而是将其解释为字符串。这就是编译失败和distcc
回退的原因。
日志审查
作为参考,distcc
日志如下所示(分为多个部分以进一步说明(:
... {{ SECTION A }}
distcc[13039] (dcc_spawn_child) forking to execute: gcc -std=c99 -Wall @_out/Release/Boot/Main.o.via -E /home/user/sandbox/distcc-makefiles/Boot/Main.c
distcc[13040] (dcc_get_hostlist) read hosts from environment
distcc[13040] (dcc_parse_hosts) found tcp token "172.17.0.2/1"
distcc[13039] (dcc_spawn_child) child started as pid13041
... {{ SECTION B }}
distcc[13039] (dcc_strip_local_args) result: gcc -std=c99 -Wall @_out/Release/Boot/Main.o.via -c /home/user/sandbox/distcc-makefiles/Boot/Main.c -o _out/Release/Boot/Main.o
distcc[13039] exec on 172.17.0.2/1: gcc -std=c99 -Wall @_out/Release/Boot/Main.o.via -c /home/user/sandbox/distcc-makefiles/Boot/Main.c -o _out/Release/Boot/Main.o
distcc[13039] (dcc_note_state) note state 2, file "Main.c", host "172.17.0.2"
distcc[13039] (dcc_connect_by_name) connecting to 172.17.0.2 port 3632
distcc[13041] (dcc_new_pgrp) entered process group
distcc[13041] (dcc_increment_safeguard) setting safeguard: _DISTCC_SAFEGUARD=1
distcc[13039] (dcc_connect_by_addr) started connecting to 172.17.0.2:3632
... {{ SECTION C }}
distcc[13039] (dcc_select_for_write) select for write on fd6
distcc[13039] (dcc_note_state) note state 4, file "(NULL)", host "(NULL)"
distcc[13039] (dcc_x_token_int) send DIST00000001
distcc[13039] (dcc_x_token_int) send ARGC00000008
distcc[13039] (dcc_x_token_int) send ARGV00000003
distcc[13039] (dcc_x_token_string) send string 'gcc'
distcc[13039] (dcc_x_token_int) send ARGV00000008
distcc[13039] (dcc_x_token_string) send string '-std=c99'
distcc[13039] (dcc_x_token_int) send ARGV00000005
distcc[13039] (dcc_x_token_string) send string '-Wall'
distcc[13039] (dcc_x_token_int) send ARGV0000001d
distcc[13039] (dcc_x_token_string) send string '@_out/Release/Boot/Main.o.via'
distcc[13039] (dcc_x_token_int) send ARGV00000002
distcc[13039] (dcc_x_token_string) send string '-c'
distcc[13039] (dcc_x_token_int) send ARGV0000002f
distcc[13039] (dcc_x_token_string) send string '/home/user/sandbox/distcc-makefiles/Boot/Main.c'
distcc[13039] (dcc_x_token_int) send ARGV00000002
distcc[13039] (dcc_x_token_string) send string '-o'
distcc[13039] (dcc_x_token_int) send ARGV00000018
distcc[13039] (dcc_x_token_string) send string '_out/Release/Boot/Main.o'
distcc[13039] (dcc_note_state) note state 3, file "(NULL)", host "(NULL)"
distcc[13039] (dcc_collect_child) cpp child 13041 terminated with status 0
distcc[13039] (dcc_collect_child) cpp times: user 0.000000s, system 0.000000s, 0 minflt, 0 majflt
distcc[13039] cpp /home/user/sandbox/distcc-makefiles/Boot/Main.c on localhost completed ok
... {{ SECTION D }}
distcc[13039] (dcc_unlock) release lock fd4
distcc[13039] (dcc_x_file) send 14682 byte file /tmp/distcc_cd4d9216.i with token DOTI and compression 69
distcc[13039] (dcc_x_token_int) send DOTI0000395a
distcc[13039] (dcc_compile_remote) client finished sending request to server
distcc[13039] (dcc_note_state) note state 5, file "(NULL)", host "172.17.0.2"
distcc[13039] (dcc_select_for_read) select for read on fd6 for 300s
distcc[13039] (dcc_r_token_int) got DONE00000001
distcc[13039] (dcc_note_state) note state 6, file "(NULL)", host "(NULL)"
distcc[13039] (dcc_r_token_int) got STAT00000100
distcc[13039] (dcc_r_token_int) got SERR00000044
distcc[13039] (dcc_r_file) received 68 bytes to file /tmp/distcc_server_stderr_cd009216.txt
distcc[13039] (dcc_r_token_int) got SOUT00000000
distcc[13039] (dcc_r_token_int) got DOTO00000000
... {{ SECTION E }}
distcc[13039] 14682 bytes from /home/user/sandbox/distcc-makefiles/Boot/Main.c compiled on 172.17.0.2 in 0.0063s, rate 2274kB/s
distcc[13039] (dcc_unlock) release lock fd3
distcc[13039] ERROR: compile /home/user/sandbox/distcc-makefiles/Boot/Main.c on 172.17.0.2/1 failed
distcc[13039] (dcc_build_somewhere) Warning: remote compilation of '/home/user/sandbox/distcc-makefiles/Boot/Main.c' failed, retrying locally
distcc[13039] (dcc_mark_timefile) mark /home/user/.distcc/lock/backoff_tcp_172.17.0.2_3632_0
distcc[13039] Warning: failed to distribute /home/user/sandbox/distcc-makefiles/Boot/Main.c to 172.17.0.2/1, running locally instead
据我了解,其中 A节找到远程服务器,B 节打开与服务器的连接,C节发送要在服务器中运行的命令(包括编译选项和要编译的文件(,D节获取结果,E 节分析结果并决定下一步该怎么做。如您所见,这是错误:
distcc[13039] (dcc_x_token_string) send string '@_out/Release/Boot/Main.o.via'
distcc[13039] (dcc_x_token_int) send ARGV00000002
要查看编译错误的输出,请在上面定义以下环境:
export DISTCC_VERBOSE=1
export DISTCC_SAVE_TEMPS=1
export DISTCC_FALLBACK=0
另请参阅man distcc
或 https://linux.die.net/man/1/distcc
当前的distcc维护者,
我强烈建议使用 distcc 手册页中记录的MASQUERADE
。