So gcc-*-version stuff uses tc-getCPP to find the preprocessor to get the version from, and tc-getCPP relies on CPP being set. However, it is common to set CC and CXX without setting CPP (in fact, setting CPP breaks some programs...). As a result, gcc version functions return version of active gcc while another version is actually being used. Please either make version getters use CC/CXX (i.e. the thing actually used to compile stuff), or make tc-getCPP default to something like "$CC -E" when CPP is not set explicitly.
Note that clang's prepocessor will report as gcc version 4.2.1 to enable compatibility code paths in glibc. Many ebuilds currently in gentoo have checks that abort if it detects recent enough gcc versions, for example the widely used kde4-base_pkg_setup() from kde4-base.eclass will die if it detect gcc versions prior to 4.6 without considering clang. In these cases, the packages/eclasses are clearly at fault, but fixing tc-getCPP() now will expose this issue to any clang users.
eroen, I've sent new set of patches that also introduce helpful checks for gcc & clang to be used in ebuilds.
(In reply to eroen from comment #1) > Many ebuilds currently in gentoo have checks that abort if it detects recent > enough gcc versions, for example the widely used kde4-base_pkg_setup() from > kde4-base.eclass will die if it detect gcc versions prior to 4.6 without > considering clang. I'm currently running into this with webkit-gtk. I need to use clang because gcc eats all my memory and then fails. I wonder why one wants to limit itself to a certain version of a compiler. The only reason I can think of is support for certain language features or a minimum required c[++]-standard. Wouldn't it be better to directly support checks for those checks?
Yes, it would be better. However, there's really no need to check for c++11 as sufficiently new gcc versions support it.
In case of clang + C++ things might be trickier: clang doesn't ship a libstdc++/STL but it uses the one from gcc (as long as sys-libs/libcxx isn't installed and configured to be used). I don't know if it is possible with the current implementation to check for a given gcc version even if CC/CXX is set to clang*. If the package relies on c++-lib specific features (and not only on language-stuff) we definitely should also check the gcc-version.
Add to that the fact that at runtime we are using the newest libstdc++ installed (i.e. not gcc-config), and GNU people don't care the slightest bit about ABI stability.
This is done for a while now.