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. I was able to successfully compile and run the hello world program using LLVM. I then made a simple spec config file to try to compile spec with LLVM: ext=ppc32_llvm teeout=yes teerunout=yes; default=default=default=default: # 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? 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. 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. Looks like a really interesting project! Thanks in advance! Patrick
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/
> > 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.Thanks! Grabbed the latest from CVS and added that linker option to the config file. It looks like it compiles and runs the SPEC tests ok now. Just to make sure I understand how LLVM works, got a few clarifications: 1. The ppc code I'm generating with the -native-cbe is static, correct? 2. Is there a frontend to any of the other gnu compiler collection stuff? Eg g77 or something for compiling fortran code or is c/c++ the focus right now? 3. Does the code that uses the JIT compiler (I know, doesn't currently exist on ppc) currently take advantage of run-time optimization? If I ran the SPEC suite with a JIT compiled version several times, would I except the score to eventually increase at all, depending on what the benchmark does?> > 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. >I only know just enough about compilers to be dangerous, but I'm working on learning more :). If no one else is currently working on this, what would be needed in order to get the JIT compiler up and running on ppc/os x? Is it just a matter of taking some tree/rtl form stuff and emitting ppc code instead of x86 code? Is there code that needs to be ported to os x so it can profile itself? Patrick