This approach uses update-alternatives to manage GCC and LLVM/CLANG C/C++ compiler toolchains.
Although tested on Linux Mint 18.3, this approach should work on any Debian based distro or for that matter any Linux distro with update-alternatives support, provided the packages are installed correctly.
There are 3 files
gcc-alternatives.shinstalls GCC versions 5/6/7 and sets up alternatives forgcc/g++/cpp/gfortran.llvm-clang-alternatives.shinstalls LLVM and CLANG versions 4/5 and sets up alternatives for various LLVM and CLANG programs includingclangandclang++.cc-alternatives.shsets up alternatives for thecc,cxx, and theldcommands. This script can be used to change systemwide default compiler/linker combination to either GCC or CLANG.
Once these scripts are run you can change the system GCC/CLANG versions by running sudo update-alternatives --config gcc|clang. To change the default compiler/linker combo used by t