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

Bill Wendling isanbard at gmail.com
Fri Mar 13 18:09:59 PDT 2009


Hi Zack,

On Fri, Mar 13, 2009 at 4: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.
>
>  - 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"
>
> 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 has different back-ends that it generates. These back-ends are
loaded when needed. You select them with the "-march" option of the
"llc" tool. What you're trying to do here is have the LLVM *binaries*
be Alpha binaries. That won't work for you. For instance, the compiler
you're using to compile LLVM doesn't appear to support generating
Alpha binaries.

>  - The other obvious thing to try is not giving any --build or
> --target options but instead --enable-targets=alpha.  This builds
> successfully but produces llvmc and clang binaries that generate code
> for x86_64 by default, and spit out a "unrecognized architecture"
> error if I give -arch=alpha.
>
llvmc will wrap around the llvm-gcc executable. If your built llvm-gcc
doesn't allow the "-arch" flag, then that would be the reason. I don't
think that the shipped llvm-gcc supports Alpha. I don't use "llvmc",
though, so I'm not sure how to help you with this.

> I have some other, closely-related questions:
>
>  - I assume I need a cross-assembler and -linker.  Will GNU binutils
> in cross-architecture mode work for that?  How do I persuade it to use
> them?  It seems to be setting itself up to feed Alpha code to "as"
> instead of "<target-triplet>-as" which isn't going to work.

You are going to have to build llvm-gcc as a cross-compiler so that
you can get the features you are wanting here. By default, llvm-gcc is
built for the host platform, so there are no need for such
<target-triplet> drivers.

-bw

>  - Does clang have the necessary code to support Alpha?  I noticed
> some very architecture-specific-looking code in there, to do with
> calling conventions; I'm basically going to have to write that from
> scratch for my modified architecture anyway but it would be nice to
> know for sure whether it already had the baseline support.  (I'm
> avoiding llvm-gcc because I know from extensive prior experience with
> GCC that it almost certainly cannot handle the semantics of my
> modifications at all.)
>




More information about the llvm-dev mailing list