【发布时间】:2016-03-02 11:09:59
【问题描述】:
平台:
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)
我已经安装了gcc-linaro-arm-linux-gnueabihf-4.7,使用如下方式编译,但是指令不匹配。
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
最后一条命令失败
【问题讨论】: