5 ms·
Using Clang on Windows
- bla2 9y agoLooks like this is using clang++ instead of clang-cl, which sets almost all of these flags automatically.
- martell 9y agoExactly, In fact clang, clang++ and clang-cl are all the same program. The frontend just behaves differently based on the file name. Disclaimer: I am a LLVM Engineer working on a mingw-w64 standalone clang :)
- jessermeyer 9y agoWhy is Clang so much slower than cl at compiling? On OS X / unix Clang seems so much faster.
- martell 9y agoBy cl do you mean MSVC cl or are you asking about clang vs clang-cl ?
- jessermeyer 9y agoMSVC cl compiles much faster than clang / clang-cl.
- dxf 9y agoYes, this is something that is being worked on.
- jessermeyer 9y agoCan you point to an official discussion / svn commit chain that demonstrates this?
- Leandros 9y agoUnfortunately, clang-cl only supports a very limited subset of CL's flags. And if you want to talk to clang directly you have to go through an extra layer of indirection by using -Xclang -flag. By using clang directly you get the whole power of clang without arbitrary limitations (and as a bonus you can now compiler your software on mac and linux).
- bla2 9y agoWhat's missing?
- DannyBee 9y ago"Unfortunately, getting clang to compile MSVC based projects isn't as easy as just dropping in clang and changing a few flags. Let's get started." Errr, use clang-cl, and "yes it is". That's the whole point of clang-cl :)
- chris_wot 9y agoWhat are the advantages of using clang-cl over the Microsoft c++ compiler?
- jftuga 9y agoYou can add features or fix bugs since it is open source. It might be easier for cross-platform code.
- martell 9y agoBy using clang-cl you are getting the advantage of the LLVM backend. LLVM/Clang can target many different platforms besides windows and it is open source so it is sponsored by many large companies including Google Apple etc. Google use it for Chrome for example (which includes windows) and have engineers working full time to meet their needs. Intel, ARM, AMD and co have upstreamed many optimisations into LLVM also. If you have a bug it probably will be resolved faster. Instead of waiting months for the next Visual Studio Release etc In general, LLVM because of the intermediate bytecode language and well made libraries like libclang enables new kind of tooling. Microsoft actually use LLVM themselves in many places and have a bunch of open source projects that use it, which is great The would actually probably be better off retiring MSVC's c++ compiler and focus on clang along with everyone else because other companies are basically paying for the engineering for their platform with clang. Unlike gcc the license for llvm/clang is more liberal so if they want private internal tooling they can still do that also.
- chii 9y ago> Unlike gcc the license for llvm/clang is more liberal so if they want private internal tooling they can still do that also. How can that be true? The definition of private internal tooling is that it's not publically distributed, and therefore, GPL isn't a concern. Unless you distribute the result of your modifications to GCC, both clang and GCC are viable bases from which you make your internal tooling.
- brian-armstrong 9y agoI tried using clang-cl recently but it produced a ton of linker errors for basic math functions. Does that mean clang-cl does not provide its own libc? And is there some guide that explains various C options on windows?
- johncolanduoni 9y agoAre you trying to compile for MSVC or Mingw libc?
- anta40 9y ago"Visual Studio 2017 will not work." Ouch...
- dxf 9y agoI'm not sure what is meant here. "opting in" to VS 2017 is recommended when building Chrome for 64-bit Windows to get improved incremental linking support. (We still link Chrome on Windows with link.exe even when compiling with Clang.)
- Leandros 9y agoNot true anymore, I've updated the repository and article to work with 2017. Visual Studio 2017 doesn't require the -fms-compatibility flags anymore, in fact, it refuses to compile if you specify them. Since I was expecting these to be required I found no way to compile them.
- martell 9y ago> (We still link Chrome on Windows with link.exe even when compiling with Clang.) I wasn't aware of this, I know Rui the COFF owner in lld puts in a lot of effort into lld for chrome link times. Maybe he just uses it as a benchmark then :D I actually caused a regression in migrating def code from lld to llvm with symbol mangling because we were missing a test case for this specific type of mangling and within hours it ended up on a chromium bug tracker and was fixed also within hours by Reid another googler on LLVM.
- dxf 9y agoYes, I should have been a bit more clear. You can link with lld (we have bots running that do this; we're even setting up a bot that enables ThinLTO). But lld support for emitting PDB files isn't quite there yet.
- Leandros 9y agoNot true anymore, I've updated the repository and article to work with 2017.