Last active
August 25, 2021 21:38
-
-
Save LeeiFrankJaw/356090e4d5a703594a09eae513396e50 to your computer and use it in GitHub Desktop.
Install Clang on Ubuuntu LTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install Clang 8 on Ubuuntu 18.04.2 LTS | |
# Turn on errexit. | |
set -e | |
# You do not need to add new repository to the source list since the | |
# llvm toolchain now can be found on the bionic bionic-updates | |
# universe repositories. | |
# Install the main components. | |
sudo apt install clang-8 lldb-8 lld-8 clang-tools-8 | |
# Create symbolic links. | |
cd /usr/bin/ | |
for i in clang{,++,-cpp}-8; do | |
sudo ln -sf $i ${i::-2} | |
done | |
for i in lld{,-link}-8; do | |
sudo ln -sf $i ${i::-2} | |
done | |
sudo ln -sf ld.lld-8 ld.lld | |
for i in lldb{,-argdumper,-mi,-server}-8; do | |
sudo ln -sf $i ${i::-2} | |
done | |
# Set the default compiler cc to clang using alternatives mechanism. | |
sudo update-alternatives \ | |
--install /usr/bin/cc cc /usr/bin/clang 30 \ | |
--slave /usr/share/man/man1/cc.1.gz cc.1.gz /usr/share/man/man1/clang-8.1.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install Clang 5 on Ubuuntu 16.04.3 LTS | |
# Turn on errexit. | |
set -e | |
# Add the llvm repository to the source list. | |
sudo tee /etc/apt/sources.list.d/llvm-toolchain-xenial.list <<HERE | |
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main | |
# deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main | |
HERE | |
# Add the llvm key to the list of trusted keys. | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | |
# Resynchronize the package index from sources. | |
sudo apt update | |
# Install the main components. | |
sudo apt install clang-5.0 lldb-5.0 lld-5.0 clang-tools-5.0 | |
# Create symbolic links. | |
cd /usr/bin/ | |
for i in clang{,++,-cpp}-5.0; do | |
sudo ln -s $i ${i::-4} | |
done | |
for i in lld{,-link}-5.0; do | |
sudo ln -s $i ${i::-4} | |
done | |
sudo ln -s ld.lld-5.0 ld.lld | |
for i in lldb{,-argdumper,-mi,-server}-5.0; do | |
sudo ln -s $i ${i::-4} | |
done | |
# Set the default compiler cc to clang using alternatives mechanism. | |
sudo update-alternatives \ | |
--install /usr/bin/cc cc /usr/bin/clang 10 \ | |
--slave /usr/share/man/man1/cc.1.gz cc.1.gz /usr/share/man/man1/clang-5.0.1.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment