Setup LLVM+Clang

  1. go to http://clang.llvm.org, download latest source: llvm, clang, compiler-rt
  2. extract 3 packages, put clang and compiler-rt inside llvm
  3. build the bundle
  4. install binary
  5. install clang python binding
mkdir -p ~/pkg/llvm # make root of llvm-bundle
cd ~/pkg/llvm
tar --strip-components=1 \
     -xJf ~/Downloads/llvm-3.8.0.src.tar.xz
mkdir -p tools/clang # extract clang here
tar --strip-components=1 -C tools/clang \
     -xJf ~/Downloads/cfe-3.8.0.src.tar.xz
mkdir -p projects/compiler-rt
tar --strip-components=1 -C projects/compiler-rt \
     -xJf ~/Downloads/compiler-rt-3.8.0.src.tar.xz
du -s tools/clang projects/compiler-rt .
600340  tools/clang
122568  projects/compiler-rt
3467256 .


# shadow building: direct building is not supported
mkdir ../llvm.build
cd ../llvm.build
# default build type is Debug
cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../llvm
script build.log
time make
^D

du -s bin include lib .
478136  bin
8464    include
717108  lib
273488  .

tail build.log

real    86m26.808s
user    80m30.736s
sys     5m2.292s


# install bin/include/lib to /usr/local
sudo make install
# include clang python bindings
cd ../llvm
cp -r tools/clang/bindings/python/clang \
        /usr/lib/python2.7/dist-packages

Advertisements