ubuntu14.04_x86-64
clang v3.4
因为我可以使用命令clang -target i386 hello.c
来编译hello.c,所以我尝试使用
clang -target arm hello.c
,
clang -target armv7 hello.c
,
clang -target armv7-a hello.c
,
clang -target arm-eabi hello.c
为ARM编译hello.c但都失败了。
是否有关于clang支持的目标类型的信息?
$ clang -target arm-none-eabi hello.c
/tmp/hello-c8aebe.s: Assembler messages:
/tmp/hello-c8aebe.s:1: Error: unknown pseudo-op: `.syntax'
/tmp/hello-c8aebe.s:2: Error: unknown pseudo-op: `.cpu'
/tmp/hello-c8aebe.s:3: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:4: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:5: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:6: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:7: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:8: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:9: Error: unknown pseudo-op: `.eabi_attribute'
/tmp/hello-c8aebe.s:16: Error: invalid char '{' beginning operand 1 `{r11'
/tmp/hello-c8aebe.s:17: Error: too many memory references for `mov'
/tmp/hello-c8aebe.s:18: Error: too many memory references for `sub'
/tmp/hello-c8aebe.s:19: Error: expecting operand after ','; got nothing
/tmp/hello-c8aebe.s:20: Error: invalid char '[' beginning operand 2 `[r11'
/tmp/hello-c8aebe.s:21: Error: no such instruction: `ldr r1,.LCPI0_0'
/tmp/hello-c8aebe.s:22: Error: invalid char '[' beginning operand 2 `[sp'
/tmp/hello-c8aebe.s:23: Error: too many memory references for `mov'
/tmp/hello-c8aebe.s:24: Error: no such instruction: `bl printf'
/tmp/hello-c8aebe.s:25: Error: no such instruction: `ldr r1,[sp,'
/tmp/hello-c8aebe.s:26: Error: invalid char '[' beginning operand 2 `[sp'
/tmp/hello-c8aebe.s:27: Error: too many memory references for `mov'
/tmp/hello-c8aebe.s:28: Error: too many memory references for `mov'
/tmp/hello-c8aebe.s:29: Error: invalid char '{' beginning operand 1 `{r11'
/tmp/hello-c8aebe.s:30: Error: no such instruction: `bx lr'
clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)
clang -emit-llvm -c hello.c -o hello.bc
llc -march=arm hello.bc -o hello.s
arm-linux-gnueabihf-gcc -o hello hello.s
在最后一个命令中进行了分析
答案 0 :(得分:1)
这不是"编译器支持"的目标,而是您需要与编译器一起使用的工具。这有点像在你的工具车间抱怨你的插座组能够得到你的汽车的轮子,但它并没有带来轮胎脱离轮辋工具"。
Clang可以为许多不同的处理器生成代码。但它依赖于外部工具来从汇编中生成二进制代码[虽然我认为至少有时会通过内部汇编程序执行此操作]并链接二进制目标文件[总是,无论如何]。
您的目标架构需要binutils
- 至少as
和ld
支持arm-none-eabi
。除非您的代码也是完全独立的,否则您将需要一个C库和一个为该目标构建的C ++库。