From fc5239e88043eefe7fcc0eb2ec3da8cc05ffdda3 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 7 Jul 2020 11:06:44 +0800 Subject: [PATCH] build: test for warning options before enabling -Wno-* variant Some compilers, like GCC, will only warn about unknown -Wno-* options when other warnings are being thrown, i.e: ```bash CXX src/libzmq_la-address.lo src/address.cpp: In function 'zmq::zmq_socklen_t zmq::get_socket_address(zmq::fd_t, zmq::socket_end_t, sockaddr_storage*)': src/address.cpp:137:9: warning: unused variable 'unused' [-Wunused-variable] 137 | int unused; | ^~~~~~~ At global scope: cc1plus: note: unrecognized command-line option '-Wno-tautological-constant-compare' may have been intended to silence earlier diagnostics cc1plus: note: unrecognized command-line option '-Wno-atomic-alignment' may have been intended to silence earlier diagnostics CXX src/libzmq_la-channel.lo ``` They will also seem to accept the -Wno-* variant when it's tested for using AX_CHECK_COMPILE_FLAG. So, rather than test for -Wno-* variants that the compiler may pretend to understand, test for the actual option, and only enable the -Wno-* case when it is available. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 800171f3..b437346b 100644 --- a/configure.ac +++ b/configure.ac @@ -751,7 +751,7 @@ AM_CONDITIONAL(ON_GNU, test "x$libzmq_on_gnu" = "xyes") # Check for __atomic_Xxx compiler intrinsics AC_LANG_PUSH([C++]) -AX_CHECK_COMPILE_FLAG([-Wno-atomic-alignment], +AX_CHECK_COMPILE_FLAG([-Watomic-alignment], [CXXFLAGS+=" -Wno-atomic-alignment"], [], [-Werror]) @@ -1053,12 +1053,12 @@ AM_CONDITIONAL(FUZZING_ENGINE_LIB, test "x$FUZZING_ENGINE_LIB" != "x") # clang 6 has a warning that does not make sense on multi-platform code AC_LANG_PUSH([C]) -AX_CHECK_COMPILE_FLAG([-Wno-tautological-constant-compare], +AX_CHECK_COMPILE_FLAG([-Wtautological-constant-compare], [CFLAGS+=" -Wno-tautological-constant-compare"], [], [-Werror]) AC_LANG_POP([C]) -AX_CHECK_COMPILE_FLAG([-Wno-tautological-constant-compare], +AX_CHECK_COMPILE_FLAG([-Wtautological-constant-compare], [CXXFLAGS+=" -Wno-tautological-constant-compare"], [], [-Werror])