]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: sync warning options between autotools, cmake & compilers
authorViktor Szakats <commit@vsz.me>
Sat, 6 Jul 2024 14:00:03 +0000 (16:00 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 10 Jul 2024 09:30:40 +0000 (11:30 +0200)
- cmake: enable Apple-specific `-Werror=partial-availability` to match
  autotools.

- autotools: enable `-pedantic-errors` with llvm/clang to match gcc and
  CMake.

- autotools: enable `-Werror-implicit-function-declaration` for
  llvm/clang to match gcc.

- cmake: enable `-Werror-implicit-function-declaration` to match
  autotools.

- move `-Wpointer-bool-conversion` from autotools to the local file
  (`sectransp.c`) it was meant to apply. This way it applies to all
  build methods.

- autotoos: show `CURL_CFLAG_EXTRAS` in the `./configure` summary.
  (it may contain `-Werror` and/or `-pedentic-errors`.)

Cherry-picked from #14097
Closes #14128

CMake/PickyWarnings.cmake
configure.ac
lib/vtls/sectransp.c
m4/curl-compilers.m4

index d1183fe392a4b80328bf9b79aa99412192534146..96e45f0e8c98170364add75f383c1bfa3e4f2a7c 100644 (file)
@@ -33,6 +33,16 @@ if(CURL_WERROR AND
   set(WPICKY "${WPICKY} -pedantic-errors")
 endif()
 
+if(APPLE AND
+   (CMAKE_C_COMPILER_ID STREQUAL "Clang"      AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) OR
+   (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.3))
+  set(WPICKY "${WPICKY} -Werror=partial-availability")  # clang 3.6  appleclang 6.3
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+  set(WPICKY "${WPICKY} -Werror-implicit-function-declaration")  # clang 1.0  gcc 2.95
+endif()
+
 if(PICKY_COMPILER)
   if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
 
index 91565c972db43f210cfa43db91ce966b569d38cf..0ea0c16d17854eeef0e70ae2fc9614625c61ab86 100644 (file)
@@ -540,6 +540,8 @@ if test X"$want_werror" = Xyes; then
     if test "$compiler_num" -ge "500"; then
       CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
     fi
+  elif test "$compiler_id" = "CLANG"; then
+    CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors"
   fi
 fi
 AC_SUBST(CURL_CFLAG_EXTRAS)
@@ -5023,6 +5025,7 @@ AC_MSG_NOTICE([Configured to build curl/libcurl:
   Install prefix:   ${prefix}
   Compiler:         ${CC}
    CFLAGS:          ${CFLAGS}
+   CFLAGS extras:   ${CURL_CFLAG_EXTRAS}
    CPPFLAGS:        ${CPPFLAGS}
    LDFLAGS:         ${LDFLAGS}
    LIBS:            ${LIBS}
index 4868395c5313141e538a7a4eff45ab183465f657..89993b17199eb063a1499fe69f5625a2ed3e18f8 100644 (file)
@@ -43,6 +43,7 @@
 
 #ifdef __clang__
 #pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpointer-bool-conversion"
 #pragma clang diagnostic ignored "-Wtautological-pointer-compare"
 #endif /* __clang__ */
 
index 06cf1b21773dad489abb5c69af041c911434f229..001e5f4aa40bb9021c323317f6ca5b1ce27821de 100644 (file)
@@ -519,6 +519,7 @@ AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
         dnl warn about compile-time arguments used during link-time, like
         dnl -O and -g and -pedantic.
         tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
+        tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
         ;;
         #
       DEC_C)
@@ -897,10 +898,6 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
             tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"  # we have silencing markup for clang 10.0 and above only
           fi
         fi
-        dnl Disable pointer to bool conversion warnings since they cause
-        dnl lib/securetransp.c cause several warnings for checks we want.
-        dnl This option should be placed after -Wconversion.
-        tmp_CFLAGS="$tmp_CFLAGS -Wno-pointer-bool-conversion"
         ;;
         #
       DEC_C)