Skip to main content

Build LLVM

Download#

sudo apt update \
&& sudo apt install -y cmake gcc git ninja-build python3
git clone --branch=llvmorg-11.1.0 --depth=1 \
https://github.com/llvm/llvm-project.git $HOME/llvm-project

LLVM#

cd $HOME/llvm-project/
cmake -G Ninja \
-S llvm \
-B build_llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/toolchain/clang/11 \
-DLLVM_ENABLE_PROJECTS=clang;lld
cmake --build build_llvm
sudo cmake --install build_llvm

link#

sudo update-alternatives \
--install /usr/bin/clang clang /opt/toolchain/clang/11/bin/clang 11 \
--slave /usr/bin/clang++ clang++ /opt/toolchain/clang/11/bin/clang++
update-alternatives --display clang

Reference#

Last updated on