[LLVMdev] Testing LLVM on OS X

Chris Lattner sabre at nondot.org
Mon Apr 26 09:14:02 PDT 2004


On Fri, 23 Apr 2004, Patrick Flanagan wrote:

> I'm interested in getting LLVM running on OS X so I can play around
> with it and check it out. I downloaded the LLVM 1.2 package and
> compiled and installed with no errors (used config options
> --with-llvmgccidr and --enable-spec2000 pointing to the relevant
> directories). I want to look at performance of SPEC CPU2000 with LLVM
> vs gcc.

Great!

> CC=/Users/patrick/Desktop/LLVM/cfrontend/ppc/llvm-gcc/bin/gcc
> CXX=/Users/patrick/Desktop/LLVM/cfrontend/ppc/llvm-gcc/bin/llvmg++
> FC=g77
> OPTIMIZE   = -O3 -fomit-frame-pointer
>
> To test that everything was setup correctly, I tried doing just the
> 164.gzip test first. It seemed to build the gzip test without errors,
> but when it tried to run it, it said that it couldn't find the bytecode
> file for that program. I looked at the files generated from the build,
> and there's a script that calls lli and passes it a bc file, but sure
> enough the .bc file is not there. I realize this is sort of a spec
> question rather than a LLVM question, but where would it put that .bc
> file and where do I need to copy that file to in order for it to work?

The problem is that LLVM only compiles to .bc files by default.  This
means that when you say:
  llvmgcc hello.c -o hello

You get a hello.bc file and hello "executable", which is really just a
shell script that runs the bytecode file with 'lli'.

There are two problems with this: 1) there is no JIT for PPC yet, so
LLVM will use the interpreter (which is intolerably slow and has other
issues).   2) Spec compiles the executables in one place and them moves
them to another, but it only copies the shell script and not the
bytecode file, so you get that error message.

The normal solution to this problem is to link with the llvmgcc
'-Wl,-native' option.  This tells llvmgcc to produce a native executable
instead of a shell script, using a PPC backend.  I'm sure you immediately
see the problem with this.  :)

The real solution to your problem is in CVS.  There llvmgcc supports a
-Wl,-native-cbe option which will use the C backend to create a native
executable for you, and can actually be used to run SPEC successfully.
If you're willing to grab LLVM CVS (details here:
http://llvm.cs.uiuc.edu/docs/GettingStarted.html#checkout ), this is the
best bet.

> Second, according to the documentation, the OS X version of LLVM
> doesn't generate native code and is run through the interpreter. I
> assume this would make it a lot slower than if it did generate native
> code.

Yes, by a factor of 1000 or so.  :)

> Is anyone currently working on making it generate native ppc code for OS
> X? If not, what would be involved in doing so? I'm new to LLVM, I'd
> appreciate some pointers to some info that might shed some light on
> that.

There was a group that started working on this, but I believe they got
stalled and are no longer working on it.  It will try to get in touch with
them to see where things stand, then get back to you on this.

> Looks like a really interesting project! Thanks in advance!

Thanks!  Sorry for the delayed response, I experienced an email avalanche
and your mail got buried.  :)

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list