Skip to content

Instantly share code, notes, and snippets.

@qrealka
Forked from ArseniyShestakov/add.sh
Created October 26, 2020 19:50
Show Gist options
  • Save qrealka/34b5e1aeb92d1bb0c54c5d54fad8a993 to your computer and use it in GitHub Desktop.
Save qrealka/34b5e1aeb92d1bb0c54c5d54fad8a993 to your computer and use it in GitHub Desktop.
My compiler alternatives
# Cleanup old alternatives
update-alternatives --remove-all cc
update-alternatives --remove-all c++
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --remove-all clang
update-alternatives --remove-all clang++
update-alternatives --remove-all icc
update-alternatives --remove-all icc++
# Add GCC versions
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 10
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 10
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 30
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 30
# Add Clang versions
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.7 10
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.7 10
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 20
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang-3.8 20
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-4.0 30
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-4.0 30
# Add ICC versions
update-alternatives --install /usr/bin/icc icc /opt/intel/compilers_and_libraries/linux/bin/intel64/icc 10
update-alternatives --install /usr/bin/icc++ icc++ /opt/intel/compilers_and_libraries/linux/bin/intel64/icpc 10
# Add compilers
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 40
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 40
update-alternatives --install /usr/bin/cc cc /usr/bin/icc 50
update-alternatives --install /usr/bin/c++ c++ /usr/bin/icc++ 50
update-alternatives --set cc /usr/bin/gcc
update-alternatives --set c++ /usr/bin/g++
update-alternatives --set cc /usr/bin/clang
update-alternatives --set c++ /usr/bin/clang++
update-alternatives --set cc /usr/bin/icc
update-alternatives --set c++ /usr/bin/icc++
# Remove existing
update-alternatives --remove-all ld
update-alternatives --remove-all ld.intel
# Add Icc linker
update-alternatives --install /usr/bin/ld.intel ld.intel /opt/intel/compilers_and_libraries/linux/bin/intel64/xild 10
# Add all linkers
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.bfd 10
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 20
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.intel 30
# Choose one
update-alternatives --set ld /usr/bin/ld.bfd
update-alternatives --set ld /usr/bin/ld.gold
update-alternatives --set ld /usr/bin/ld.intel
# GCC
update-alternatives --set gcc /usr/bin/gcc-4.9
update-alternatives --set g++ /usr/bin/g++-4.9
update-alternatives --set gcc /usr/bin/gcc-5
update-alternatives --set g++ /usr/bin/g++-5
update-alternatives --set gcc /usr/bin/gcc-6
update-alternatives --set g++ /usr/bin/g++-6
# Clang
update-alternatives --set clang /usr/bin/clang-4.0
update-alternatives --set clang++ /usr/bin/clang++-4.0
# Icc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment