-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
very loud warnings output from cmake VS2019+Clang builds #4983
Comments
Tried the following, no change diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3d3b14..f25d33c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -257,6 +257,14 @@ if(MSVC)
endforeach(flag_var)
endif()
endif()
+if(MSVC_CLANG)
+ # silence clang-cl builds a bit
+ foreach(flag_var
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+ string(REGEX REPLACE "/W(1|2|3|4)" "" ${flag_var} "${${flag_var}}")
+ endforeach(flag_var)
+endif()
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
# etc. are created correctly. |
Maybe we should force (the first to solve all the "you used |
Maybe also
It's the other way around.. (Off-topic: the winrt code does windows includes with capital letters, though.) |
See https://github.com/sezero/SDL/tree/clang-cl This reduces log size from about 55k lines to 33k lines - still not good. What I wonder is why these warning options are enabled - is it |
Are there code changes that we should be doing to fix the warnings? |
Some of the |
Adding diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3d3b14..ed39d25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -563,6 +563,14 @@ if(USE_GCC OR USE_CLANG)
list(APPEND EXTRA_CFLAGS "-Wshadow")
endif()
+ if(MSVC_CLANG)
+ # silence the clang-cl builds
+ check_c_compiler_flag(-Weverything HAVE_GCC_WEVERYTHING)
+ if(HAVE_GCC_WEVERYTHING)
+ list(APPEND EXTRA_CFLAGS "-Wno-everything")
+ endif()
+ endif()
+
if(APPLE)
list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
list(APPEND EXTRA_LDFLAGS "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}") The order of addition in
Anyone has a better solution? |
I definitely wouldn't turn off all warnings. :)
These two warnings are overreaches by Clang, imho; they don't actually affect clang or any other compiler we currently use, so they're just trying to enforce some hypothetical code hygiene on others, as far as I can tell. |
It also adds the other |
Also of real interest is where the hell these warnings are actually enabled.. Looked at |
@sezero According to the clang-cl manual, /Wall is treated as -Weverything:
A solution to this problem would be to use /W4 instead of /Wall for MSVC Clang builds. That brings down the total warning count from 13180 to 842. I tested this locally by replacing this line of the CMakeLists.txt with the following conditional:
Alternatively, if you want -Weverything enabled, then you probably want to disable the most obtrusive warnings. I've collected all unique warnings and sorted them by occurrence in descending order below. There are only 37 unique warnings in total, but some are occurring in the thousands.
|
Ew.. That explains it, thanks. Will try patching cmake soon. |
OK, pushed b7f9c20 -- closing as fixed. |
See e.g. recent Github CI build logs.
Cmake seems to enable both gcc
-Wall
and also MSVC/W3
, the latterpossibly is the culprit?
The text was updated successfully, but these errors were encountered: