如何使用Clang交叉编译源代码?

时间:2014-08-26 18:27:40

标签: clang cross-compiling clang++ llvm-clang uclibc

我在主机(Ubuntu 12.04 LTS)中安装了clang 3.4并尝试交叉编译一个简单的C ++ 11程序,以便在mips32r1(小端)+ uclibc环境中执行。

在尝试交叉编译时,我遇到了错误,(附上了详细的输出)

arunprasadr@cheetah:~/works/myex/llvm$ clang++ test.cc --sysroot=/home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc -v -target mipsel-unknown-linux-uclibc -I /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4 -I /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4/mipsel-linux-uclibc
Ubuntu clang version 3.4-1ubuntu3~precise1 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: mipsel-unknown-linux-uclibc
Thread model: posix
Selected GCC installation:
 "/usr/bin/clang" -cc1 -triple mipsel-unknown-linux-uclibc -S -disable-free -disable-llvm-verifier -main-file-name test.cc -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-cpu mips32 -target-abi o32 -mfloat-abi hard -target-linker-version 2.22 -v -resource-dir /usr/bin/../lib/clang/3.4 -I /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4 -I /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4/mipsel-linux-uclibc -isysroot /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc -internal-isystem /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4/include -internal-externc-isystem /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include -internal-externc-isystem /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/usr/include -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/arunprasadr/works/myex/llvm -ferror-limit 19 -fmessage-length 197 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /tmp/test-508ee4.s -x c++ test.cc
clang -cc1 version 3.4 based upon LLVM 3.4 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4
 /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include/c++/4.5.4/mipsel-linux-uclibc
 /usr/bin/../lib/clang/3.4/include
 /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/include
 /home/arunprasadr/toolchains/stbgcc-4.5.4-2.5/mipsel-unknown-linux-uclibc/usr/include
End of search list.
test.cc:8:7: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  for(auto aa : str) {
      ^
test.cc:8:15: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
  for(auto aa : str) {
              ^
2 warnings generated.
 "/usr/bin/as" -march mips32 -mabi 32 -EL -o /tmp/test-3b520a.o /tmp/test-508ee4.s
Assembler messages:
Fatal error: invalid -march= option: `mips32'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)

似乎clang试图调用系统汇编程序而不是交叉工具链的汇编程序。无论如何将汇编程序设置为clang?

编辑(1) - 添加参考链接

参考:http://clang.llvm.org/docs/CrossCompilation.html

0 个答案:

没有答案