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

Sean Silva chisophugis at gmail.com
Tue Nov 26 09:40:17 PST 2013


On Tue, Nov 26, 2013 at 11:44 AM, 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,
>
> 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.
>

Out of curiosity, can't clang do the assembly itself in this case?


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

Well, just remember that the GNU binutils that those tools are derived from
support far more architectures (3x, 5x?) than LLVM does (just supporting
linux requires like 30 architectures). When we get to that point, it will
probably not make sense for a distro to ship a binary targeting all the
architectures that we support, for the same reason it doesn't make sense
for them to install binaries for every target supported by the GNU
toolchain. (but at least in LLVM's case, it would be a conscious tradeoff,
while IIRC the GNU toolchain simply can't be built in a way that targets
all of them from a single binary).

-- Sean Silva


>
> cheers,
> --renato
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131126/70ea0853/attachment.html>


More information about the llvm-dev mailing list