News for hackers. Stuff that matters.
Re:Chrome now uses clang for production builds on Linux by rakoo on Monday November 17, 2014 @12:05PM (#8619092)
Does anyone have details on why they made the switch ? The email states very little improvements, even a bug on 32-bit Debians. Is this only because of the license of the compiler ?
Re:Chrome now uses clang for production builds on Linux by IshKebab on Monday November 17, 2014 @01:12PM (#8619494)
The licence of the compiler doesn't affect what you build with it. I expect the reasons are the same most people are switching to clang:

* Modern modular design (everything is libraries) * Faster compile times * Nicer error messages

The modular design in particular is a good reason that might not be obvious at first. It lets you do things like debuggers, code formatters and static analysers in a much more sane and robust way than GCC's "no plugins, everything must be separate and flaky" way.

Re:Chrome now uses clang for production builds on Linux by film42 on Monday November 17, 2014 @02:14PM (#8619865)
I recently heard a google employee come speak at my university about how google's main codebase is compiled using clang, and their janitorial work is done using clang mapreduce [1]. Furthermore, that google employee talked about how google is working with the LLVM team to integrate the toolchain into visual studio for cross-platform compilation [2]. Pretty cool stuff!

[1] (similar talk) https://www.youtube.com/watch?v=mVbDzTM21BQ

[2] http://llvm.org/docs/GettingStartedVS.html

Re:Chrome now uses clang for production builds on Linux by 12423gsd on Monday November 17, 2014 @03:15PM (#8620239)
" google is working with the LLVM team to integrate the toolchain into visual studio "

the 3 giants are working together...

Re:Chrome now uses clang for production builds on Linux by pix64 on Monday November 17, 2014 @03:51PM (#8620463)
Re:Chrome now uses clang for production builds on Linux by deng on Monday November 17, 2014 @02:08PM (#8619841)
GCC has support for plugins since version 4.5, which is over four years old. Also, the error messages have improved greatly in the last releases.
Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @03:56PM (#8620500)
You really want to have the infrastructure argument about which is a better compiler infrastructure?

Even GCC developers (like I was ) don't really question it.

The only thing GCC buys you right now, at all, is slightly better performance (it varies depending on your benchmark) and support for a larger variety of odd embedded systems.

On the other hand, LLVM is very easy to modify, can be built as a library (as can clang), has a sane, well defined IR, etc.

Re:Chrome now uses clang for production builds on Linux by deng on Monday November 17, 2014 @04:22PM (#8620682)
Did I say that gcc has the better infrastructure, the more modern code base, better modularity? I don't think so. That would actually be pretty weird, given that its code base is nearing 30 years of history. But I hope that it is still allowed to say that GCC has made progress the past few years. And I think it is worth refuting claims like "you cannot access the AST in gcc", since this is simply not true anymore. Yes, actually dealing with the AST is baroque, but you can access it nonetheless. There are nice plugins for GCC, like Melt or the python-plugin which make this easier, though. Also, there's the license/freedom thingy, which might not interest you, but others do care about such things.
Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @04:58PM (#8620923)
"Did I say that gcc has the better infrastructure, the more modern code base, better modularity? I don't think so. "

Your reply certainly implied you thought GCC was fine along the same axises your parent said clang was better.

"But I hope that it is still allowed to say that GCC has made progress the past few years." You are talking to a guy who helped make some of this progress (for example, I helped build the tree-ssa project that brought a language independent middle IR and SSA optimizers to GCC). It's certainly made progress, but that progress had been fought about for the 5 years before that. At the same time, GCC lost good developers during these fights due to wanting to get stuff done and not deal with politics.

"Also, there's the license/freedom thingy, which might not interest you, but others do care about such things."

Actually, it interests me immensely. I helped with things like the libstdc++ exception, etc. Besides being a compiler guy, i'm an open source lawyer.

But in the end, I choose stuff based on technical merits first, freedom second. You are of course, welcome to do as you please.

Re:Chrome now uses clang for production builds on Linux by deng on Tuesday November 18, 2014 @03:52AM (#8623015)
> Your reply certainly implied you thought GCC was fine along the same axises your parent said clang was better.

No. I simply corrected a false statement regarding gcc. I did not compare it to clang at all. I have no illusions how gcc does compare to clang w.r.t. to code quality, modularity, etc. As I've said: it would be weird if it were otherwise. It's really not hard to beat gcc in that area.

> You are talking to a guy who helped make some of this progress

Thank you (no irony intended).

> Actually, it interests me immensely.

It may interest you, but as you say yourself:

> But in the end, I choose stuff based on technical merits first, freedom second

>You are of course, welcome to do as you please.

Will do, thanks.

Re:Chrome now uses clang for production builds on Linux by _dps on Tuesday November 18, 2014 @02:46PM (#8625883)
> Besides being a compiler guy, i'm an open source lawyer.

Apologies for replying in-thread (I couldn't find contact in your profile). Would it be possible to ask you a few questions about a perhaps-novel compiler licensing question for an open source application we're developing (we're a commercial entity and can pay for your time)? If so you can reach me at the email in my profile.

Re:Chrome now uses clang for production builds on Linux by bronson on Monday November 17, 2014 @02:14PM (#8619869)
If you spend a long time damaging your project's internal organization, expect to spend a long time digging back out.
Re:Chrome now uses clang for production builds on Linux by pjmlp on Monday November 17, 2014 @01:48PM (#8619724)
Clang brought new life into C and C++ eco-systems, specially in the sense that since we cannot get rid of C for the time being, at least we can improve the tooling around it to make it safer.

But sometimes I wonder if the license doesn't play a role as well.

Re:Chrome now uses clang for production builds on Linux by _RPM on Monday November 17, 2014 @03:09PM (#8620198)
Why would you want to get rid of C?
Re:Chrome now uses clang for production builds on Linux by wolf550e on Monday November 17, 2014 @03:21PM (#8620282)
To make certain classes of bugs impossible. What will end up hapenning with all code that must be kept is that ever stricter compilers and static analyzers will find the unsafe code and it will be fixed piece by piece.
Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @03:44PM (#8620428)
The license played no role in this switch :)
Re:Chrome now uses clang for production builds on Linux by emn13 on Monday November 17, 2014 @04:22PM (#8620679)
I have no idea whether it's true, but on the topic of gcc's inferiority in the matter of error messages, this source claims it's no longer true: https://gcc.gnu.org/wiki/ClangDiagnosticsComparison

Of course, given the source, apply salt :-).

Re:Chrome now uses clang for production builds on Linux by Alphasite_ on Monday November 17, 2014 @07:36PM (#8621780)
I dont know about C++, but for C Clang certainly feels like it has better error messages than the variant of GCC that the distro the Uni defaults to has, If nothing else, because of the colour.
Re:Chrome now uses clang for production builds on Linux by emn13 on Monday November 24, 2014 @08:13AM (#8652190)
Are the versions you're using up to date, however?
Re:Chrome now uses clang for production builds on Linux by joelthelion on Monday November 17, 2014 @02:31PM (#8619961)
None of these reasons matter at all for production builds. The production build needs to happen only once per release, and the only things that count are performance and reliability.

The last time I checked gcc still had better performance than CLang, but things might have changed since then.

Re:Chrome now uses clang for production builds on Linux by micampe on Monday November 17, 2014 @02:57PM (#8620122)
You don't want to build your nightlies with one compiler and then switch to a different one just for the final release.
Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @03:50PM (#8620452)
1. It depends on your benchmarks. There are some it's behind on, some it's ahead on.

2. LLVM is a lot easier to improve.

Re:Chrome now uses clang for production builds on Linux by CJefferson on Monday November 17, 2014 @12:09PM (#8619121)
They do mention:

> With the switch to clang, binary size dropped about 8% while performance mostly stayed the same. Startup time improved a bit,

Also I can imagine it might be nice to use the same compiler on different OSes, and gcc is very much a 2nd class citizen on mac.

Re:Chrome now uses clang for production builds on Linux by moyix on Monday November 17, 2014 @02:04PM (#8619816)
On the other hand, clang is very much a second class citizen on Windows.
Re:Chrome now uses clang for production builds on Linux by zanny on Monday November 17, 2014 @02:16PM (#8619883)
Every compiler that is not (and some may even consider it second class considering its UX) MSVC is a second class citizen on Windows.
Re:Chrome now uses clang for production builds on Linux by CJefferson on Monday November 17, 2014 @02:16PM (#8619881)
True, but is gcc much better, or does chrome use visual studio? (I honestly don't know, wondered if anyone else did)
Re:Chrome now uses clang for production builds on Linux by Joky on Monday November 17, 2014 @02:29PM (#8619948)
Yes.
Re:Chrome now uses clang for production builds on Linux by 0x09 on Monday November 17, 2014 @03:27PM (#8620317)
I don't use the MSVC toolchain or Windows for that matter, so I don't have a good compass for this, but the impression from the newsletter, dev meetings etc is that clang-cl is constantly being improved. Is the situation still that poor?
Re:Chrome now uses clang for production builds on Linux by cremno on Monday November 17, 2014 @03:59PM (#8620528)
They have a site covering compatibility with MSVC: http://clang.llvm.org/docs/MSVCCompatibility.html

I think it's pretty acceptable, if you're writing C. As you can see, C++ support is only partially completed (no exceptions!). But you're right, Clang on Windows gets constantly improved.

The creation of good debugging information (MSVC's /Zi or even /ZI option) is also missing. For a first class citizen, support of the (undocumented) PDB format is a requirement in my opinion.

Re:Chrome now uses clang for production builds on Linux by experimental- on Monday November 17, 2014 @02:16PM (#8619882)
So is GCC. Perhaps it's still one less compiler to deal with, if they don't need GCC on any platform any more.
Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @03:52PM (#8620471)
???? Compared to GCC?

You can now build a fairly well-functioning chrome binary, from visual studio, with clang/llvm, without source code changes.

Re:Chrome now uses clang for production builds on Linux by nly on Monday November 17, 2014 @01:15PM (#8619519)
Google are invested in Clang by virtue of employing guys like Chandler[0] to work on it. When you're scrubbing up monstrous codebases like Chrome, tooling matters. Clangs architecture, and things like all the sanitizers that are part of the broader project, presumably go a long way.

[0] https://twitter.com/chandlerc1024

Re:Chrome now uses clang for production builds on Linux by mcescalante on Monday November 17, 2014 @02:53PM (#8620087)
I posted a link to a 2011 talk from Chromium devs about using clang in another comment here, but below is a summary of what they seemed to enjoy from clang (at least, from the talk points):

- Useful warnings, they look good, and are on by default.

- More than a compiler, lets you build your own tools (example: AddressSanitizer)

- Better performance (less time) with clang vs. gcc for both -O0 -g and -O2 (at the time the benchmark was done on 8 cores, 24GB)

In summary / tl;dr : they enjoy diagnostics, the clang code base, how it works, and the ability to write their own tools. It seems like it's more to do with preference/performance and less to do with licensing. I'm sure that now they're doing many more things with clang since three years has passed since the aforementioned talk.

Re:Chrome now uses clang for production builds on Linux by DannyBee on Monday November 17, 2014 @03:54PM (#8620485)
Because you can get a single toolchain that is state of the art, can build for all of chrome's supported platforms (in fact, it could do it from a single binary if you really wanted), and one can easily improve to get the performance you want out of.