cross-compiling with llvm

Hi,
i wanted to use llvm to cross-compile c++ code for powerpc on a x86
(debian linux), but i have some problems configuring and compiling
llvm-suite and front-end.
Here are some of my questions:

1. Is it possible at all to cross-compile with llvm?

2. I allready have a gcc cross-compiler for power-pc, do i need this or
   does llvm contain its own? How can i tell llvm to use it?

3. Is there any howto for doing the cross-compiling? I think i need
   to compile the gcc-front-end for this task, but i don't know the
   options for the configuration script.

Can anyone give me some advice?

Regards Philipp.

  1. Is it possible at all to cross-compile with llvm?

Yes, this is possible. I’ve cross-compiled from x86 to MIPS using LLVM. However, the codes I compiled using this technique did not always run correctly. You may have better luck with PPC.

  1. I allready have a gcc cross-compiler for power-pc, do i need this or
    does llvm contain its own? How can i tell llvm to use it?

LLVM has no MIPS backend, so when I did this, I used the C backend to transform the LLVM bytecode to C, then put the result through a gcc MIPS cross compiler. LLVM does have a PPC backend, however, so I don’t think you need to do this. I think you want to build llvm-gcc on x86 as a PPC cross compiler, use it to compile to LLVM bytecode, and then use the PPC backend to generate PPC code. To generate PPC code from foo.bc, you say llc -march=powerpc < foo.c > foo.

  1. Is there any howto for doing the cross-compiling? I think i need
    to compile the gcc-front-end for this task, but i don’t know the
    options for the configuration script.

Building llvm-gcc as a cross compiler is tricky and not documented. I’m away from Urbana right now, but when I get back tomorrow I’ll take a look at what I did for MIPS and see if I can reconstruct it for you.

Rob

Robert L. Bocchino Jr.

Ph.D. Student

University of Illinois, Urbana-Champaign

Building llvm-gcc as a cross compiler is tricky and not documented. I’m away from Urbana right now, but when I get back tomorrow I’ll take a look at what I did for MIPS and see if I can reconstruct it for you.

Hi,

It looks like I ran the llvm-gcc configure script with the following options, where $(INSTALLDIR) is the directory I built into:

configure --prefix=$(INSTALLDIR) --disable-threads --disable-nls --disable-shared --enable-languages=c,c++ --program-prefix=llvm- --target=mipseb-linux --with-sysroot=$(INSTALLDIR)

You will probably want to say --target=powerpc.

I hope this helps.

Rob

Robert L. Bocchino Jr.

Ph.D. Student, Computer Science

University of Illinois, Urbana-Champaign