Copied from https://jdhao.github.io/2021/07/03/install_clangd_on_linux/ because sometimes good things disappear from the 'net.
git clone --depth=1 https://github.com/llvm/llvm-project.git
mkdir build && cd build
cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_INSTALL_PREFIX=~/tools/llvm -DCMAKE_BUILD_TYPE=Release ../llvm
make -j 16
Some explanation about the options used:
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra": it specifies which targets we want to build. To use
clang-tools-extrais a must.
-DCMAKE_INSTALL_PREFIX=~/tools/llvm: it specifies where we want to install llvm, in this case, we install it under
-DCMAKE_BUILD_TYPE=Release: it specifies the build type.
Releasetype will be smaller than
For more details about Cmake options on building llvm, check here.
I need this because the work VMs use RHEL7 with no chance to upgrade (the project is built on this to support customers running RHEL7 and up), and I want to config neovim lsp with cpp support.
But wait there's more. This version of LLVM needs cmake 3.20 or higher and of course the VM only has cmake 2.8
- visit cmake.org/download and wget the source
And now GCC needs to be version 7.4 or newer, but the VM is running 4.8.5. Sigh.