[LLVMdev] setting up LLVM to *run on* amd64 but *generate code* for alpha

Andrew Lenharth andrewl at lenharth.org
Sat Mar 14 08:12:11 PDT 2009


On Fri, Mar 13, 2009 at 7:41 PM, Zack Weinberg <zackw at panix.com> wrote:
> I'm trying to persuade llvm (svn trunk) to build in a mode where it
> *runs on* amd64 but *generates code* for alpha, exclusively.  (Well,
> technically, generate code for my experimental architecture simulator
> that happens to be based on alpha.)  I have been unable to find any
> combination of configure switches that makes this happen.  I should
> probably underline that I am _not_ trying to cross-compile LLVM, I am
> trying to make LLVM _be_ a cross compiler.

What you want is llvm-gcc to be a cross compiler.  llvm can be
compiled natively with no extra flags.  To generate alpha assembly
from a bytecode, you use
llc -march=alpha

llvm and llc depend on the system assembler so to get binaries you
will need a cross platform linker and an alpha assembler.

>  - The "natural" way to do that (by which I mean "the way you would do
> it if you believe what it says in the autoconf manual") would be to
> specify --build=x86_64-unknown-linux --target=alpha-unknown-linux.
> This produces Makefiles that bomb out on the very first file in the
> tree:
>
> $ make
> llvm[1]: Compiling Alarm.cpp for Debug build
> cc1plus: error: unrecognized command line option "-mieee"
> cc1plus: error: unrecognized command line option "-mieee"

LLVM should be compiled as is for your architecture.  It will then be
able to optimize and produce asm for any supported arch (i.e. it is
naturally cross platform).  What you are doing is telling the
Makefiles you are building on an Alpha.

> because Makefile.config has ARCH=Alpha, and Makefile.rules changes the
> options passed to the build compiler based on ARCH.  IMO this is a
> bug, but I don't understand your makefile system well enough to fix
> it.

LLVM is a cross compiler by default, ARCH is the host machine, not the
target machine.


The simplest thing by far is to have a linux alpha system you can
compile code on (rr use M5 in full system simulation mode).  (Note I
haven't built llvm-gcc for a while on alpha, and last I knew it died
in libgcc on some of the math routines, but you can use the native
compiler for those.  The llvm-gcc executable works).

Andrew




More information about the llvm-dev mailing list