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

Rob Stewart
Wed, 27 Nov 2013 13:57:46 -0000

On 26 November 2013 16:44, Renato Golin <renato.golin at linaro.org>
wrote:
> 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,

I'm honoured. (But Rob is also OK) :-)

> 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.

So on my Fedora box, I've installed packages gcc-arm-linux-gnu.x86_64
and cross-binutils-common.noarch . Moreover, the first of these two
packages provide `/usr/bin/arm-linux-gnu-gcc`
$ repoquery -lq gcc-arm-linux-gnu.x86_64
Repository google-chrome is listed more than once in the configuration
/usr/bin/arm-linux-gnu-cpp
/usr/bin/arm-linux-gnu-gcc
/usr/bin/arm-linux-gnu-gcov
/usr/lib/gcc/arm-linux-gnueabi
/usr/lib/gcc/arm-linux-gnueabi/4.8.1
/usr/lib/gcc/arm-linux-gnueabi/4.8.1/crtbegin.o
...

The -target that appears to be recognised by clang is `arm-none-eabi`.
However, I'm now falling in to another trap.
$ clang -v -target arm-none-eabi -mcpu=cortex-a9 -mfloat-abi=soft helloworld.c
...
arm-none-eabi-gcc: fatal error: selected multilib '.' not installed

I've put the -v output to gist: https://gist.github.com/robstewart57/7676030