This is a simple story until you start looking just below the surface. The simple part is that Google has manged to use the Clang compiler to compile Chrome targeting Windows.
The real question is why?
The situation with C/C++ on Windows has been, and is, difficult. Ask most C/C++ programmers which compiler to use and the answer is most likely GCC- the GNU Compiler Collection.
There are other notable compilers, such as the Intel compiler, but in the main GCC is considered the standard. The only exception is Clang, which is well thought of but not used as often. It has a reputation for being the compiler that academics and language experimenters select.
Under Windows most programmers just give in and use the Microsoft C/C++ compiler, but with a lot of grumbling about it not fully complying with some C standard or other and about all of the Microsoft extensions it supports. Of course, if you are developing a Windows application then it is the extensions and extra bits you actually want.
Until Chrome 54 Google used Clang to compile Chrome for every platform apart from Windows where it used the Microsoft compiler. The problem is that Clang didn’t support Windows – and now it does.
Google has helped with the open source project to make Clang Windows compatible. Not only is it Windows compatible, but it is also binary compatible with output from the Microsoft compiler.
his means you can use the linker to join up code from each compiler into a single program. This is an amazing effort, but notice that it took the Google team from 2013 until now to get an acceptable production build of Chrome on Windows. The really amazing part is that in 2015 Microsoft decicded to help. Microsoft also published the PDB format for the binary file that its compiler produces – this is unheard of cooperation. Programmers have been reverse engineering PDB files since they existed.
So what does Google get from all this?
Not very much if you look at performance figures. You can look at the details but essentially the Clang version of Chrome is about the same size and runs more or less at the same speed. This might change as the Google team fine tunes Clang for Windows. There is a long list of reasons for using Clang for Chrome, but the main ones seems to be that it is now possible to write plugins for the compiler and patches are going to be cross-platform.
Put simply, one compiler good, six different compilers on six different platforms bad.
There is also a list of pros and cons for using Clang, but they all seem to be fairly minor. The one that stands out is the fairly obvious:
“If your project runs on multiple platforms, you can use one compiler everywhere.”
This deserves thinking about for a moment. You can see the attraction for the Chrome developers, but what about the rest of us? I use GCC because of the number of targets it supports – mostly microcontrollers.
It also supports a wider range of languages than Clang, which might not be an issue if you are just focusing on C and C++, but … it mostly runs on Linux. I say “mostly” because there are ports to Windows, but they are fairly messy. Now you can run GCC using the Linux subsystem on Windows, but again there are disadvantages.
The simplest and cleanest way to run GCC on Windows is in a full virtual machine running Linux.
Now consider the choice for a new application – GCC, which gives you Linux; or Clang, which gives you Linux and Windows. Perhaps the dominance that GCC has had on Linux is about to be weakened. Perhaps this is why Microsoft helped out with the changes to Clang?
Whatever, it seems that Clang has come of age. It is production ready on Linux and Windows and it is being used to compile the current top browser on all of its platforms. Add to this the fact that from version 51 Opera is going to be compiled using Clang for Windows, and you can see things have really changed.
The last word should go to the LLVM blog post announcing it all:
“Thanks to the whole LLVM community for helping to create the first new production C++ compiler for Windows in over a decade, and the first-ever open-source C++ compiler that’s ABI-compatible with MSVC!”
The final exclamation mark is well justified.