top | item 20195155

OpenMandriva, the first Clang-built Linux distribution

148 points| Conan_Kudo | 6 years ago |openmandriva.org

131 comments

order
[+] haunter|6 years ago|reply
What difference does that make for an end user? You have two copies of the same OS on the 2 PCs (same hardware) but one compiled on gcc, the other on LLVM/clang. How will this affect me? What differences I will notice? Better performance? Like real world performance
[+] koyote|6 years ago|reply
You could theoretically see better real-world performance. As someone who is currently working on very high-performance C++, I have noticed Clang being much more 'confident' in optimising code than its counterparts (especially compared to MSVC++).

That being said, in the grand scheme of things any performance improvement would probably only show up on benchmarks.

[+] nickpsecurity|6 years ago|reply
The only benefit I can think of is increased security now or over time. Most people developing compiler-based mitigations work on LLVM. Especially the practical ones. HardenedBSD is an example of a project making use of them. SVA is an example of one that might be applied to Linux:

https://github.com/jtcriswell/SVA

[+] notaplumber|6 years ago|reply
Several *BSD projects have been using the Clang toolchain by default for many years, and have been a massive driving force in getting these fixes upstreamed so that other systems, incl. Linux distributions can benefit from greater choice of compilers.

FreeBSD since 10.x on i386/amd64, not sure about the status on other platforms.

OpenBSD since 6.1 for arm64, 6.2 for i386/amd64. This is both default for the base system, meaning kernel and userland. And also the ports tree, for compiling 3rd party packages, very few ports still depend on gcc.

And also, while not the default system compiler yet, LLVM/clang is compiled and installed on macppc/sparc64 and mips64 systems.

[+] shereadsthenews|6 years ago|reply
That’s neat but the large differentiation seems to be PGO+LTO. As pointed out below both of Google’s distributions of Linux are optimized that way (actually with AutoFDO/SamplePGO+ThinLTO), but I don’t think there is a community distribution that is properly optimized. It could be significantly better.
[+] pkulak|6 years ago|reply
Clear Linux?
[+] ndesaulniers|6 years ago|reply
Really great work by the OpenMandriva team. I've spoken to some of their contributors before and even looked into one of the bugs they reported. Now that I think about it, I need to send that patch for fixing asm goto detection in glib.

Android and ChromeOS are also built with Clang. I'm curious about the distinction of "first." Does anyone know the timelines here?

[+] oneplane|6 years ago|reply
Not sure how wide Apple has adopted it or how much of a 'distro' you could call their operating systems, but much is built using LLVM with clang where publicly visible.
[+] rocqua|6 years ago|reply
> Python has been updated to 3.7.3, and we have successfully removed dependencies on Python 2.x from the main install image (for now, Python 2 continues to be available in the repositories for people who need legacy applications);

This is cool. I wish ubuntu/debian would move towards this.

[+] pfdietz|6 years ago|reply
Clang has added a command line option for automatic initialization of auto variables to zero, hasn't it?

That by itself would be enough to make me choose clang over a compiler that didn't have that option. Gcc deliberately doesn't support that, right?

[+] ori_b|6 years ago|reply
That seems like a mistake to turn on, given that clang also has options to error on uses of potentially uninitialized variables. Zero is often just as wrong as any other value, so this flag will hide real bugs.

In fact, I'd rather have a flag that clobbers values with random data, to make sure that uses of uninitialized values are caught as soon as possible.

[+] kartan|6 years ago|reply
Why not use static code analyzers? You run them in compilation time and warn you of uninitialized variables.

Initializing values just because seems wasteful. That's why global and static variables are already initialized in this way.

For me it would yet make sense that Gcc allows it even if it's not a very good practice it may have its uses.

[+] andrekandre|6 years ago|reply
what’s the reason gcc wouldn’t support it?

[edit] ipad auto correct

[+] Conan_Kudo|6 years ago|reply
For those interested, there's a presentation about OpenMandriva's usage of LLVM from EuroLLVM 2019:

* Video: https://www.youtube.com/watch?v=QinoajSKQ1k

* Slide deck (PDF): https://llvm.org/devmtg/2019-04/slides/TechTalk-Rosenkranzer...

[+] BurningCycles|6 years ago|reply
Am I correct in assuming you are connected to the project ? If so I was wondering what the packages are where you employ PGO, Firefox, Chromium and x64 are examples of applications with built in compile-support, are you using PGO on other packages as well ?
[+] Hendrikto|6 years ago|reply
Also this:

> Python has been updated to 3.7.3, and we have successfully removed dependencies on Python 2.x from the main install image (for now, Python 2 continues to be available in the repositories for people who need legacy applications);

[+] frutiger|6 years ago|reply
Arch Linux was able to achieve this years ago.
[+] canada_dry|6 years ago|reply
ELI5... why is this great news (i.e. why is LLVM/CLANG better than GCC -- speed?)
[+] StavrosK|6 years ago|reply
See, when a daddy loves a mommy very much, they usually get married. However, sometimes the daddy meets another woman, who is faster, uses less memory, with a significantly less complicated code base, and then the daddy decides to compile his Linux with her instead.

