[cfe-dev] MSVC compatible driver proposal

Reid Kleckner rnk at google.com
Wed Jun 26 19:13:42 PDT 2013


On Wed, Jun 26, 2013 at 9:38 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Wed, Jun 26, 2013 at 5:48 PM, Reid Kleckner <rnk at google.com> wrote:
> > On Wed, Jun 26, 2013 at 8:22 PM, Richard Smith <richard at metafoo.co.uk>
> > What I have in mind right now is CMake, where every user pretty much does
> > their own ad hoc flag checking and munging.  Every CMake user would have
> to
> > say add_cflag_if_supported("-fblah") / add_cflag_if_supported("-Xescape
> > -fblah"), or it would be in some 'if clang' block.
>
> It needs to be in an "if clang" block regardless if these are
> clang-specific flags. And they need the -Xwhatever regardless if the
> flag means something else to cl.exe. Also, I don't see any problem
> with supporting -Xwhatever from both drivers, so you don't even need
> special case code for the cl.exe case. Just do:
>
>  if(clang)
>     add_cflag_if_supported("-Xwhatever -fblah")
>  endif(clang)


I don't think that's standard practice for existing CMake and autoconf
build systems.  I've met many people who believe in feature testing
compiler flags with a test compile, rather than maintaining a list of
compiler vendors and versions that support a given flag.  Personally, I've
always hated this because it's really expensive and wastes a lot of time.

The other school of thought is to do the obvious thing and say "if gcc, add
-fno-rtti, if msvc, add /GR-", and then change it when you need to build
with clang.

I also don't want to ask people to escape gcc style flags everywhere.
 Consider -Wextra, which gcc and clang accept, and today might be written
as 'add_if_supported(-Wextra)' or 'if (gcc_compatible) add(-Wextra)'.

It seems best to have that work for all of gcc, clang, and clang-cl,
without adding code to add on -Xescape for clang.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130626/1bac2d2d/attachment.html>


More information about the cfe-dev mailing list