NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/60185: bsd.sys.mk: add Clang warning suppressions for -Werror compatibility



>Number:         60185
>Category:       toolchain
>Synopsis:       bsd.sys.mk: add Clang warning suppressions for -Werror compatibility
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 12 06:45:01 +0000 2026
>Originator:     FireTurtle
>Release:        NetBSD-current (2026-04)
>Organization:
>Environment:
cross-build with Clang 22+ on Linux, targeting amd64/i386/vax
>Description:
I've been building NetBSD-current with a recent Clang (22+) and there
are quite a few -Werror failures from warnings that GCC doesnt emit.
Three warnings account for the bulk of the failures across the tree:

  -Wdeprecated-non-prototype    ~100+ files (binutils, openssl, heimdal, ...)
  -Wstrict-prototypes           ~50+ files  (same packages)
  -Wunused-but-set-variable     ~50+ files  (kernel, libc, external/)

These fire on all architectures (amd64, i386, etc.), not just
cross-builds. The first two will also fire with GCC 14+, which
netbsd-current already imports.

Per-file suppression would mean touching hundreds of Makefiles, many in
external/ code that gets re-imported regularly, so that doesn't seem
practical.

The patch uses -Wno-error= (not -Wno-) so the warnings are still
visible, just not fatal. It also adds -Wno-unknown-warning-option so
the same bsd.sys.mk works with both the in-tree Clang 13 and newer
versions.

This was discussed earlier on tech-toolchain ("Compiling with modern Clang").
>How-To-Repeat:
Build NetBSD-current with HAVE_LLVM=yes using Clang 14 or newer. Hundreds of -Werror failures from the three warnings listed above.
>Fix:
--- share/mk/bsd.sys.mk.orig
+++ share/mk/bsd.sys.mk
@@ -171,6 +171,18 @@
 
 CWARNFLAGS+=${CWARNFLAGS.${ACTIVE_CC}}
 
+# Clang warning suppressions for -Werror compatibility.
+# Silently ignore flags unknown to older Clang versions (the in-tree
+# Clang 13 does not know warnings added in Clang 14-23).
+.if ${ACTIVE_CC} == "clang"
+CWARNFLAGS.clang+=-Wno-unknown-warning-option
+# C23 strictness and Clang-vs-GCC divergences (100+ files each).
+# These also fire with GCC 14+ (-Wstrict-prototypes, -Wdeprecated-non-prototype).
+CWARNFLAGS.clang+=-Wno-error=deprecated-non-prototype
+CWARNFLAGS.clang+=-Wno-error=strict-prototypes
+CWARNFLAGS.clang+=-Wno-error=unused-but-set-variable
+.endif
+
 CPPFLAGS+=${AUDIT:D-D__AUDIT__}
 _NOWERROR=${defined(NOGCCERROR) || (${ACTIVE_CC} == "clang" && defined(NOCLANGERROR)):?yes:no}
 CFLAGS+=${${_NOWERROR} == "no" :?-Werror:} ${CWARNFLAGS}




Home | Main Index | Thread Index | Old Index