Verbose Logging

software development with some really amazing hair

T + G I F R

Compile LLVM On Ubuntu

· · Posted in Programming
Tagged with

I needed to compile LLVM from scratch since the llvmruby gem needs it compiled with position independent code and the repo version doesn't seem to be, the gem whines compiling, etc, etc.

The docs for LLVM don't seem to be that great when it comes to compiling this stuff from scratch, so here's what I did, as one big script chunk. You can probably copy and paste this, but I make no promises that it will work, only that it Works on My Machine.

cd; mkdir llvm; cd llvm
unset LD_LIBRARY_PATH
unset LIBRARY_PATH
unset C_INCLUDE_PATH
wget http://llvm.org/releases/2.5/llvm-gcc-4.2-2.5.source.tar.gz
wget http://llvm.org/releases/2.5/llvm-2.5.tar.gz
tar zxf llvm-2.5.tar.gz
tar zxf llvm-gcc-4.2-2.5.source.tar.gz
cd llvm-2.5
./configure --prefix=$HOME/local/llvm --enable-pic
make -j3 # alter to suite your system, usually 1 + number of cores
make install
cd ../llvm-gcc4.2-2.5.source
./configure --prefix=$HOME/local/llvm-gcc --enable-languages=c,c++ --program-prefix=llvm- --enable-llvm=$HOME/local/llvm
make -j3 all
make install
cd ~/local/llvm-gcc/bin
./llvm-gcc -v
view raw setup.sh hosted with ❤ by GitHub

And that should output something like

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/home/darkhelmet/local/llvm-gcc --enable-languages=c,c++ --program-prefix=llvm- --enable-llvm=/home/darkhelmet/local/llvm
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5636) (LLVM build)
view raw output.txt hosted with ❤ by GitHub

The last part about the LLVM build is the important part. It still doesn't quite work with llvmruby, but maybe it's because I used the 2.5 version and the llvmruby page says 2.4. Just something else…

LLVM is up and running though, so happy LLVM'ing!