Chromium Windows builds now use Clang by default
groups.google.com
groups.google.com
So what is Chromium gaining from switching to clang-cl? Perhaps just less amount of compiler specific code/hacks/quirks/workarounds etc?
Edit: This being Google I was expecting interesting data or at least somewhat thorough reasoning. The post just felt like a fyi for switching to clang. Nonetheless some good possible reasons in below replies.
That is, there are benefits to be had by knowing you do work on multiple toolchains. Painful at times, but mainly in ways that make a better product.
My guess (not being a Chromium developer myself) is that this is an exercise in consistency across platforms - I can imagine that using the same compiler on all supported platforms makes the language features supported consistent and removes the risk of one compiler generating much worse output for the same code. But I'm just postulating, I don't actually know for sure.
If you are an application developer and a compiler X gives warnings that compiler Y doesn't for your application, then ideally you should probably fix the warnings from compiler X. An end user probably doesn't care either way, they just want to compile the program without any issues.
You should always strive for zero warnings on all builds across all compilers. It's a realistic, achievable and worthwhile goal. But while pretty much all warnings are worth looking at, a much smaller set are worth breaking the build over. You're much better off (in my view) promoting those particular warnings to errors, and leaving the rest as-is.
Seems like a win on every level to me.
Switching to Clang also allows the use of Clang-based sanitizers and fuzzing, which improves the security of Chrome.
Wow. That's a big omission on Microsoft's part! I wonder how they themselves are getting around it for Win64 performance sensitive code.
Using CPUID is one, using very specific vector instructions another (but you can do most of this using intrinsics) and it's better if they get their own .s file
Unless there's an instruction you need that doesn't have an intrinsic or you're writing something like a spin lock where instruction ordering is critical and a compiler barrier for some reason is not sufficient, there's no reason to ever write assembly.
Your code won't be appreciably faster than if you tuned it in the compiler, and after a few years the compiler will integrate new instructions while your assembly just gets stale.
So there are reasons to write code in assembly language.
It's more hassle, but still possible to use.
There are lots of good reasons, but my favourite point -- besides considering clang to be a superiour c++ compiler in general -- is that using an open-source compiler allows us to fix things.
When a developer runs into a miscompile or compiler crash, finds an inefficiency in the generated code or has an idea for a new warning, we can fix it and push a new compiler out within days. And in addition to the work we put in ourselves, we benefit from the huge amount of work put in by the wider llvm/clang community.
It leads to a better developer experience, and in the end a better product.
- MSVC had trouble with dead code elimination in some cases: fixing https://crbug.com/684105 reduced binary size by almost 900KB on Windows.
- It lets tooling like https://chromium.googlesource.com/chromium/src/+/master/docs... and the custom clang plugin checks run on Windows-specific code.
Slower build times.
Their 2015 (and later) tooling and runtime cannot be trusted anymore, they send home data like there is no tomorrow - as observed on Win7. It's the VC++ runtime, the dotNet runtime, the dotNet optimization process, VSCode, dotNetCore, etc all send data home with no opt-in or opt-out option. This doesn't happen on other operating systems.
In addition, the analyses and optimisations performed by Clang are generally more sophisticated than by MSVC. See for example http://www.forwardscattering.org/post/51.
The only optimisation I know of that MSVC performs that Clang doesn't (in some cases at least) is autovectorisation of some maths functions: https://bugs.llvm.org/show_bug.cgi?id=23645
(Actually MSVC has a pretty effective link-time code gen option, that is often turned off by projects using Clang)
0 - https://bitbucket.org/chromiumembedded/cef
Edit: Now that I think about it, the Qt stuff is all in shared libs, so less worried there. But with CEF, the C++ wrapper is statically linked. What is MSVC's linker's ability to consume clang objs and vice versa I wonder. If not an issue, maybe I'm just fine.
(It works well. The PDB files and the corresponding source code are available, so you can step through the Chromium code in Visual Studio and so on.)
CEF is built as part of your program using whatever compiler you're using. I don't know what the mechanics of it are... I assume it uses the Chromium stuff via an import library? I didn't look very closely at this aspect of it.