News for hackers. Stuff that matters.
Re:Clang Is Now Used to Build Chrome for Windows by tavert on Monday March 05, 2018 @05:01PM (#16524876)
> 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.

Re:Clang Is Now Used to Build Chrome for Windows by martell on Monday March 05, 2018 @06:23PM (#16525513)
mingw-w64 llvm maintainer/developer here.

Over the past 2-3 years, with great help from a few other LLVM devs I have slowly pushed for native clang support for mingw-w64. With the current in tree HEAD you can now build and bootstrap mingw-w64 with a llvm-only toolchain (no binutils or gcc, thus no disregard of the PECOFF SPEC)

The stack is as follows. LLVM+CLANG+LLD+COMPILER-RT+LIBCXX+LIBCXXABI+LIBUNWIND+MINGW-W64.

The libraries and executables built this way can be dropped into visual studio quite easily, the two environments are now basically interchangeable. This also means we can borrow the PDB debugging work by Zachary Turner and/or any msvc features added to llvm for free that was done by the various googlers working on chrome. See a talk from Reid on the most recent LLVM developer meetup for more info on PDB and how it works. There has been no formal release of this environment yet but you should see something in the coming weeks/months. I keep build scripts here for those interested.

https://github.com/martell/mingw-w64-clang

I'm due another cleanup of the repo now that wine 3.0 is out so I can actually run x64 tests within a linux docker container. I'm going to be doing some blogging to make this more visible with various partners that want to support this.

The most interesting part of this for me was implementing a llvm-dlltool alternative to binutils dlltool that actually works within the PECOFF spec so msvc lib.exe and link.exe likes what it produces.

https://reviews.llvm.org/rL308379

Re:Clang Is Now Used to Build Chrome for Windows by zturner on Monday March 05, 2018 @06:33PM (#16525571)
This sounds great, it's been a long time coming and I'm sure many people will appreciate being able to debug their mingw generated executables in Visual Studio.

I did all of the PDB stuff in LLVM, happy to help if you need it (ping me on the mailing list or IRC)

Re:Clang Is Now Used to Build Chrome for Windows by martell on Monday March 05, 2018 @06:40PM (#16525622)
Updated the comment to reflect this. :) Thanks for all the good work. Will ping you when I move onto that stage for support.
Re:Clang Is Now Used to Build Chrome for Windows by tavert on Monday March 05, 2018 @07:23PM (#16525857)
Excellent work. I like to ignore visual studio completely and pretend it doesn't exist, but that's just me :) I've used cygwin's cross-compiler x86_64-w64-mingw32-clang package once in a while, though I find more projects' build systems choke on it and do the wrong thing (libgmp as a notable example) than with x86_64-w64-mingw32-gcc.
Re:Clang Is Now Used to Build Chrome for Windows by martell on Monday March 05, 2018 @09:35PM (#16526447)
I tend to ignore both gcc and MSVC. Clang is really good at bootstrapping itself with this setup even when cross compiling without any real complexity. Without diverting into a cmake vs autotools battle I like that llvm and clang just work and bootstrap so easily. Gone are the days of messing around with gmp isl and co to bootstrap a toolchain.
Re:Clang Is Now Used to Build Chrome for Windows by tavert on Monday March 05, 2018 @11:26PM (#16526857)
Fair enough, but I actually need gmp more for runtime math, plus fortran deps like lapack and more obscure things. Maybe flang will be production-worthy some day - do you know if they're still outputting a textual representation of IR into string buffers?
Re:Clang Is Now Used to Build Chrome for Windows by brucedawson on Monday March 05, 2018 @07:05PM (#16525772)
I've been watching the process of getting git to build with VS, but it's sounding like mingw-w64 will gain PDB output faster than the VS version will happen. Either way, if I can debug (and profile) git.exe then I'm happy.
Re:Clang Is Now Used to Build Chrome for Windows by Ericson2314 on Monday March 05, 2018 @10:01PM (#16526551)
Great work! We with Nixpkgs/NixOS have over the past year overhauled cross compilation, culminating recently with a bunch of parallel efforts recently including Windows cross compilation. People have built Nix with cygwin in the past, it would be nice to get it working in MSYS2/mingw-w64 too.
Re:Clang Is Now Used to Build Chrome for Windows by jacobush on Tuesday March 06, 2018 @04:19AM (#16527802)
Are you targeting Linux, building on Windows?
Re:Clang Is Now Used to Build Chrome for Windows by Ericson2314 on Saturday March 10, 2018 @11:32AM (#16559084)
No reason we couldn't expand into doing that!
Re:Clang Is Now Used to Build Chrome for Windows by amedvednikov on Monday March 05, 2018 @10:01PM (#16526553)
Thanks for your work. mingw-w64 is amazing!
Re:Clang Is Now Used to Build Chrome for Windows by mappu on Monday March 05, 2018 @05:38PM (#16525230)
One of mingw{,-w64}'s major contributions is a gcc-compatible replacement set of headers and import libraries, instead of using the Windows SDK or MSVC versions.

These work great most of the time, but if you start hooking deeply into windows, you realise they are a little bit outdated or incompatible. e.g. I get a lot of errors like

    #warning COM interfaces layout in this header has not been verified.
    #warning COM interfaces with incorrect layout may not work at all.
    #pragma message: Interface Ifoo has unverified layout.
in COM code, and some ATL things it is unable to build at all.
Re:Clang Is Now Used to Build Chrome for Windows by bedros on Monday March 05, 2018 @05:16PM (#16525039)
Apple 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

Re:Clang Is Now Used to Build Chrome for Windows by kccqzy on Monday March 05, 2018 @05:22PM (#16525085)
I thought Apple didn’t just “hire” the developers of clang. They started the clang project in-house before eventually open sourcing it.
Re:Clang Is Now Used to Build Chrome for Windows by gsnedders on Monday March 05, 2018 @05:30PM (#16525160)
Yes; Clang was started internally to Apple. They did "just hire" the developer of LLVM.
Re:Clang Is Now Used to Build Chrome for Windows by gsnedders on Monday March 05, 2018 @05:31PM (#16525166)
> 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.

Re:Clang Is Now Used to Build Chrome for Windows by saurik on Tuesday March 06, 2018 @01:33AM (#16527276)
Why, though? What does Chrome do that calls into C++ code compiled by anyone but Google?
Re:Clang Is Now Used to Build Chrome for Windows by valarauca1 on Tuesday March 06, 2018 @03:11AM (#16527597)
on Windows the native ABI (or the default ABI I should say) explicitly reserves space for C++ stack unwinding on a per call basis.

A lot of the windows API can (ab)use this so it’s best to follow it, despite it being C (ish).

Re:Clang Is Now Used to Build Chrome for Windows by gsnedders on Tuesday March 06, 2018 @05:33AM (#16528025)
File dialogs (to save/load web pages, to upload files), print support, TCP sockets… all of these involve calling into system code.
Re:Clang Is Now Used to Build Chrome for Windows by tavert on Tuesday March 06, 2018 @10:05AM (#16529234)
do any of those require ABI compatibility at the C++ level? win32 API's are generally exposed as C
Re:Clang Is Now Used to Build Chrome for Windows by Const-me on Tuesday March 06, 2018 @11:45AM (#16529946)
> win32 API's are generally exposed as C

A lot of newer Win32 APIs are IUnknown-based COM interfaces. APIs that are probably relevant for Chrome are shell interop, drag & drop, Direct2D, Direct Write, Media Foundation.

Re:Clang Is Now Used to Build Chrome for Windows by brucedawson on Monday March 05, 2018 @05:35PM (#16525192)
Does this option give you full debug information? My impression was that it does not. I require full debug information for debugging and profiling, and with clang-cl I get that (context: I work on Chromium)
Re:Clang Is Now Used to Build Chrome for Windows by chandlerc1024 on Monday March 05, 2018 @06:09PM (#16525423)
My memory is that it supports DWARF debug info. So you get full debug info in DWARF and can use the mingw port of GDB on Windows.

Still, this is very different from the first-class support for compatible debug info that Clang provides.