On 1/2/26 12:27 AM, Craig Small via Net-snmp-coders wrote:
On Fri, 2 Jan 2026, 12:47 pm Magnus Fromreide, <[email protected] <mailto:[email protected]>> wrote:
    I am stronly agreeing and wants to go further - I think all dialect
    options
    should be removed from the net-snmp-config output, so no more

    -g
    -fno-strict-aliasing
    -O2

    as that should be the the choice of the client program, not us.

I would like that very much. As an example of the issue adding those options causes, syslog-ng failed to compile with 5.9.5.2 but compiled ok.

What happens is one of the options triggered a compile error in the syslog-ng code itself because a previous warning was now an error. So changing the version of net-snmp a program links to caused an error so it wouldn't compile; but not due to an API change.

How about realizing this with the patch below?

Thanks,

Bart.

diff --git a/net-snmp-config.in b/net-snmp-config.in
index c6005fe45a20..3e6453a8adc3 100644
--- a/net-snmp-config.in
+++ b/net-snmp-config.in
@@ -27,6 +27,22 @@ check_build_dir()
       fi
 }

+filter_cflags()
+{
+    read -r all_cflags
+    for cflag in ${all_cflags}; do
+       case "$cflag" in
+           -fsanitize*)
+               echo -n "$cflag ";;
+           -f*|-g*|-O*|-pipe|-W*|-I.)
+               ;;
+           *)
+               echo -n "$cflag ";;
+       esac
+    done
+    echo
+}
+
 # usage: index n arguments
 # effect: returns the (n+1)th argument
 index()
@@ -143,10 +159,11 @@ else
       ;;
     #################################################### compile
     --base-cflags)
-      echo @CFLAGS@ @CPPFLAGS@ -I${NSC_INCLUDEDIR}
+      echo @CFLAGS@ @CPPFLAGS@ -I${NSC_INCLUDEDIR} | filter_cflags
       ;;
     --cflags|--cf*)
-      echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR}
+      echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR} |
+       filter_cflags
       ;;
     --srcdir)
       echo $NSC_SRCDIR
@@ -188,7 +205,7 @@ else
       echo $result
       ;;
     --build-command)
-      echo "@CC@ @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@"
+      echo "@CC@ @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@" | filter_cflags
       ;;
     #################################################### client lib
     --libs)




_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to