Assuming you've downloaded version 15.0.6, for example, and your filename resembles clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz
then a couple more steps are needed.
You will need XZ decompression binaries and a compatible tar
CLI which supports decompression using it (otherwise operate them on multiple successive commands by first decompressing then unwinding the tape archive).
The command to do this is: tar -x --xz --strip-components=1 -f clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz
You should see these directories:
# Assume this is at /home/user/.local/llvm-15
.
├── bin
├── include
├── lib
├── libexec
└── share
Now any Clang++ invocations you'll make will require -I /home/user/.local/llvm-15
. For example:
clang++ -c -o ./some_llvm_ext.o ./some_llvm_ext.cc -I /home/user/.local/llvm-15/include -std=c++20 -fno-exceptions -D_GNU_SOURCE
Additionally, you need to configure the LD_LIBRARY_PATH to point to your new lib directory. While you can temporarily export a new value, it's worth checking to see if it's blank otherwise you'll have this wonky colon+space thing at the end.
# For BASH / ZSH / SH
export LD_LIBRARY_PATH="$HOME/.local/llvm-15/lib:$LD_LIBRARY_PATH"
# For FISH
# Note: Some FISH configurations will require `set -gx` depending on the context.
set -x LD_LIBRARY_PATH $HOME/.local/llvm-15/lib $LD_LIBRARY_PATH
Finally, to permanently use this new gem of LLVM, explore how to use update-alternatives
on Debian based distributions. Likewise read the documentation or explore article tutorials regarding /etc/ld.so.conf
and any files sourced beneath /etc/ld.so.conf.d/
.
Last, but most importantly, fix your PATH
variable to prioritize /home/user/.local/llvm-15/bin
over all others.