[LLVMdev] Cross compiling to ARM using LLC {Help}

Tim Northover t.p.northover at gmail.com
Tue Dec 17 07:48:14 PST 2013


Hi Najem,

> # generate LLVM-IR for dijkstra_large.c
> $gcc -S -flto -o dijkstra_large.bc -fplugin=${DRAGONEGG} dijkstra_large.c

Is your GCC configured as an arm-linux-gnueabihf compiler? If not,
it's almost certainly going to be getting ABI details wrong. I'm
slightly surprised that it affects argv, but it's certainly the first
thing to think about.

> # generate TARGET object file for dijkstra_large.bc
> $./llc -march=arm -mcpu=cortex-a9 dijkstra_large.bc -o dijkstra_large.o -filetype=obj -O3

If Dragonegg *is* generating for ARM then the "-march=arm" option to
llc should be unnecessary.

Also, GCC should probably have "-O3" as well, since llc is the backend
code generator and doesn't run the mid-end phases.

> # Generate executalbe using Target's toolchain
> $arm-linux-gcc -static dijkstra_large.o -o dijkstra_large

I've not seen an arm-linux-gcc before, so I'm slightly worried about
what ABI it's using (-gnu, -gnueabi or -gnueabihf).

> The second issue is that when I use "arm-linux-gnueabihf-gcc" cross compiler
> instead of the arm-linux-gcc I get the following error

> Also it would be nice if anyone can point me to a tutorial which shows how
> to build LLVM cross compiler using the clang.

That sounds like a very good idea. For a start there are far more
people here who know how to get clang to cooperate than DragonEgg
(I've never even built DragonEgg, for example). We've got a couple of
documents on that topic:

http://llvm.org/docs/HowToCrossCompileLLVM.html
http://clang.llvm.org/docs/CrossCompilation.html

They're not perfect by any means yet (still fairly new), but it'd be
great to hear your experiences trying to follow them so we can improve
things.

Cheers.

Tim.



More information about the llvm-dev mailing list