top | item 14924470

Using Clang on Windows

26 points| Leandros | 8 years ago |arvid.io | reply

28 comments

order
[+] DannyBee|8 years ago|reply
"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 :)

[+] Leandros|8 years ago|reply
Unfortunately, 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).
[+] chris_wot|8 years ago|reply
What are the advantages of using clang-cl over the Microsoft c++ compiler?
[+] bla2|8 years ago|reply
Looks like this is using clang++ instead of clang-cl, which sets almost all of these flags automatically.
[+] martell|8 years ago|reply
Exactly, 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 :)

[+] Leandros|8 years ago|reply
Unfortunately, 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).
[+] brian-armstrong|8 years ago|reply
I 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?
[+] anta40|8 years ago|reply
"Visual Studio 2017 will not work."

Ouch...

[+] dxf|8 years ago|reply
I'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|8 years ago|reply
Not true anymore, I've updated the repository and article to work with 2017.