Linux – How are GCC versions chosen for compiling the linux kernel

gcclinux-kernel

I know that the linux kernel specifies minimal compilation requirements, but I haven't found any source of information regarding how distros/vendors choose which version of GCC to use when compiling the linux kernel.

For example how do Debian maintainers decide which version of GCC to use? Or how do mobile chipset vendors such as Qualcomm or Samsung choose when building Linux for a chipset that supports Android?

Best Answer

I'm not a kernel developer, and don't have an authoritative answer, but here's my take on this:

  • New distributions are likely to incorporate the latest stable GCC version available, since it usually provides the most value (in terms of language support, features, diagnostics and optimizations).
  • Maintainers are likely to use the distribution default GCC for building packages, which is to the best interest of the distribution since it's provides uniformity and stability (all use the same, tried and tested default GCC version).
  • Chip vendors will usually rely on their properitary or ported GCC compilers. It doesn't make sense to maintain more than one compiler in-house (effort and cost wise), and the same compiler is probably used by the customers of the chip vendors (SoC vendors, or software houses that build S/W for these chips), so it's the best interest of the company to use the highest GCC version supported by the kernel.
  • Compilers are backward compatible, and very rarely GCC would introduce a breaking interface change (leave aside ABI changes such as C++98 to C++11), so it is almost always desirable to use the latest compiler version available. However, there are compiler bugs, too, and newer compiler versions may introduce performance regressions, so upgrading the compiler version may be a big thing and could cause companies to advance their GCC version in a very slow pace (and for chip vendors developing their own compilers, very costly too).

To summarize my two cents: I think Linux maintainers will tend to use the distribution default GCC version, while chip vendors will tend to use the latest GCC version available supporting their target (and that plays well with other components of their system, such as drivers). Hope this makes sense.

On the same issue, I came across this very interesting article from Linux Journal, on the decision making behind which GCC version to use for the kernel, which is well worth a read:
Minimum GCC Version Likely to Jump from 3.2 to 4.8

Related Question