Re: Will Arch Linux going to change the default compiler to Clang?

bangkok_manouel wrote:

some distributions will use Clang for compiling kernel

[citation needed]

AFAIK, only FreeBSD is moving to clang. There's a blurb on Wikipedia that Debian has managed to compile something like 90% of their packages, but I can't seem to find anything else that hints there are Linux distributions planning on making the switch. I think the recent news from FreeBSD may have caused confusion and/or assumptions.

Re: Will Arch Linux going to change the default compiler to Clang?

bangkok_manouel wrote:

some distributions will use Clang for compiling kernel

[citation needed]

Sorry, this is my mistake. I thought so because Clang is going to replace the GCC, and FreeBSD (not Linux) is going to use CLang, and Debian has a report mentioned compiling the archive using CLang, and an article said using Clang to build linux kernel.

Re: Will Arch Linux going to change the default compiler to Clang?

In addition, clang is heavily pushed by Apple. In the long term, due to its license (not GNU) such company could potentially fork the project and continue supporting only his private branch, leaving alone the clang community. All the important companies like a lot having their own compiler. This wouldn't be possible at all with gcc. Of course, this conspiration theory is entirely my personal (and probably many others) point of view. The GNU license is much more open-source friendly, and this is essential for a tool building the entire system.

Re: Will Arch Linux going to change the default compiler to Clang?

The main reason FreeBSD is changing to Clang/LLVM was that they were stuck at a very old GCC 4.2 due to them not accepting GPLv3 (GCC 4.2 was the last GPLv2 licenced GCC), a secondary reason would be that Clang/LLVM is permissively licenced like BSD and thus is more in line with their philosphy. In practice the transition has not been easy as it's been in progress for a long time and has required lots of modifications in the FreeBSD source code.

Linux has no problem with GCC being GPLv3 licenced and as such targets the latest and greatest versions, as for the compiler performance difference GCC typically generates 5-15% faster code when we've benchmarked here at work (x86-64), often more when we use PGO (profile-guided-optimizization) which is a optimization Clang/LLVM lacks (although there was a pgo GSOC project for llvm this summer, don't know how it turned out though).

As for compilation speed, Clang/LLVM is indeed faster altough it's gotten slower over time (rather unavoidable as it matures) and the difference is not as evident as it was earlier, and as Allan pointed out, if you don't optimize your code as much then obviously the compilation speeds will be faster.

Error diagnostics however is a place where I think Clang/LLVM is still supreme, however GCC has made great strides here in the 4.7 release and will likely continue to do so during the 4.8 release. Overall I doubt the kernel devs are going to spend any time on Clang/LLVM compability, not ony because they likely think that time is better spent elsewhere but also because I gather the primary problem is that Clang/LLVM lacks support for many of the compiler extensions the kernel devs relies on in order to better control the resulting code and make it as efficient as possible.

Re: Will Arch Linux going to change the default compiler to Clang?

Grinch wrote:

Overall I doubt the kernel devs are going to spend any time on Clang/LLVM compability, not ony because they likely think that time is better spent elsewhere but also because I gather the primary problem is that Clang/LLVM lacks support for many of the compiler extensions the kernel devs relies on in order to better control the resulting code and make it as efficient as possible.

That's not true. There's LLVMLinux project under Linux Foundation that aims to do just that. There's also quite a few talks about the subject, here's one for example. Many mobile / ARM companies are very interested in compiling Linux with LLVM; most notably Google.

Re: Will Arch Linux going to change the default compiler to Clang?

Teho wrote:

That's not true. There's LLVMLinux project under Linux Foundation that aims to do just that. There's also quite a few talks about the subject, here's one for example. Many mobile / ARM companies are very interested in compiling Linux with LLVM; most notably Google.

What of what I wrote was not true? Are the kernel developers doing this? No, this is a 'third-party' effort. And while this project currently compiles the kernel it requires both a patched kernel and a patched clang-llvm toolchain to do so, and the resulting kernel is unstable.

Re: Will Arch Linux going to change the default compiler to Clang?

Grinch wrote:

What of what I wrote was not true? Are the kernel developers doing this? No, this is a 'third-party' effort. And while this project currently compiles the kernel it requires both a patched kernel and a patched clang-llvm toolchain to do so, and the resulting kernel is unstable.

What does that even mean? The idea is to upstream the patches and it's ongoing effort. How do you define what work is done by "kernel developer" or "thrid-party" kernel developers?

Re: Will Arch Linux going to change the default compiler to Clang?

Teho wrote:

What does that even mean? The idea is to upstream the patches and it's ongoing effort.

What it means is that it's not an initiative by the main kernel developers, nor do they seem interested. There is ton of code which IS upstreamed and not accepted. This is not the first attempt to have clang-llvm compiler Linux, there have also been other get-linux-to-compile-with-compiler-x projects before clang-llvm like with ICC, none of which have succeeded.

