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.
Pretty much my opinion aswell, if Clang/LLVM fixed to work with the Linux kernel without the Linux kernel having to lose any features/performance, then I'm sure they are happy to use it alongside GCC.
Originally Posted by droidhacker
The reason the FreeBSD switched was a licence-politically driven issue as they would not accept distributing GPLv3 licenced software as part of the base distribution and therefore was stuck shipping age old GCC 4.2, and also that they have a official goal of not having GPL licenced code in their base system.
Due to this FreeBSD invested the quite long time it took of getting FreeBSD to compile under Clang/LLVM.
The Linux devs however has no such licence-political agenda to drive support for Clang/LLVM, and as you said it then comes down to purely practical advantages, of which there currently really aren't any, atleast not enough to warrant making changes to the Linux kernel which may result in less performance and overall less control over the generated code.
There's a lot of thoughtlessness in the comments above.
This is not only about Linux. Yes, Linux can compile under gcc, and if everyone in Linuxland is happy with that, fine.
But this is also about LLVM. It helps make LLVM a better set of tools (better compiler/linker etc, better analyzer of logic faults, memory mishandling, lock failures, etc) to have it tested against an ever wider and larger set of targets; and Linux is, of course an extremely challenging target. It's interesting to hear how LLVM is progressing on this front purely as general news about LLVM, regardless of whether it ever will, or will not, become the official Linux build tool.