aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-09-11 21:02:56 -0700
committerGuy Harris <guy@alum.mit.edu>2018-09-12 04:22:33 +0000
commita6dc0c27fcc0c1a008c24daf8359f09a4d146965 (patch)
tree058dfd86d5421d1b086f0651c00dbb56f4e9f531
parent91c5942c93b4c1f9823ba6c530089461677ae016 (diff)
Don't use -Werror with Apple's llvm-gcc.
Its handling of warnings, and of warnings-treated-as-errors, is horribly broken; once you've asked for a warning, and have specified -Werror, there appears to be nothing whatsoever that you can do to keep that warning from being an error *everywhere* in the code. Prior to change Ib591a1d6beaa13337d927a446b4d8d5e687ff610, the tests for warnings were all failing on the macOS buildbot, so *no* warnings were being requested. With this change, a warning won't be reported as an error, but at least it'll be reported. (We should probably switch to using Clang on the macOS buildbot at some point; I don't know whether the version of Clang currently on the buildbot is safe to use, but if we ever run a newer version of Xcode, which doesn't come with llvm-gcc - which may involve running a newer version of macOS on the buildbot as well - it's presumably safe, given that it's the only compiler Apple shipped.) Change-Id: I677967cb87b91f68f08de546e59abff1dbd6788b Reviewed-on: https://code.wireshark.org/review/29623 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--CMakeLists.txt41
1 files changed, 17 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec29925..f58a1db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -491,30 +491,10 @@ else() # ! MSVC
-Wno-long-long
-Wheader-guard
-Wcomma
+ -Wshorten-64-to-32
)
#
- # For -Wshorten-64-to-32, Apple's llvm-gcc doesn't seem to support
- # specifying -Werror and then specifying that -Wshorten-64-to-32
- # warnings should *not* be treated as errors - not with pragmas
- # and not even with -Werror ... -Wshorten-64-to-32 ...
- # -Wno-error=shorten-64-to-32.
- #
- # So we only add -Wshorten-64-to-32 if either 1) we're not building
- # on/for Apple or 2) we're using Clang.
- #
- # We also suppress -Wunused-function; that's enabled by -Wall,
- # but it's another warning that can be difficult to suppress
- # in generated code.
- #
- if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
- list(APPEND WIRESHARK_COMMON_FLAGS
- -Wshorten-64-to-32
- -Wno-unused-function
- )
- endif()
-
- #
# Code that may be worth looking into (coding practices)
#
if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING))
@@ -752,9 +732,22 @@ if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS)
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(WERROR_COMMON_FLAGS "/WX")
else()
- check_c_compiler_flag(-Werror WERROR)
- if (WERROR)
- set(WERROR_COMMON_FLAGS "-Werror")
+ #
+ # If a warning has been enabled by -Wall or -W,
+ # and have specified -Werror, there appears to be
+ # no way, in Apple's llvm-gcc, to prevent that
+ # particular warning from giving an error - not
+ # with a pragma, not with -Wno-{warning}, and not
+ # with -Wno-error={warning}.
+ #
+ # Therefore, with that compiler, we just disable
+ # -Werror.
+ #
+ if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+ check_c_compiler_flag(-Werror WERROR)
+ if (WERROR)
+ set(WERROR_COMMON_FLAGS "-Werror")
+ endif()
endif()
endif()
endif()