[llvm] r234343 - Enable W4 warnings by default for MSVC builds

Kaylor, Andrew andrew.kaylor at intel.com
Mon Apr 13 12:00:49 PDT 2015


I added the line you suggested to CMakeLists.txt, and this is what I see:

f:\users\akaylor\llvm-s\test>cmake -G "Visual Studio 12 2013 Win64" f:\users\akaylor\llvm-s\llvm
CMAKE_CXX_FLAGS =
-- No build type selected, default to Debug
-- The C compiler identification is MSVC 18.0.31101.0
…

Also, the /W3 flag isn’t being used during my build.

-Andy


From: Zachary Turner [mailto:zturner at google.com]
Sent: Monday, April 13, 2015 11:57 AM
To: Kaylor, Andrew; Aaron Ballman
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm] r234343 - Enable W4 warnings by default for MSVC builds

No, CMake itself initializes CMAKE_CXX_FLAGS to include /W3.  By default, if you do nothing, CMAKE_CXX_FLAGS will have /W3.  You can verify this by printing the value of CMAKE_CXX_FLAGS in the first line of llvm/CMakeLists.txt

On Mon, Apr 13, 2015 at 11:55 AM Kaylor, Andrew <andrew.kaylor at intel.com<mailto:andrew.kaylor at intel.com>> wrote:
I'm not sure I understand.  Are you saying this problem only happens if you have CMAKE_CXX_FLAGS defined to include W3?

I don't have CMAKE_CXX_FLAGS defined on my system and my version of CMake (3.0.1) isn't defining it on its own, which would explain why I'm not seeing the problem.  I guess your patch to strip W3 if it's there is OK, though it should probably also look for W1 and W2.

On the other hand, if there isn't some non-user reason that W3 would be part of CMAKE_CXX_FLAGS I would say this fall under the "don't do that" category of fix.

-Andy

-----Original Message-----
From: aaron.ballman at gmail.com<mailto:aaron.ballman at gmail.com> [mailto:aaron.ballman at gmail.com<mailto:aaron.ballman at gmail.com>] On Behalf Of Aaron Ballman
Sent: Monday, April 13, 2015 11:44 AM
To: Zachary Turner
Cc: Kaylor, Andrew; llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
Subject: Re: [llvm] r234343 - Enable W4 warnings by default for MSVC builds

When I do that, the first line of output shows /W3:


E:\llvm\x64>"D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64

E:\llvm\x64>cmake -G "Visual Studio 12" ..\llvm CMAKE_CXX_FLAGS =  /DWIN32 /D_WINDOWS /W3 /GR /EHsc ....

~Aaron

On Mon, Apr 13, 2015 at 2:37 PM, Zachary Turner <zturner at google.com<mailto:zturner at google.com>> wrote:
> Also what version of CMake are you using?  Maybe it's an issue with
> CMake >= 3.0?  Try putting the following line at the top of your
> CMakeLists.txt
>
> message("CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
>
> If you don't see /W3 in there, you won't hit the problem.
>
> On Mon, Apr 13, 2015 at 11:36 AM Zachary Turner <zturner at google.com<mailto:zturner at google.com>> wrote:
>>
>> Just realized maybe 2012 was a typo.  Are you actually still using 2012?
>> I thought support was dropped.
>>
>> On Mon, Apr 13, 2015 at 11:33 AM Aaron Ballman
>> <aaron at aaronballman.com<mailto:aaron at aaronballman.com>>
>> wrote:
>>>
>>> I do not get the warnings when building x64 or x86 on Windows 7,
>>> MSVC 2012, debug build. This is when building LLVM, Clang, lld, and
>>> clang tools extra
>>>
>>> ~Aaron
>>>
>>> On Mon, Apr 13, 2015 at 2:22 PM, Zachary Turner <zturner at google.com<mailto:zturner at google.com>>
>>> wrote:
>>> > I'm building x64.  Can you try that?  Run "vcvarsall amd64" before
>>> > building LLVM
>>> >
>>> > On Mon, Apr 13, 2015 at 11:21 AM Kaylor, Andrew
>>> > <andrew.kaylor at intel.com<mailto:andrew.kaylor at intel.com>>
>>> > wrote:
>>> >>
>>> >> I haven’t seen that.  I’m not seeing any warnings right now.
>>> >>
>>> >>
>>> >>
>>> >> From: Zachary Turner [mailto:zturner at google.com<mailto:zturner at google.com>]
>>> >> Sent: Monday, April 13, 2015 11:17 AM
>>> >> To: Kaylor, Andrew; llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
>>> >> Subject: Re: [llvm] r234343 - Enable W4 warnings by default for
>>> >> MSVC builds
>>> >>
>>> >>
>>> >>
>>> >> Hi Andy, this is causing a huge slew of warning spam.  Is this
>>> >> expected?
>>> >> CMake passes /W3 by default, so  every single translation unit I
>>> >> compile gives me the following warning:
>>> >>
>>> >>
>>> >>
>>> >> cl : Command line warning D9025 : overriding '/W3' with '/W4'
>>> >>
>>> >>
>>> >>
>>> >> Furthermore, since this is a command line warning and not a
>>> >> compiler warning, it cannot be suppressed.  Unless you have any
>>> >> better ideas on how to address this, I think this should be
>>> >> reverted.
>>> >>
>>> >>
>>> >>
>>> >> On Tue, Apr 7, 2015 at 12:07 PM Andrew Kaylor
>>> >> <andrew.kaylor at intel.com<mailto:andrew.kaylor at intel.com>>
>>> >> wrote:
>>> >>
>>> >> Author: akaylor
>>> >> Date: Tue Apr  7 14:01:01 2015
>>> >> New Revision: 234343
>>> >>
>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=234343&view=rev
>>> >> Log:
>>> >> Enable W4 warnings by default for MSVC builds
>>> >>
>>> >> Modified:
>>> >>     llvm/trunk/CMakeLists.txt
>>> >>
>>> >> Modified: llvm/trunk/CMakeLists.txt
>>> >> URL:
>>> >>
>>> >> http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev
>>> >> =234343&r1=234342&r2=234343&view=diff
>>> >>
>>> >>
>>> >> =================================================================
>>> >> =============
>>> >> --- llvm/trunk/CMakeLists.txt (original)
>>> >> +++ llvm/trunk/CMakeLists.txt Tue Apr  7 14:01:01 2015
>>> >> @@ -233,14 +233,7 @@ list(REMOVE_DUPLICATES LLVM_TARGETS_TO_B
>>> >>  include(AddLLVMDefinitions)
>>> >>
>>> >>  option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
>>> >> -
>>> >> -# MSVC has a gazillion warnings with this.
>>> >> -if( MSVC )
>>> >> -  option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF)
>>> >> -else()
>>> >> -  option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
>>> >> -endif()
>>> >> -
>>> >> +option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
>>> >>  option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled."
>>> >> OFF)  option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
>>> >> option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> llvm-commits mailing list
>>> >> llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
>>> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>> >
>>> >
>>> > _______________________________________________
>>> > llvm-commits mailing list
>>> > llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
>>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150413/9f8ed9ef/attachment.html>


More information about the llvm-commits mailing list