[LLVMdev] Cross-compiler to arm
Hanbing Li
hanbing.li at inria.fr
Fri Nov 7 07:37:31 PST 2014
Hi Tim,
Thank you very much. Following your suggestion, I have gotten an executable a.out
on pandaboard!
Thank you.
Sincerely,
Hanbing
----- Mail original -----
> De: "Tim Northover" <t.p.northover at gmail.com>
> À: "Hanbing Li" <hanbing.li at inria.fr>
> Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Envoyé: Jeudi 6 Novembre 2014 18:46:47
> Objet: Re: [LLVMdev] Cross-compiler to arm
>
> Hi Hanbing,
>
> On 6 November 2014 09:21, Hanbing Li <hanbing.li at inria.fr> wrote:
> > clang-3.5: error: no such file or directory: '—mfpu=neon'
> > clang-3.5: error: no such file or directory: '—-sysroot=...'
>
> I suspect these are copy/paste errors, with some overzealous tool
> converting an ASCII hyphen to some kind of unicode n-dash (U+2013) or
> similar. Then LLVM thinks they're files rather than options.
>
> > clang-3.5: error: -emit-llvm cannot be used when linking
>
> As you discovered, "-c" is the solution here (or one solution anyway).
> I'm not quite sure why you're trying to do it in so many steps though;
> for educational purposes?
>
> Another point is that the triple you're using looks weird. LLVM is
> certainly ignoring the "v7l" part (it doesn't know anything about 'l'
> as a variant).
>
> Also, the usual Linux triples are "armv7-linux-gnueabi" (which does
> softfp automatically) and "armv7-linux-gnueabihf" (which uses the
> hard-float ABI). While you could probably create a "linux-eabi"
> system, I'm not aware of any (it affects things like the names of
> compiler support functions).
>
> > $ ld -e main -o a.out test.o
>
> If you are running on Linux, main is almost certainly not the entry
> point. Usually there's a function _start in one of the crt*.o files
> that performs necessary setup and tidying. Skipping it could well
> account for the segfault.
>
> The compiler normally knows how to tell the linker what to do about
> this. So I'd put one on the panda board itself and use that:
>
> $ gcc test.o -o a.out
>
> (or clang, of course!)
>
> > Does anyone know how to cross-compile from MacOS to arm? Or tell me what's
> > wrong with my operations!
>
> You'll probably have a bit of an up hill struggle (most cross-Linux
> developers use Linux, so that's what the documentation, such as it is,
> assumes). Have you considered using a Linux virtual machine on your
> Mac for this project?
>
> > Any suggestion or information is appreciated!
>
> I'd probably suggest letting clang do the entire compilation in one step:
>
> $ clang -target armv7-linux-gnueabi test.c -o a.out
>
> You'll need a full target toolchain for this to work (the
> gcc-arm-linux-gnueabi someone mentioned to you), so it's initially
> harder than just getting a .s out of clang and doing the rest on the
> Panda. But you're going to hit those problems anyway as soon as you
> want to "#include <stdio.h>": the version that comes with your Mac
> will almost certainly make things go horribly wrong in weird ways.
>
> Cheers.
>
> Tim.
>
More information about the llvm-dev
mailing list