http://llvm.org/docs/GettingStarted.html
一、下载安装 cmake >=3.4.3
yum install gcc gcc-c++
curl -O http://www.cmake.org/files/v3.9/cmake-3.9.2.tar.gz
## git clone https://github.com/Kitware/CMake.git ##cmake 官网下载会很慢,可以考虑从 gitbub 上拉取源码
export PATH=$PATH:/opt/cmake/bin
tar -xf cmake-3.9..tar.gz
cd cmake-3.9.
./bootstrap --prefix=/opt/cmake
make && make install
二、下载 llvm 源码(可选,YCM 会自动下载通用库)
cd /tmp
for x in "http://releases.llvm.org/4.0.0/llvm-4.0.0.src.tar.xz
http://releases.llvm.org/4.0.0/cfe-4.0.0.src.tar.xz
http://releases.llvm.org/4.0.0/compiler-rt-4.0.0.src.tar.xz
http://releases.llvm.org/4.0.0/clang-tools-extra-4.0.0.src.tar.xz
http://releases.llvm.org/4.0.0/libcxx-4.0.0.src.tar.xz
http://releases.llvm.org/4.0.0/libcxxabi-4.0.0.src.tar.xz"; do
wget $x
done cd $HOME
mkdir llvm_source && cd llvm_source
tar -xf /tmp/llvm-4.0.0.src.tar.xz
mv llvm-4.0.0.src llvm
cd llvm/tools
tar -xf /tmp/cfe-4.0.0.src.tar.xz
mv cfe-4.0.0.src clang
cd clang/tools
tar -xf /tmp/clang-tools-extra-4.0.0.src.tar.xz
mv clang-tools-extra-4.0.0.src clang-tools-extra
cd ../../../projects
tar -xf /tmp/compiler-rt-4.0.0.src.tar.xz
mv compiler-rt-4.0.0.src compiler-rt
tar -xf /tmp/libcxx-4.0.0.src.tar.xz
mv libcxx-4.0.0.src libcxx
tar -xf /tmp/libcxxabi-4.0.0.src.tar.xz
mv libcxxabi-4.0.0.src libcxxabi
三、编译/安装
mkdir llvm_build && cd llvm_build
cmake -G "Unix Makefiles" \
-D CMAKE_BUILD_TYPE=Release \
-D LLVM_TARGETS_TO_BUILD=host \
-D CMAKE_INSTALL_PREFIX=/opt/llvm \
. \
../llvm
make && make install
tips:
CentOS 6 升级 gcc-4.8
https://www.cnblogs.com/imzye/p/6216482.html