As of Chrome 64, Chrome for Windows is compiled with Clang. We now use Clang to build Chrome for all platforms it runs on: macOS, iOS, Linux, Chrome OS, Android, and Windows. Windows is the platform with the second most Chrome users after Android according to statcounter, which made this switch particularly exciting.
I wonder if it’s the technical merit of llvm in general, or gpl3 that’s turning people away from gcc nowadays.
Granted, this is windows build we’re talking about, but it seems that llvm is pushing forward on all fronts.
Edited 2018-03-07 07:53 UTC
GPL3. No large company is going to touch such software with a stick most of the time when it comes to development.
No, companies that are simply using GPL V3 have nothing to worry about. Its companies that distribute it, that are concerned with GPL V3.
However, you are right that those companies that want to contribute to compilers, don’t want o touch GPL V3. Hence they are pouring their efforts into LLVM efforts.
Now, because all the development is going into LLVM, its becoming better than GCC. The technical reasons follow shortly after the political.
It’s more like the technical demerit of gcc. GCC is a cumbersome code base, and the move to develop in C++ was probably too late.
LLVM Clang is easier to develop for.
In the case of several systems such as OpenBSD, it is indeed the license, although a barrier to adoption is LLVM and Clang supporting many fewer targets, and not always being self-hosting.
In my own experience, current versions of LLVM+Clang and GCC take a similar amount of time to download and build (although CMake makes me want to build clang a lot less). The code output is very comparable as well. Sometimes Clang is better, sometimes GCC is better ( https://t.co/k3d4mN7EqE )
Edited 2018-03-08 19:22 UTC
True. I have contributed patches to both and LLVM is by far the easiest code to read.
Yet somehow GCC still produces faster code, and after being challenged by Clang they now also compile faster.. So they must be doing something right.
For me, it was pure code generation. For my relatively simple projects, clang would produce code that’s about 10%-15% smaller than gcc. clang was still not quite as good as Visual C++, but gcc was an outlier. Turning your point around, what would be the reason to use gcc over clang?
After -O2 or -Os, I find they’re both about the same. Clang is a much faster compiler, hands down. My understanding is that GCC can be overly aggressive in optimization so may end up generating code that isn’t the best for relatively simple projects.
The optimization thing is definitely true. I have tested code using GCC and Clang with various optimizations turned on. Code compiled with Clang would always run smoothly. Code compiled without optimizations on GCC would also run. But if I turned on optimizations under GCC, the program would crash. Some logic or checks were getting optimized out, but only under GCC, and causing instability.
Warnings and errors are more sane under Clang. The messages are much clearer with references to where things went wrong in Clang. GCC’s errors are pretty cryptic in comparison.
I have also noticed GCC throwing incorrect warnings. Like “This variable is declared but unused.” But looking through the code shows the variable is, in fact, used and cannot be removed. I still test code under GCC to see if it finds potential problems Clang doesn’t, but I do almost all my work with Clang because it is so much more pleasant to use.
Check twice. It is pretty safe to assume error is on your side.
Try with different GCC versions. Its is highly unlikely that you found some untested path.
Edited 2018-03-08 11:15 UTC
Yup, try different gcc versions, forks, branches, vendor revisions, one might by chance fit your need for your project. But you might have to walk the same trial and error path to find the suitable gcc incarnation for another project.
Or just switch to a mature compiler that is not fuzzy and ticklish, no leaves gaping holes open for years, implement the standard correctly without implementing “extensions” that are not compatible with the competition.
Bref, a suitable 3rd millennium compliant compiler. Not a thing from the past.
That I proposed was a way to diagnose the problem. If you think the problem is compiler specific – try different version to make sure.
A lot of programs in devices around you are compiled with GCC and optimization enabled. If your software is unstable, GCC isn^aEURTMt the right thing to blame.
Edited 2018-03-09 07:12 UTC
Or you’re checking this for null.
For a large project like Chrome, I’d be more than willing to bet that a large part of the appeal is the compilation performance of Clang compared to GCC. In my own experience, builds that use Clang tend to take between 10 and 15% less time than building the same code with GCC. While that may not sound like much, it becomes very significant when you’re dealing with stuff that takes hours to build even on high-end systems (see for example LibreOffice, Firefox, Thunderbird, and the various WebKit libraries).
Reverse is true for me. I get shorter compilation times with gcc for chromium than with clang (still takes some hours). Otoh, anything obj-c is done with clang. There’s no compelling technical reasons to choose one over the other in general. As is evident from assorted tests and comparisons. I rely on both.
Interesting. I’ve never built Chromium with Clang, but I have done webkit-gtk and Firefox with it before, and both of those built faster. I’ve not tried recently though, and performance of GCC may have significantly improved since I last tried.
This is Chrome for Windows, it was built using MSVCC not gcc.
clang had a bit of an edge over gcc in compile speed a few years back. But I think they compile speed differential is not that significant anymore when it comes to recent llvm vs gcc toolchains.
No, they did this for the compiler monoculture. They didn’t want to deal with different quirks in different compilers, so now they only support one single compiler, and thus ends up depending on their bugs (I am a Chromium embedded and have already had to fix several clang’isms in the Chromium 65 code just a few weeks after they went monoculture).