[LLVMdev] Sparc back end problem

dalej dalej at apple.com
Mon Nov 15 13:27:30 PST 2010


Since your first step is a 64-bit environment, size_t is understood to be 64 bits and the result of sizeof is passed that way, which doesn't match your eventual target environment.  You can see this in the generated IR (use llvm-dis).  You'll get farther if you use a 32-bit environment as your first step (-m32 works some places), but you'll still have problems because of incompatibilities in the calling convention between x86-32 and Sparc.  I recommend trying harder to compile llvm-gcc.

On Nov 15, 2010, at 12:46 PM, Timothy M Jones wrote:

> Hi everyone,
> 
> I'm trying to make a cross-compiler based on llvm to target sparc (solaris) from x86_64 (linux).  I couldn't compile llvm-gcc on my system so have to use the precompiled binaries from the website, but already have a gcc cross-compiler so can use this.  So far, my compilation steps are these:
> 
> 1) Preprocess the (C) sources using gcc cross-compiler
> 2) Use llvm-gcc to transform to llvm IR
> 3) Run llc to emit sparc assembly
> 4) Assemble and link using gcc cross-compiler
> 
> This works for a simple 'Hello World' program, but I'm getting problems when trying more complicated things.  One thing in particular is with a simple printf that I want to write that prints out the size of an integer.  I've attached an example program source, preprocessed source, llvm code and assembly.  Instead of printing 'Value is 4' I get 'Value is 0'!  I don't know sparc assembly at all, but a quick scan over the code shows that the value '4' is definitely used in an instruction near the printf call.  Anyone know why this isn't working or point out where I'm going wrong?  I'm using llvm 2.8.
> 
> Cheers
> Tim
> 
> 
> -- 
> Timothy M. Jones
> http://homepages.inf.ed.ac.uk/tjones1
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> <test-printf.bc><test-printf.c><test-printf.i><test-printf.s>_______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list