Does that help?

[+] djsumdog|6 years ago|reply
Clang has some code base and speed advantages, but the big reason the large players like Apple are grabbing onto it is licensing. A lot of companies really want to move away from any GPL stuff. It's sad since so much of what we have in the Linux ecosystem came from GNU.
[+] IloveHN84|6 years ago|reply
They want to get rid of Stallmann's GNU concepts
[+] fluffything|6 years ago|reply
Compiling things with clang is faster and uses less memory.

Linux distros, package repositories, etc. are basically giant compilation farms, compiling packages making sure they work well together so that you don't have to.

So switching to clang might impact their resource usage.

---

For you, the user, the performance of binaries compiled with GCC or clang is pretty much on par. Some binaries are a bit faster with clang, others are a bit faster with GCC, often in negligible ways.

If you are doing something that's very resource intensive, recompiling that software yourself tuning it to your use cases is probably going to have a much larger impact on resource usage than whether the shipped package was compiled with gcc or clang.

[+] zamalek|6 years ago|reply
Apart from compiler redundancy, it eliminates the usage of vendor (GCC or Clang) extensions and UB that the two compilers don't agree on.

Edit: last I checked (more than two years ago), GCC was faster on more micro-benchmarks.

[+] snvzz|6 years ago|reply
Dependency on a specific toolchain is bad for the ecosystem.

The existence of a distribution using Clang for building itself makes the ecosystem way stronger.

[+] otabdeveloper2|6 years ago|reply
It's not great news. GCC is basically better in every way.

People promote Clang because it has a permissive license and opens the door for Google and Apple to inject proprietary crap into Linux.

[+] pepijndevos|6 years ago|reply
In addition to the "why does LLVM matter" asked elsewhere, why would I want to use OpenMandriva?
[+] pbhjpbhj|6 years ago|reply
https://wiki.openmandriva.org/en/4.0/RC/Release_Notes

but I'm not really sure. I guess if you want a recent kernel, KDE Plasma based distro and you work with LLVM/clang.

I really don't know where it fits with Mageia/PCLinuxOS and other Mandrake descendants.

History IIRC -- Mandrake was RH Linux with KDE; Mandriva was a continuation of that which split; OpenMandriva were devs from that split that took ROSA Linux (still doing KDE4 I think) and then continued their project from that base.

[+] qhwudbebd|6 years ago|reply
Doesn’t mention if the kernel built fine with clang, that would be interesting if so as that used to be tricky. (I’m probably out of date; maybe it’s fine nowadays?)
[+] ndesaulniers|6 years ago|reply
Good question! This is my day job! Builds are looking pretty green!

https://clangbuiltlinux.github.io/

X86_64 required the implementation of ASM goto, which we just shipped. You'll need to build clang from source, but the feature will be in clang-9.0 release. Other arches should build with clang-8 (technically x86_64 will build pre 4.19 kernels) but we shipped pixel 2 kernels w/ clang-4.0 so older Clang's may work depending on your target arch/tree/configs.

[+] qalmakka|6 years ago|reply
The kernel _almost_ builds fine with Clang; one of the major stopgaps were the usage of VLAIS (which I think have been all removed given that they amount to pure insanity) and `asm goto`, which it has been implemented by LLVM (I think it will become available on stable when 9.0 is released this autumn).
[+] Conan_Kudo|6 years ago|reply
The kernel is not built with clang as that only works with ARM architectures right now (the Android kernel supports it, but the mainline kernel does not).
[+] matthewbauer|6 years ago|reply
They still use libgcc, ld.bfd, and libstdc++ though.
[+] fluffything|6 years ago|reply
I was wondering whether they were using `libc++` and `libc++abi` or not. Thank you for clarifying this.
[+] gok|6 years ago|reply
Surely that distinction must to go to Android and/or ChromeOS?
[+] stefantalpalaru|6 years ago|reply
https://www.phoronix.com/scan.php?page=article&item=gcc-clan... :

"On the AMD side, the Clang vs. GCC performance has reached the stage that in many instances they now deliver similar performance... But in select instances, GCC still was faster: GCC was about 2% faster on the FX-8370E system and just a hair faster on the Threadripper 2990WX but with Clang 8.0 and GCC 9.0 coming just shy of their stable predecessors. These new compiler releases didn't offer any breakthrough performance changes overall for the AMD Bulldozer to Zen processors benchmarked.

On the Intel side, the Core i5 2500K interestingly had slightly better performance on Clang over GCC. With Haswell and Ivy Bridge era systems the GCC vs. Clang performance was the same. With the newer Intel CPUs like the Xeon Silver 4108, Core i7 8700K, and Core i9 7980XE, these newer Intel CPUs were siding with the GCC 8/9 compilers over Clang for a few percent better performance."