I have tried to use many target types to compile hello.c for ARM on
ubuntu_x86 with clang v3.4 but all failed,anyone knows the correct types?
I can`t get any type information on llvm document.
That's because there is no right answer, as it depends on the
environment. But there is a document that teaches how to cross-compile
that has some hints:
The section on Target Triple tells you that you must follow whatever
your distribution calls the tool you want to use. For example, if you
have "arm-none-eabi-as", then you need the triple to be
"arm-none-eabi" and set CPU/FPU manually via -mcpu/-mfpu.
IIRC, Ubuntu also has "armv7-linux-gnueabihf" or something, and that
would chose Cortex-A8 + NEON by default, with hard-float, so you'll
need less cpu/fpu options.
In a nutshell, use whatever triple you have your target toolchain in the path.
Another option is to use the --sysroot option, if you have unzipped
your toolchain somewhere like /opt. This will also help you defining
the libraries and headers location, and avoid a lot of -I and -L
$ clang -target arm-none-eabi hello.c
/tmp/hello-c8aebe.s: Assembler messages:
/tmp/hello-c8aebe.s:1: Error: unknown pseudo-op: `.syntax'
I hate this error, and I think Clang could do *a lot* better, but this
is because Clang didn't find the target assembler and defaults to the
host's version, which of course, is x86, not ARM.
I think Clang should *at least* warn that it didn't find the target's
assembler and is defaulting to something, especially when host !=