Clang 用yoctosdk进行交叉编译

Clang 用yoctosdk进行交叉编译,clang,cross-compiling,llvm-clang,yocto,Clang,Cross Compiling,Llvm Clang,Yocto,是否可以使用YoctoSDK中的工具链和sysroot与Clang/LLVM for ARM交叉编译 Yocto SDK中的环境设置脚本具有以下编译器选项: export CC="arm-poky-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=$SDKTARGETSYSROOT" 我想交叉编译这个简单的用户空间应用程序 第c页: #include <stdi

是否可以使用YoctoSDK中的工具链和sysroot与Clang/LLVM for ARM交叉编译

Yocto SDK中的环境设置脚本具有以下编译器选项:

export CC="arm-poky-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
我想交叉编译这个简单的用户空间应用程序

第c页:

#include <stdio.h>
int main()
   {
   printf("Hello World\n");
   return(0);
   }
但是,这在以下情况下失败:

Ubuntu clang version 3.4.2-3ubuntu2~xedgers (tags/RELEASE_34/dot2-final) (based on LLVM 3.4.2)
Target: arm-poky-linux-gnueabi
Thread model: posix
Selected GCC installation: 
 "/usr/lib/llvm-3.4/bin/clang" -cc1 -triple armv7-poky-linux-gnueabi -S -disable-free -disable-llvm-verifier -main-file-name testapp.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-cpu cortex-a7 -target-feature +neon -target-abi aapcs-linux -mfloat-abi hard -target-linker-version 2.24 -v -resource-dir /usr/lib/llvm-3.4/bin/../lib/clang/3.4.2 -I /opt/poky/2.0.1/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/5.2.0/arm-poky-linux-gnueabi/ -internal-isystem /usr/include/clang/3.4.2/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-3.4/bin/../lib/clang/3.4.2/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fno-dwarf-directory-asm -fdebug-compilation-dir /home/adtec/workspace/yocto/testapp -ferror-limit 19 -fmessage-length 207 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /tmp/testapp-8517af.s -x c testapp.c
clang -cc1 version 3.4.2 based upon LLVM 3.4.2 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/include/clang/3.4.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/poky/2.0.1/sysroots/cortexa7hf-vfp-neon-poky-linux-gnueabi/usr/include/c++/5.2.0/arm-poky-linux-gnueabi
 /usr/include/clang/3.4.2/include
 /usr/local/include
 /usr/include
End of search list.
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
 "/usr/bin/as" -mfloat-abi=hard -mcpu=cortex-a7 -mfpu=neon -o /tmp/testapp-f4f688.o /tmp/testapp-8517af.s
/usr/bin/as: unrecognized option '-mfloat-abi=hard'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
ubuntuclangversion3.4.2-3ubuntu2~xedgers(tags/RELEASE_34/dot2final)(基于LLVM 3.4.2)
目标:arm poky linux gnueabi
线程模型:posix
选定的GCC安装:
“/usr/lib/llvm-3.4/bin/clang”-cc1-三重armv7 poky linux gnueabi-S-禁用自由-禁用llvm验证器-主文件名testapp.c-mrelocation model static-mdisable fp elim-fmath errno-mconstructor别名-目标cpu cortex-a7-目标功能+霓虹灯-目标abi aapcs linux-Loat abi硬-目标链接器版本2.24-v-资源目录/usr/lib/llvm-3.4/bin//lib/clang/3.4.2-I/opt/poky/2.0.1/sysroot/cortexa7hf vfp neon poky-linux-gnueabi/usr/include/c++/5.2.0/arm-poky-linux-gnueabi/-内部isystem/usr/clang/3.4.2/include/-内部isystem/usr/local/include-内部isystem/usr/lib/llvm-3.4/bin//内部isystem-内部外部isystem/usr/include-fno dwarf目录asm-fdebug编译目录/home/adtec/workspace/yocto/testapp-ferror limit 19-fmessage length 207-mstackrealign-fno signed char-fobjc runtime=gcc-fdiagnostics show option-fcolor diagnostics-vecize slp-o/tmp/testapp-8517af.s-x c testapp.c
clang-cc1版本3.4.2基于LLVM 3.4.2默认目标x86_64-pc-linux-gnu
忽略不存在的目录“/包括”
忽略重复目录“/usr/include/clang/3.4.2/include”
#包括“…”搜索从这里开始:
#包括搜索从这里开始:
/opt/poky/2.0.1/sysroot/cortexa7hf vfp neon poky-linux-gnueabi/usr/include/c++/5.2.0/arm-poky-linux-gnueabi
/usr/include/clang/3.4.2/include
/usr/本地/包括
/usr/包括
搜索列表结束。
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“cortex-a7”不是此目标的可识别处理器(忽略处理器)
“/usr/bin/as”-mfloat abi=hard-mcpu=cortex-a7-mfpu=neon-o/tmp/testapp-f4f688.o/tmp/testapp-8517af.s
/usr/bin/as:无法识别的选项'-mfloat abi=hard'
叮当声:错误:汇编程序命令失败,退出代码为1(使用-v查看调用)

交叉编译这个简单的ARM应用程序需要什么样的Clang标志?

如果您可以访问完整的构建,而不仅仅是SDK,您可以尝试使用Clang层。虽然最终应该可以构建一个包含clang的SDK,但我认为还没有人这样做。

您可以使用meta clang并生成一个包含gcc和基于clang的交叉编译器的SDK,一旦安装了SDK,就有CLANGCC和CLANGCXX环境变量可用于调用clang而不是gcc。如果您想使用它作为默认值,您可以这样做

export CC=${CLANGCC}
export CXX=${CLANGCXX}
export CPP=${CLANGCPP}

还有一个用于Clang SDK的writeup

,它是Clang的一个相当旧的版本,显然没有使用集成汇编程序。我在基于Clang3.9的编译器上尝试了类似的方法,得到了完全不同的结果:链接时失败,因为我的库是使用-mfloat abi=soft编译的。如果我使用它:我还尝试了使用-no集成as,并且没有将-mfloat abi标志传递给汇编程序。我希望实现这一点,因为GCC 4.8不支持ARM上的AddressSanitizer(
export CC=${CLANGCC}
export CXX=${CLANGCXX}
export CPP=${CLANGCPP}