Currently, GCC toolchain can only be set via the option --gcc-toolchain. On
many HPC clusters, like Summit, because of its old system, the default GCC is
4.8.5. Users usually use module load gcc/$(version) to load another GCC.
However, the module package manager can only set some environment variables like
PATH, it cannot control Clang's GCC toolchain. As a result, no matter which
GCC users are using, it always ends up with the system version. What's more,
sometimes it's not easy to pass the option to the build system.
I did talk to some LLVM users about this problem. Some of them thought LLVM
works purely w/o GCC, and many thought Clang can select the right GCC they are
setting. I also saw an "issue" on GitHub about failing to compile OpenMP source
code using LLVM after a patch that set default C++ version to C++14, and it is
actually because the user compiled LLVM with GCC 6.4.0, and then set clang and
clang++ as the default compiler to compile OpenMP. Since the user was using a
cluster with CentOS 7 whose default GCC is 4.8.5, and GCC 4.8.5 does not fully
support C++14, the problem occurred.
This patch added the support for setting GCC toolchain via an environment
variable GCC_TOOLCHAIN. It will be read if --gcc-toolchain is not set. In
this way, as long as those package managers set the environment variable when
loading different versions of GCC, Clang can also pick up the right version.