LLVM/Clang Is Advancing To Build The Linux Kernel
Phoronix: LLVM/Clang Is Advancing To Build The Linux Kernel
Going back years there's been work to build the Linux kernel with LLVM's Clang compiler rather than GCC. It's taken a lot of work by many individuals and organizations, but it's becoming an easier task to accomplish for multiple architectures. Here's where the Clang'ed Linux kernel is at today...
Various departments in Microsoft has been toying around Clang/LLVM internally for some time. GCC, too. There have been attempts to build Windows itself with both compilers for various reasons (testing, competition evaluation, bored employees, etc.). This is the first I heard of anyone at Microsoft potentially integrating it into any kind of thing which might turn into an actual product, though. It's really, really not surprising that a corporation of ~150,000 employees (~90,000 full-time) has some teams using Linux, Clang, or other FOSS projects. Especially if you consider the intake of younger programmers with more exposure to FOSS than some of the old Microsoft hats and the various OSS-friendly initiatives out of Microsoft in the last decade or so. The infamous "Halloween Documents" happened a CEO ago (soon two CEOs ago) and 15 years ago and without nearly every new college hire having at least some modicum of Linux/FOSS exposure.
The Sparc JIT has been worked on recently as well which is quite exciting ... I need to test that out on my T2000, SparcStation 20 and SparcStation LX
This article is fuzzy to say the least, he states that the necessary patches in Clang/LLVM are done, while stating that they need patches for the Linux kernel to rewrite code which relies on GCC compiler extensions.
First off, the reason the Linux kernel relies so heavily on compiler extensions is because they want the added control over the code generation that it gives, often for performance reasons.
Further more, many if not most of the compiler extensions the Linux kernel uses are the direct result of Linux kernel developer requests towards GCC, in other words they exist in GCC because the Linux developers requested them.
So how big is the chance that the Linux kernel devs will apply these patches which removes the use of compiler extensions they requested in the first place? Unlikely I say, particularly with their focus on performance.
No wonder this project is basically on the same state it has been these past three years or so, again I don't see the Linux kernel devs opting to sacrify code generation control and likely performance in order to get Clang/LLVM to be able to compile the kernel. The 'LLVMLinux project' would be better off trying to get the missing extensions supported by LLVM/Clang instead, unless they have been trying to do this and have been absolutely denied.
So the claim that the 'necessary' patches to compile Linux has landed in Clang/LLVM is bogus, if the necessary patches had landed then you wouldn't need to patch the Linux kernel to compile.
I...partially agree. Yes, the devs requested the GCC-specific features IN THE PAST. But who knows when that was. They may not be necessary anymore, there may be other ways to do them more properly, or-- since we hitting a point of "Shit we need to look at multiple compilers now, not just GCC.." maybe those sections will be redone in a standards-compliant way so that in the future we can test multiple compilers more efficiently.
Originally Posted by XorEaxEax
If the extensions in question weren't necessary anymore (as in the kernel developers want to keep them) then these patches would have been accepted ages ago as I see it.
Originally Posted by Ericg
As this project is still basically in the same situation as it has been the last three or so years since it started (or was it further back?) indicate to me that the kernel developers have no interest in applying this patches to mainline.
The whole 'advancing' seems to be little more than Michael's usual Clang/LLVM propaganda (he even tried to spice the lack of concrete progress in this article by mentioning Microsoft experimenting with LLVM).
Also is the resulting kernel stable these days? Last time this was reported on the resulting kernel (after patching to be able to build at all) was crash prone and not fit for any kind of production use.
I don't really see why the Linux kernel devs would feel any 'shit we need to look at multiple compilers'?
Originally Posted by Ericg
The big thing LLVM brings to the open source ecosystem is JIT compilation which is something the Linux kernel has no need of, further more the GCC compiler supports way more platforms than Clang/LLVM so there's nothing to gain there either.
Then we have GCC generating better performant code, PLUS the fact that it supports all the compiler extensions that the Linux kernel developers have requested.
Now if Clang/LLVM were to add support for these missing compiler extensions then I'm sure the Linux devs would gladly use it alongside GCC for testing purposes.
But as it stands it seems they won't be added to Clang/LLVM and it seems the Linux developers have no interest in removing said extensions, again as proven by the LLVMLinux project basically remaining on status quo after all this time.
Probably the reason that this isn't going anywhere is that it doesn't actually solve any tangible problems. Unless someone can demonstrate that something is dramatically BETTER using llvm/clang to compile the kernel, there is really no reason to waste energy on it.
And frankly, llvm/clang isn't suitable for the kernel, because it is an unstable mess. If you don't believe me, just try building current mesa/radeonsi on llvm/clang from just a few months ago. Can't do it.