Hi, i work on clang for Windows. Found out about this via Victor’s talk. I told him this in person but I’m putting it here so it doesn’t get forgotten.
Clang on windows is generally expected to be invoked as clang-cl.exe
, but the extension uses clang++.exe
. It’s possible to make this work, as you’ve discovered, but there’s several surprising issues that can arise, so I’m not sure it’s the right “default” experience.
For starters, it will be harder to get your code to even compile at all because there are a lot of special options that you need to pass to get it into ms compatibility mode with the right paths. But worse, you may end up checking different code than you’re actually building because you’re not using the same options your build system uses. This puts a large burden on the user to make sure they understand how to translate msvc compilation flags to clang compilation flags.
Since you’re already hooking into the vcxproj, you can determine on a per file basis the exact msvc style command line, this way you guarantee you are checking the same code you are shipping.
Of course, you can still provide options to override this or add clang specific command line options, but it seems like this should be “advanced” and not the default experience.
A couple of things you might not know that could help:
-
If you run clang-cl.exe
you literally pass the exact same command line as you would to cl.exe
. But if you add -###
at the end, instead of compiling, it will show you the “real” command line being generated. Perhaps the system could use this intelligently as a starting point.
-
You can still pass most (all?) clang dash-options to clang-cl.exe
and even mix msvc slash options with clang dash options.
-
clang++.exe
is a synonym for clang.exe —driver-mode=g++
and clang-cl.exe
is a synonym for clang.exe —driver-mode=cl
In any case, I encourage you to look into defaulting to using the cl driver as I think it will be more familiar to users and in most cases will allow everything to “just work” immediately out of the box without having to futz around with clang command lines