- centos 7 安装前置依赖
sudo yum install git python-devel libffi-devel graphviz-devel elfutils-libelf-devel readline-devel libedit-devel libxml2-devel protobuf-devel gtext-devel doxygen swig
sudo yum install -y centos-release-scl scl-utils-build
sudo yum install -y devtoolset-9
source /opt/rh/devtoolset-9/enable
export CC=/opt/rh/devtoolset-9/root/bin/gcc
export CXX=/opt/rh/devtoolset-9/root/bin/g++
wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz
tar xzvf cmake-3.20.0.tar.gz
cd cmake-3.20.0
./bootstrap --prefix=/usr/local
make -j8
sudo make install
- ubuntu 18.04+ 安装前置依赖
sudo apt install git build-essential cmake python3-dev libncurses5-dev libxml2-dev libedit-dev swig doxygen graphviz xz-utils
- 下载&编译
git clone git@github.com:llvm/llvm-project.git -b release/11.x
cd llvm-project && mkdir build && cd build
cmake -G "Unix Makefiles" ../llvm -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DLLVM_ENABLE_PROJECTS=clang; -DLLVM_TARGETS_TO_BUILD="AArch64;X86;"
make -j8
sudo make install
如果只要编译clang,在cmake命令添加定义 -DLLVM_ENABLE_PROJECTS=clang;
LLVM_ENABLE_PROJECTS
可用的项目有clang;clang-tools-extra;compiler-rt;debuginfo-tests;libc;libclc;libcxx;libcxxabi;libunwind;lld;lldb;mlir;openmp;parallel-libs;polly;pstl
例如LLVM_ENABLE_PROJECTS=clang;clang-tools-extra;libc;libclc;libcxx;libcxxabi;lld;lldb;
默认会编译所有平台,可以通过LLVM_TARGETS_TO_BUILD
指定平台,可用平台有AArch64, AMDGPU, ARM, BPF, Hexagon, Mips, MSP430, NVPTX, PowerPC, Sparc, SystemZ, X86, XCore