Kernel compiled in clang, not gcc..why not make clang default?

Is there a reason we compile kernel by default in gcc? I, for example, am forced to compile fedora kernel now in clang because the crucial kernel security feature “Layout randomization” is since recent kernel versions been moved to a native clang feature. So I just edit the kernel.spec file…is there a niftier way to select compilation engine, by the way?

So, the question is, are there any only gcc compiler features that warrant use of gcc versus clang by default? Maybe some architectures only available for gcc? But those would be obscure enough to justify making clang the default compiler?

Clang has very cool features too…like sanitizers, control flow integrity…etc

Ok, beautiful. Fedora’s kernel package has two flags to compile using clang instead of gcc.

First, make -j 128 LLVM=1 nconfig - this will let you select clang-specific options like turn on CFI, LTO,randomize structure - so many cool things. Important step since that’s the whole point of using clang. [Do not use sanitizers, those are for development purposes].

And then compile kernel normally using fedpkg and the two clang flags added.

***Does anyone here use clang to compile their kernels???

Clang or gcc?
  • clang
  • gcc
0 voters