Google's Chrome browser is now built using the Clang compiler on Windows. Previously built using the Microsoft C++ compiler, Google is now using the same compiler for Windows, macOS, Linux, and Android, and the switch makes Chrome arguably the first major software project to use Clang on Windows.

Chrome on macOS and Linux has long been built using the Clang compiler and the LLVM toolchain. The open source compiler is the compiler of choice on macOS, making it the natural option there, and it's also a first-class choice for Linux; though the venerable GCC is still the primary compiler choice on Linux, by using Clang instead, Google ensured that it has only one set of compiler quirks and oddities to work with rather than two.

But Chrome on Windows has instead used Microsoft's Visual C++ compiler. The Visual C++ compiler is the best-supported, most widely used compiler on Windows and, critically, is the compiler with the best support for Windows' wide range of debugging and diagnostic tools. The Visual Studio debugger is widely loved by the C++ community, and other tools, such as the WinDbg debugger (often used for analyzing crash dumps), are core parts of the Windows developer experience.

Way back in 2013, Google decided that it wanted to use Clang everywhere, including Windows. Using the same compiler everywhere makes development much easier—you have the same set of bugs to deal with on every platform—and Clang in particular has diagnostic tools such as ASan and UBSan that Google wanted to be able to use.

There was just one small sticking point: Clang and LLVM didn't really have much in the way of Windows support. This was true in superficial ways—Clang supports different command-line options to Microsoft's compiler, for example, so couldn't work as a drop-in replacement—and in many deeper ways. For example, Windows' tooling is all built around the PDB ("program database") file format for holding debug information. Microsoft's debuggers and a wide range of third-party tools all assume that Windows programs will have their debug data available as PDB files. LLVM, however, couldn't produce PDBs. As with almost any large software project, the Windows APIs also require certain non-standard extensions, which Clang had to be altered to support.

As such, the first step to making Chrome use Clang on Windows was to improve Clang and LLVM to give them first-class support for Windows. Google assembled a team to work on this. The browser was first successfully built with Clang on Windows in 2015, with Google testing it first in its Canary development channel, then the Development and Beta channels. With Chrome 64, the stable browser channel is making the switch to using Clang.

While Google did the lion's share of the compiler development to make this happen, some of the necessary work was done by Microsoft. The PDB format was largely undocumented (and the documentation that existed was very stale), so LLVM developers asked for help: Microsoft responded by publishing a big chunk of source used to produce PDBs. Microsoft has also worked to ensure that both the Windows headers and the C++ libraries work with Clang as well as its own compiler.

Google has not yet moved entirely to the LLVM toolchain. Chrome for Windows still uses the Microsoft linker (the part of the toolchain that combines the compiled source code into a single executable or DLL), and it still uses the Microsoft C++ library. In time, Google plans to switch to the LLVM linker and may use Clang C++ library, too.