22 ms·
Clang Is Now Used to Build Chrome for Windows
- tomc1985 9y agoLast time I tried to build Chrome/Chromium I had to mess about with this build system called Ninja. (Which worked well it was just awkward to set up on Windows). Is that still in play?
- mastax 9y agoYes, ninja is still used.
- xyzzyz 9y agoNinja is used because it's simple, multiplatform and very fast. The mainstream alternatives offer at most 2 out of 3.
- cjhopman 9y ago"it's simple": yep, so much so that you inevitably need a meta-build system. In the context of Chrome, the build system only offers 2 out of 3.
- bigcheesegs 9y agoIt's by design that you need a meta-build system. Ninja build files were not designed to be written by hand, not even ninja itself has hand written ninja files.
- cjhopman 9y agoYes, I understand that it's designed that way. My point was that, in the context of Chrome using ninja, the claim that "Ninja is used because it's simple, multiplatform and very fast. The mainstream alternatives offer at most 2 out of 3." is a bit odd considering that the decision doesn't seem to be ninja vs mainstream alternatives but rather ninja+gn(or gyp or whatever else) vs alternatives.
- evmar 9y agoCan you elaborate on the difficulty on Windows? If you go to the home page there is a section "Getting Ninja" that links to a page with a zip file... ?
- tomc1985 9y agoIt was too long ago for me to remember specifics. Once ninja was up and running the build process was pleasant.
- tsomctl 9y agoI didn't realize that clang is mostly a drop in replacement for cl, and matches the C++ abi. That in of itself is awesome.
- brucedawson 9y agoclang isn't. clang-cl is (after years of work by the clang-cl team at Google). They had to do a lot of work, especially around PDB (symbol-file) generation.
- zturner 9y agoMore precisely: clang-cl is a drop-in replacement for cl (even the command lines are the same). But clang-cl is just a driver for clang, and it's still possible to get the ABI compatibility without clang-cl, but you have to know what you're doing and get the flags right.
- equalunique 9y agoHave seen a couple interesting articles[0][1] highlighting the weirdness of building Chromium on Windows, so hopefully this LLVM improvement will be a step towards a smoother process. [0] https://randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/ https://randomascii.wordpress.com/2018/02/25/compiler-bug-li... [1] https://randomascii.wordpress.com/2017/07/09/24-core-cpu-and-i-cant-move-my-mouse/ https://randomascii.wordpress.com/2017/07/09/24-core-cpu-and...
- jwilk 9y agoOn HN: [0] https://news.ycombinator.com/item?id=16463572 https://news.ycombinator.com/item?id=16463572 [1] https://news.ycombinator.com/item?id=14733829 https://news.ycombinator.com/item?id=14733829
- brucedawson 9y agoHey, those are mine! Those two issues (and this one: https://randomascii.wordpress.com/2018/02/11/zombie-processes-are-eating-your-memory/ https://randomascii.wordpress.com/2018/02/11/zombie-processe...) are equally problematic with clang. Two of them were problems with Windows, and one was a flaw in a Microsoft system management component. Luckily they are all mitigated, fixed, or being fixed, so my Chrome builds run much more smoothly now.
- equalunique 9y agoThank you for chiming in! Your articles are wonderful!
- zamalek 9y agoDid you guys ever reverse-spec the name mangling?
- katastic 9y agoDid Microsoft ever fix their kernel bug with process creation you wrote about?
- tavert 9y ago> if your project is Windows-only, you can get a second compiler’s opinion on your code, and Clang’s warnings might find bugs GCC (mingw.org and mingw-w64 triples) has existed and been able to do this, including and especially cross-compiling, for a long time. No need to manually download a Windows SDK either. edited to add: to be fair, it's not ABI compatible with MSVC. But it deserves a mention and it's an easier option than MSVC-style build systems for many open source projects.
- bedros 9y agoApple hired developers of Clang and started supporting Clang around the time GPLv3 was being pushed by FSF, Apple at the time was using GCC in their development and feared that GPLv3 would taint their code. other than technical merits, permissible license of Clang is attractive for some developers/businesses
- gsnedders 9y ago> edited to add: to be fair, it's not ABI compatible with MSVC. But it deserves a mention and it's an easier option than MSVC-style build systems for many open source projects. Pretty sure this is significant in Chrome's case.
- saurik 9y agoWhy, though? What does Chrome do that calls into C++ code compiled by anyone but Google?
- anfilt 9y agoAnd why not use mingw gcc? Do they find somthing wrong with it? Edit Mingw-w64 its quite nice and includes gcc without all stuff cgwin does.
- ChickeNES 9y agoIt's not ABI compatible with MSVC
- sverige 9y agoUnfortunately, mingw profiling code and the toolchain is tainted with GPL.
- jhasse 9y agoIsn't it "GPL + GCC exception"?
- nice_byte 9y agoWhy use it? llvm is the future anyway and lots of players have a stake in it and contribute to it. In fact, there are way too many c++ compilers if you ask me. I would gladly accept a world where clang is the one and only.
- monocasa 9y ago> In fact, there are way too many c++ compilers if you ask me. I would gladly accept a world where clang is the one and only. Not me, IMO clang is where it is due to competition.
- deleted 9y ago[deleted]
- tzahola 9y ago>I would gladly accept a world where clang is the one and only. And luckily you don’t have any saying in such matters.
- quickben 9y agoInteresting. It seems Google is moving away from anything gpl/gnu lately (fuchsia, etc...)
- pjmlp 9y agoYep, GCC is no longer supported on Android.
- wongmjane 9y agoI think it is mainly due to their concerns over the Tivoization clause which is added to GPLv3
- chocolatebunny 9y agoThat's true for any developer of embedded software. Any one who makes hardware of any kind will avoid trying to put any GPLv3 licensed code on their hardware.
- DannyBee 9y agoAgain, no, we didn't care. First: We were already publishing all our GCC changes, as we did all our work upstream (we worked on a staging branch in the gcc repo, and changes were moved to trunk as fast as possible) Plenty of other companies used our branch and we were happy with it. We do all our work upstream for clang/llvm as well, and pull compiler releases when upstream is green according to our internal testing. (Pretty much the only cherry picks are a small number of reverts sometimes) Second, literally nobody has ever come and expressed a concern about using GCC to me. I've had to explain the runtime and libstdc++ exceptions to people, but that was the other way around -- They weren't worrying, and I needed to make sure they worried and shipped source when they ship it as a .so.
- slrz 9y agoI doubt this is very relevant in the case of Chrome compilers. It's more about the huge investment/expertise in Clang- or LLVM-based dynamic analysis and development tooling. It's just the better platform for writing these things. Heck, this is what is was built for in the first place. GCC is a solid, but also a very traditional compiler.
- bgussen 9y agoDid the LLVM folks fix the C++ structured exception handling incompatibility between MSVC compiled DLLs/programs and LLVM compiled ones? This was a problem for many years.
- dxf 9y agoClang 7 documentation has a section on MSVC compatibility, https://clang.llvm.org/docs/MSVCCompatibility.html https://clang.llvm.org/docs/MSVCCompatibility.html From that document: Asynchronous Exceptions (SEH): Partial. Structured exceptions (__try / __except / __finally) mostly work on x86 and x64. LLVM does not model asynchronous exceptions, so it is currently impossible to catch an asynchronous exception generated in the same frame as the catching __try.
- chandlerc1024 9y agoYes. (To the extent possible. There are some edge cases left, but they're very rare. Essentially all the real-world code we've seen works now.)
- AlexeyBrin 9y agoTried to install Clang 5.0 Visual Studio integration, unfortunately it seems that I need to install VS 2015 (v140) compiler since it doesn't work with VS 2017 (v141).
- CyberDildonics 9y agoI've tried clang for windows twice. Each time the problem hasn't been the compiler, which works well, it has been which library to use with it on windows. Clang 5.0 worked well up until I needed the filesystem library, which isn't there. Does anyone know if it still relies on the visual studio C++ library?
- bigcheesegs 9y agoclang-cl is just a compiler. It relies on VS to provide the C and C++ standard libraries. VS 2017 has the filesystem library and it should work with clang-cl 6.
- brucedawson 9y agoTo elaborate on that, if you want to build Chromium for Windows you currently still need to install Visual Studio. We don't use its compiler anymore but we use its linker and other tools, its header files, and its libraries. Many Chromium developers also use it for editing code, and for debugging code. Chrome is currently built using VS 2017 15.3 (that's update 3). Eventually we will probably upgrade to VS 2017 15.7 in order to get more STL conformance, linker improvements, etc.
- notriddle 9y agoYou need the MSVC build tools and the Windows SDK. You don't need the entire Visual Studio.
- voltagex_ 9y agoCan you get the VS 2017 build tools separately any more?
- oldmanhorton 9y agoYep: https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 https://www.visualstudio.com/downloads/#build-tools-for-visu...
- evmar 9y agoWe first started fiddling with Clang for Chrome in late 2010: http://neugierig.org/software/chromium/notes/2011/01/clang.html http://neugierig.org/software/chromium/notes/2011/01/clang.h... The original work was just finding bugs in the codebase and compiler. It's gone so far!
- Ono-Sendai 9y agoGreat work by the Clang team, well done! I'm a bit surprised to see that build times in Clang are worse, and that resulting binary performance is comparable. Maybe that will change when the Clang build starts to use LTCG, as the article mentions.
- DannyBee 9y agoYeah, just things that aren't optimized yet. Windows headers, etc have very different hot spots and need different paths to be fast than linux/mac ones. For reference, in distributed builds, the build times are ridiculously faster using clang. (it shaves many hours off the time).
- tmzt 9y agoIs that due to the use of PCH in MSVC, so the hotspots only happen if the headers change? What does clang offer in this regard? Is incremental build sufficient?
- DannyBee 9y agoNo, clang offers precompiled headers as well. It's literally things like "parsing large numbers of pragmas is slower in clang because nobody has bothered to optimize it". This is not uncommon for very different codebases. Clang was, for a long time, many times slower at compiling the linux kernel, for example, because the linux kernel headers have a huge amount of inline assembly and nobody ever bothered to optimize the parsing paths for inline assembly. (now somewhat fixed). This is just the very typical "hey, when you change the use cases dramatically, you may need to retune/rethink how certain things are done" I think people just may not realize how wildly different these types of codebases are in what types of statements/things occur.
- xvilka 9y agoWith Microsoft producing MSVC/C2 compiler with Clang frontend, I am surprised they did not abandon the MSVC at all - they have a hard times even at supporting C99, not to mention modern C++ technologies. And all those tools and plugins built around Clang/LLVM. MSVC is a legacy of XX century and should be abandoned for good.
- pjmlp 9y agoThey don't have any hard time supporting C99, from Microsoft point of view C is done, time to move on to C++. > We do not plan to support ISO C features that are not part of either C90 or ISO C++. https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/ https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-an... All the updates regarding C99 and C11 in Visual C++ are related to ANSI/ISO C++ requirements regarding C compatibility, as Herb states. Regarding legacy, Visual C++ is one of the top C++ compilers doing incremental compilation and linking, which still beats Rust compilation times on Windows.
- wahern 9y agoMicrosoft backpedaled not longer afterwards. See, e.g., https://blogs.msdn.microsoft.com/vcblog/2013/06/28/c1114-stl-features-fixes-and-breaking-changes-in-vs-2013/ https://blogs.msdn.microsoft.com/vcblog/2013/06/28/c1114-stl... and https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/ https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-libra... They even added C99 compound literals and designated initializers: https://msdn.microsoft.com/en-us/library/hh409293(v=vs.120).aspx https://msdn.microsoft.com/en-us/library/hh409293(v=vs.120).... Compound literals could never be added to C++ because the syntax and semantics conflict with existing C++ constructs.
- deleted 9y ago[deleted]
- pjmlp 9y agoC99 and C11 library support is required by ANSI/ISO C++. As for the minor language changes, there was a blog post that I cannot locate now, stating it was to the extent required for porting well known projects to Windows, the remaining features would depend on key customers feedback.
- RandomCSGeek 9y agoWho are the "we" they refer to in this blog? Are they Google's devs who build chrome, or are they clang's devs? If they are clang's dev, why are they building chrome? I am completely confused on this one.
- GeekyBear 9y agoFor those interested in Clang history, here's Chris Lattner giving a tech talk at Google introducing LLVM and Clang. https://www.youtube.com/watch?v=029YXzHtRy0 https://www.youtube.com/watch?v=029YXzHtRy0 The Clang discussion begins at 18:53
- deleted 9y ago[deleted]
- andreyv 9y ago> On the other hand, if all platforms use the same compiler, if it builds on your machine then it’s probably going to build on all platforms. This also works the other way: buggy code that "works" in Clang may now go unnoticed. This means it will be harder to build Chromium using GCC or MSVC. I see that Arch Linux already has to depend on Clang to build Chromium [1], which isn't very reassuring. [1] https://www.archlinux.org/packages/extra/x86_64/chromium/ https://www.archlinux.org/packages/extra/x86_64/chromium/