CLang Toolchain
Install Latest Version
Add APT Repository (Debian/Ubuntu)
Visit apt.llvm.org to verify the correct repository for your distribution.
Solution with sources-file
Add a source-list file llvm-toolchain.sources to the directory /etc/apt/sources.list.d/.
cat <<EOD | sudo tee /etc/apt/sources.list.d/llvm-toolchain.sources >/dev/null
Types: deb
URIs: http://apt.llvm.org/$(lsb_release -sc)
Suites: llvm-toolchain-$(lsb_release -sc)
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By:
$(wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sed 's/^/ /')
EOD
Solution with list-file
For older distributions not supporting .sources files.
The repository PGP key may already be installed on desktop distributions. If not, use the following commands to add the key and repository:
sudo wget https://apt.llvm.org/llvm-snapshot.gpg.key -O /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo "deb [arch=$(dpkg --print-architecture)] http://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/llvm-toolchain.list
Install LLVM/Clang Packages
After adding the repository, update the package list and install the desired LLVM/Clang packages:
You can install specific versions by appending the version number (e.g., clang-18, clang-19).
Enable Unattended Upgrades
Since LLVM packages receive frequent updates, you can configure unattended upgrades for automatic updates.
Install Unattended Upgrades Package
Install the required package:
Enable it using the following command:
This modifies /etc/apt/apt.conf.d/20auto-upgrades, setting two flags:
Configuration File for LLVM
Get repository information by running:
The result will contain a section similar to:
500 http://apt.llvm.org/jammy llvm-toolchain-jammy/main amd64 Packages
release n=llvm-toolchain-jammy,c=main,b=amd64
origin apt.llvm.org
Create the file /etc/apt/apt.conf.d/51unattended-upgrades-llvm with the following content: