[LLVMdev] Targeting ARM Cortex-a9 from x86_64 with clang

Renato Golin renato.golin at linaro.org
Tue Nov 26 08:44:37 PST 2013


On 26 November 2013 15:36, Rob Stewart <robstewart57 at gmail.com> wrote:

> $ clang -v -target armv7a-linux-eabi -mcpu=cortex-a9 -mfloat-abi=soft
> -mfpu=neon helloworld.c
>

Hi Rod,

You need cross-binutils installed on your box. If you use Debian, there are
packages (gcc-4.7-arm-linux-gnueabi and friends). Other distros may have
similar packages, but you can always download the Linaro toolchain (
http://releases.linaro.org/latest/components/toolchain).

Supposing you already have it, and it's in the PATH, Clang only recognizes
it automatically if your triple is identical to the name of your cross
compiler (See "Toolchain Options" in the referred doc). That means, you
either need to have an "armv7a-linux-eabi-gcc" on the path, or you have to
change your triple to something like "arm-linux-gnueabi", because that's
what your cross-GCC will probably be called. The -mcpu will take care of
choosing v7A.

Otherwise, you'll have to set --sysroot or --gcc-name as well as the
triple, but that's not recommended.


 "/usr/bin/as" -mfpu=neon -mfloat-abi=soft -mcpu=cortex-a9 -mfpu=neon
>

As you can see, it chose the platform assembler, which is x86_64-only, not
a cross-assembler. That's the hint that Clang didn't find your
cross-binutils.

I know, Clang could have better error detection and stop when it's clearly
the wrong architecture, but hey, Clang can deal with all archs on the same
binary, there's no reason your system assembler (whatever it is) can't,
too. One day, LLVM binutils will be... ;)

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131126/dfffabb0/attachment.html>


More information about the llvm-dev mailing list