]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix propagation of cc_werr_cflags() output. [skip ci]
authorDenis Ovsienko <[email protected]>
Mon, 4 Mar 2024 11:43:20 +0000 (11:43 +0000)
committerDenis Ovsienko <[email protected]>
Thu, 4 Apr 2024 07:01:20 +0000 (08:01 +0100)
Same as in libpcap.  It is not the propagation that tcpdump needs from
this change, but the proper application of compiler options.

(cherry picked from commit f32255ba1324e14dcb3def10c9141adccb21cf60)

CHANGES
CMakeLists.txt
build_common.sh

diff --git a/CHANGES b/CHANGES
index f5eb70c6cad935205d5baa09eb56ab0be364bc3a..1883b9726a05888720891e5eb5bf5e7bde73e2fb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -84,6 +84,7 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
       Do not require vsnprintf().
       tests: Use the -tttt option, by default, for the tests.
       autoconf, CMake: Get the size of a void * and a time_t.
+      Fix propagation of cc_werr_cflags() output.
     Documentation:
       Fixed errors in doc/README.Win32.md.
 
index bf24ed19238e8ec8e049adc5ef2b4cf27e657100..ac30eca82369a43f2b7fe898779db99215ccadf2 100644 (file)
@@ -1063,9 +1063,13 @@ endif()
 # usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
 #
 if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
-    foreach(_extra_cflag ${EXTRA_CFLAGS})
-        check_and_add_compiler_option("${_extra_cflag}")
-    endforeach(_extra_cflag)
+    # The meaning of EXTRA_CFLAGS is "use the exact specified options, or the
+    # build risks failing to fail", not "try every specified option, omit those
+    # that do not work and use the rest".  Thus use add_compile_options(), not
+    # foreach()/check_and_add_compiler_option().  Another reason to do that is
+    # that the effect lasts in testprogs/ and testprogs/fuzz/.
+    string(REPLACE " " ";" _extra_cflags_list ${EXTRA_CFLAGS})
+    add_compile_options(${_extra_cflags_list})
     message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
 endif()
 
index 3c9d7d4c9fb7353a4b3d5bbac01e16cbeccf580f..a512f2840375fe84479d48112bb606a5890dd6d9 100644 (file)
@@ -179,7 +179,10 @@ cc_werr_cflags() {
         echo '-qhalt=w'
         ;;
     suncc-*)
-        echo '-errwarn=%all'
+        # GCC and Clang print an identification for every warning, which is
+        # useful for root cause analysis and bug fixing.  Sun C does not do it
+        # by default, but an additional option makes the style more consistent.
+        echo '-errwarn=%all -errtags=yes'
         ;;
     esac
 }