0

我正在测试distcc,我发现这个教程很容易理解,我应该说我能够编译llvm使用CMake + NinjaCMake + Makefiles使用distcc并且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.
4

3 回答 3

1

启用调试消息(带$ 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

据我了解,SECTION A找到远程服务器,SECTION B打开与服务器的连接,SECTION C发送命令以在服务器中运行(包括编译选项和要编译的文件),SECTION D获取结果,E 部分分析结果并决定下一步做什么。如您所见,这是错误:

distcc[13039] (dcc_x_token_string) send string '@_out/Release/Boot/Main.o.via'
distcc[13039] (dcc_x_token_int) send ARGV00000002
于 2020-02-16T19:32:32.153 回答
1

要查看编​​译错误的输出,请在上面定义这些环境:

export DISTCC_VERBOSE=1
export DISTCC_SAVE_TEMPS=1
export DISTCC_FALLBACK=0

另见man distcchttps://linux.die.net/man/1/distcc

于 2021-10-25T07:04:00.063 回答
0

当前的 distcc 维护者,

我强烈建议MASQUERADE按照 distcc 手册页中的说明使用。

于 2020-02-16T12:50:50.620 回答