For this project to reach mainline it requires upstream acceptance of patches in both clang/llvm and linux, clang/llvm devs have not been interested in adding many of the the GCC compiler extensions the linux kernel relies on, and the linux kernel developers have shown no interest of relinquishing the use of these compiler extensions as they want the best possible performance, not to mention that in many cases the kernel developers were actually those who requested said compiler extensions to be added to GCC.

So no, I don't think this will lead to Linux officially building with clang/llvm, you will (as is the case now) have to apply patches, likely not only to linux but also on the clang/llvm toolchain.

Re: Will Arch Linux going to change the default compiler to Clang?

Grinch wrote:

For this project to reach mainline it requires upstream acceptance of patches in both clang/llvm and linux, clang/llvm devs have not been interested in adding many of the the GCC compiler extensions the linux kernel relies on, and the linux kernel developers have shown no interest of relinquishing the use of these compiler extensions as they want the best possible performance, not to mention that in many cases the kernel developers were actually those who requested said compiler extensions to be added to GCC.

Would you mind sharing some sources? There seems to be quite a bit of work going on making upstream Clang/LLVM to compile Linux kernel and one of its most active developers is Google that internally compiles Linux with LLVM. Here's a a master bug for tracking the process. To my understanding the patches applied to Linux are also relatively small and non-intrusive. There's obviously a lot of community intrest considering that it was worth setting up the LLVMLinux project under Linux Foundation (to reduce dublicated work); Debian also seems to have plans to compile their entire repository with Clang. Not to mention that LLVM itself is very popular nowadays being installed on almost every Linux system.

Re: Will Arch Linux going to change the default compiler to Clang?

Scimmia wrote:

Um, what? To the best of my knowledge, it's installed on very few linux systems.

It's used quite a bit by MESA/Gallium3D: It's hard dependecy on compile time, it's needed by the LLVMPipe software rasterizer, it's used as a shader compiler by Radeon Gallium drivers and Intel plans to use it in the future too. The propietary NVIDIA driver uses LLVM for both CUDA and OpenCL (as do the Gallium and Intel drivers). Every Android phone has LLVM installed because it's used for RenderScript. I though it was always installed with MESA but it seems I was mistaken.

Re: Will Arch Linux going to change the default compiler to Clang?

Teho wrote:

Would you mind sharing some sources? There seems to be quite a bit of work going on making upstream Clang/LLVM to compile Linux kernel

Same as you (I suppose) I've been following these attempts by looking at overall progress, mailing lists and some of the bug reports, like I said this is not the first attempt to get llvm/clang to compile Linux (afaik this latest one is a consolidation of previous efforts together with some new blood(?) which makes it more likely that it will atleast be able to compile a stable kernel, albeit requiring patches).

Teho wrote:

Debian also seems to have plans to compile their entire repository with Clang. Not to mention that LLVM itself is very popular nowadays being installed on almost every Linux system.

Are you referring to that one Debian developer who has compiled the repository with Clang to see how well it went? Is that the basis of your 'Debian also seems to have plans to compile their entire repository with Clang' claim?. AFAIK developers of distros have tried pretty much all the compilers under the sun on their repos and have reported the results, doesn't mean they plan to use that compiler for their official builds.

Teho wrote:

To my understanding the patches applied to Linux are also relatively small and non-intrusive.

I don't know what the state is now but the previous patches I recall where not unintrusive, of course there are two targets of problems here, you can pretty much leave Linux alone if you can have clang-llvm accept lots of patches, and vice versa. If the current crop of patches needed were relatively small and non-intrusive they would likely have made in into some testing branches in the trees of their upstream targets by know, the changes needed for FreeBSD to compile using Clang/LLVM were quite substantial as I recall and it was like a 4-5 year period necessary for the transition despite being a very focused effort which will finally reach it's culmination with the upcoming FreeBSD 10 release.

Teho wrote:

There's obviously a lot of community intrest considering that it was worth setting up the LLVMLinux project under Linux Foundation (to reduce dublicated work);

Well I don't judge a project's success or community interest by a webpage, I judge it by progress. Currently it seems to be where it was last I checked, patches needing to be applied to both Linux and Clang/LLVM with a unstable kernel as a result.

Teho wrote:

Not to mention that LLVM itself is very popular nowadays being installed on almost every Linux system.

Well yes LLVM is pretty much ubiquitous as a JIT-framework which is used in lots of projects but LLVM as a an actual installed package?

Like I said, I would be surprised (as in I don't think it will happen) if upstream linux and clang/llvm took in the patches necessary for compiling linux 'out-of-the-box' based upon past and current progress. I guess we'll have to see.

Re: Will Arch Linux going to change the default compiler to Clang?

Re: Will Arch Linux going to change the default compiler to Clang?

enihcam wrote:

Sorry I bring this up again, but I think Clang is mature now. Any thoughts?

Do you have any real information to add besides "I think"?

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.