git clone
cd llvm-project
git checkout remotes/origin/release/13.x
mkdir build && cd build
cmake ../llvm -DCMAKE_INSTALL_PREFIX=$HOME/llvm-13
cmake --build . --target install

I’m compiling LLVM for use with inkwell which relies on the LLVM_SYS_130_PREFIX env variable to find llvm (for llvm 13 of course, it’s different for other versions more here).

After installing modify your shell to set this variable to $HOME/llvm-13 or wherever you want llvm (modify the cmake DCMAKE_INSTALL_PREFIX flag as well).

If you want a version other than 13 run git branch -a for a list of remote branches.

You can also find official instructions here: