2017-08-17 115 views
1

我想使用distcc將我的Mac中的代碼編譯到一堆Linux主機,但我無法弄清楚使一切「排隊」。我已經成功地使用了從Mac到Mac的distcc,所以我對如何設置東西有一個總體思路。如何使用clang和distcc編譯不同體系結構的從站(例如mac/linux)

我使用的是鐺4.0,並已安裝並在Mac和Linux上工作。下面的命令編譯罰款不distcc開頭,但加入的distcc後,我得到了以下問題:

distcc /Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/clang++ -I/usr/local/include -I/Users/xaxxon/v8toolkit/./include -I/Users/xaxxon/v8/include -stdlib=libc++ -g -Werror=return-type -g -std=gnu++1z -o CMakeFiles/v8toolkit_static.dir/src/v8toolkit.cpp.o -c /Users/xaxxon/v8toolkit/src/v8toolkit.cpp 

我不知道被什麼拾起了編譯器在Linux上,我也不知道該怎麼找出。有可能它會選擇gcc而不是clang。

我首先考慮的是這樣的:

clang: warning: argument unused during compilation: '-stdlib=libc++' 

我的第一個錯誤是:

In file included from /Users/xaxxon/v8toolkit/src/v8toolkit.cpp:5: 
In file included from /usr/include/assert.h:44: 
In file included from /Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/../include/c++/v1/stdlib.h:94: 
/usr/include/stdlib.h:250:20: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them 
int atexit_b(void (^)(void)) __attribute__((availability(macosx,introduced=10.6))); 

下一個錯誤,我得到(成爲第一個錯誤,如果我手動添加-fblocks到編輯命令(這是本地Mac版本不需要)是:

/Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/../include/c++/v1/__tuple:289:13: error: unknown type name '__type_pack_element' 
    typedef __type_pack_element<_Ip, _Types...> type; 
      ^
/Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/../include/c++/v1/__tuple:289:32: error: expected member name or ';' after declaration specifiers 
    typedef __type_pack_element<_Ip, _Types...> type; 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 
/Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/../include/c++/v1/__tuple:356:43: error: use of undeclared identifier '__type_pack_element' 
     typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>... 
             ^
/Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/../include/c++/v1/__tuple:357:6: error: expected a type 
    >; 

我不明白我是否在做s從根本上說是錯誤的,或者如果我錯過了一些讓Linux編譯器的行爲不同的小東西。

謝謝你的任何提示或建議。

編輯:我只是確保在Linux上有相同的命名目錄,現在只能得到-fblocksunused during compilation -stdlib=libc++問題。

EDIT2:我能得到的一切編譯(儘管有警告),但是當它鏈接,我得到:

ld: warning: ignoring file CMakeFiles/v8toolkit_shared.dir/src/debugger.cpp.o, file was built for 
unsupported file format (0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00) which is not the architecture being linked 
(x86_64): CMakeFiles/v8toolkit_shared.dir/src/debugger.cpp.o 

回答

1

添加-target標誌修復一切!在我的情況下,埃爾卡皮坦,目標三重是:

-target x86_64-apple-darwin15.6.0 

爲構建命令:

distcc /Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin/clang++ -Dv8toolkit_shared_EXPORTS -I/usr/local/include -I/Users/xaxxon/v8toolkit/./include -isystem /Users/xaxxon/v8/include -stdlib=libc++ -g -Werror=return-type -target x86_64-apple-darwin15.6.0 -g -fPIC -std=gnu++1z -o CMakeFiles/v8toolkit_shared.dir/src/v8toolkit.cpp.o -c /Users/xaxxon/v8toolkit/src/v8toolkit.cpp 

你可以得到當前主機的目標鍵入clang -v

$ clang -v 
clang version 4.0.0 (tags/RELEASE_400/final) 
Target: x86_64-apple-darwin15.6.0 <<==== THIS LINE HERE 
Thread model: posix 
InstalledDir: /Users/xaxxon/Downloads/clang+llvm-4.0.0-x86_64-apple-darwin/bin 

下面的CMake行將抓取(並打印)當前機器的三元組:

# Get the target triple for the current host by calling clang -v and then stripping out the Target: value from its output. CMake regex syntax is quite limited. 
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v ERROR_VARIABLE CLANG_VERSION_INFO) 
string(REGEX REPLACE ".*Target:[\r\n\t ]*([^\r\n\t]*).*Thread model.*" "\\1" TARGET_TRIPLE ${CLANG_VERSION_INFO}) 
message(STATUS "TARGET TRIPLE: '${TARGET_TRIPLE}' END") 

非常感謝@duskwuff和oftc.net #llvm求助!

相關問題