From 369216b039833d30b92cee44d448821ebd4077ce Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 1 Mar 2022 22:54:58 -0700 Subject: [PATCH] ath: fix older clang build. Define NO_WUNUSED_BUT_SET_VARIABLE for newer clang, and use it in ATH_C to account for different clang versions. Use it in Makefiles as well. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D34408 --- sys/conf/kern.mk | 6 +++++- sys/conf/kern.pre.mk | 2 +- sys/modules/ath/Makefile | 2 +- sys/modules/ath_ahb/Makefile | 2 +- sys/modules/ath_dfs/Makefile | 2 +- sys/modules/ath_hal/Makefile | 2 +- sys/modules/ath_hal_ar5210/Makefile | 2 +- sys/modules/ath_hal_ar5211/Makefile | 2 +- sys/modules/ath_hal_ar5212/Makefile | 2 +- sys/modules/ath_hal_ar5416/Makefile | 2 +- sys/modules/ath_hal_ar9300/Makefile | 2 +- sys/modules/ath_main/Makefile | 2 +- sys/modules/ath_pci/Makefile | 2 +- sys/modules/ath_rate/Makefile | 2 +- 14 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 06a0c1272704..c1228ed1bc6f 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -47,7 +47,7 @@ CWARNFLAGS+= -Wno-error=unused-but-set-variable .if ${COMPILER_TYPE} == "gcc" # Catch-all for all the things that are in our tree, but for which we're # not yet ready for this compiler. -NO_WUNUSED_BUT_SET_VARIABLE = -Wno-unused-but-set-variable +NO_WUNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable CWARNEXTRA?= -Wno-error=address \ -Wno-error=aggressive-loop-optimizations \ -Wno-error=array-bounds \ @@ -90,6 +90,10 @@ CWARNFLAGS+= -Wno-format-zero-length FORMAT_EXTENSIONS= -Wno-format .elif ${COMPILER_TYPE} == "clang" FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ +# Only newer versions of clang have -Wno-unused-but-set-variable +.if ${COMPILER_VERSION} >= 130000 +NO_WUNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable +.endif .else FORMAT_EXTENSIONS= -fformat-extensions .endif diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index f36613f8a609..3ba837d9de11 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -263,7 +263,7 @@ ZFS_RPC_C= ${CC} -c ${ZFS_CFLAGS} -DHAVE_RPC_TYPES ${WERROR} ${.IMPSRC} ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC} # ATH driver -ATH_CFLAGS= -I${SRCTOP}/sys/dev/ath -Wno-unused-but-set-variable +ATH_CFLAGS= -I${SRCTOP}/sys/dev/ath ${NO_WUNUSED_BUT_SET_VARIABLE} ATH_C= ${CC} -c ${CFLAGS} ${WERROR} ${ATH_CFLAGS} ${.IMPSRC} # Special flags for managing the compat compiles for DTrace diff --git a/sys/modules/ath/Makefile b/sys/modules/ath/Makefile index 5697a6464e15..c312058a4abf 100644 --- a/sys/modules/ath/Makefile +++ b/sys/modules/ath/Makefile @@ -42,4 +42,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_ahb/Makefile b/sys/modules/ath_ahb/Makefile index ee2fe2adb5da..02278eadea2b 100644 --- a/sys/modules/ath_ahb/Makefile +++ b/sys/modules/ath_ahb/Makefile @@ -40,4 +40,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/dev/ath -I${SRCTOP}/sys/dev/ath/ath_hal .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_dfs/Makefile b/sys/modules/ath_dfs/Makefile index db49f6b20109..93c6b64e23ce 100644 --- a/sys/modules/ath_dfs/Makefile +++ b/sys/modules/ath_dfs/Makefile @@ -46,4 +46,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal/Makefile b/sys/modules/ath_hal/Makefile index 92beae8420b6..e21698918e76 100644 --- a/sys/modules/ath_hal/Makefile +++ b/sys/modules/ath_hal/Makefile @@ -47,4 +47,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ EXPORT_SYMS= YES CWARNFLAGS.ah_regdomain.c= ${NO_WSHIFT_COUNT_NEGATIVE} ${NO_WSHIFT_COUNT_OVERFLOW} -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal_ar5210/Makefile b/sys/modules/ath_hal_ar5210/Makefile index f327b980ef5b..57302b01bdf3 100644 --- a/sys/modules/ath_hal_ar5210/Makefile +++ b/sys/modules/ath_hal_ar5210/Makefile @@ -52,4 +52,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal_ar5211/Makefile b/sys/modules/ath_hal_ar5211/Makefile index 19788ab835fa..29f03932f640 100644 --- a/sys/modules/ath_hal_ar5211/Makefile +++ b/sys/modules/ath_hal_ar5211/Makefile @@ -54,4 +54,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal_ar5212/Makefile b/sys/modules/ath_hal_ar5212/Makefile index 93b47315ba4c..53ab389ba4e0 100644 --- a/sys/modules/ath_hal_ar5212/Makefile +++ b/sys/modules/ath_hal_ar5212/Makefile @@ -59,4 +59,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal_ar5416/Makefile b/sys/modules/ath_hal_ar5416/Makefile index a3dbbd041cfc..7169a92c429f 100644 --- a/sys/modules/ath_hal_ar5416/Makefile +++ b/sys/modules/ath_hal_ar5416/Makefile @@ -90,4 +90,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_hal_ar9300/Makefile b/sys/modules/ath_hal_ar9300/Makefile index 7d709d319a85..1145777f1838 100644 --- a/sys/modules/ath_hal_ar9300/Makefile +++ b/sys/modules/ath_hal_ar9300/Makefile @@ -57,4 +57,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ # AR9300 HAL build overrides, as there's still some code to tidy up CWARNFLAGS.ar9300_eeprom.c= ${NO_WCONSTANT_CONVERSION} CWARNFLAGS.ar9300_reset.c= ${NO_WSOMETIMES_UNINITIALIZED} -Wno-unused-function -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_main/Makefile b/sys/modules/ath_main/Makefile index 7971df14c905..4cf55d42fc92 100644 --- a/sys/modules/ath_main/Makefile +++ b/sys/modules/ath_main/Makefile @@ -50,4 +50,4 @@ CFLAGS+= ${ATH_CFLAGS} # XXX Work around clang warnings, until maintainer approves fix. CWARNFLAGS.if_ath.c= ${NO_WSOMETIMES_UNINITIALIZED} -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_pci/Makefile b/sys/modules/ath_pci/Makefile index 7ed67fffca65..a5a2d87925ca 100644 --- a/sys/modules/ath_pci/Makefile +++ b/sys/modules/ath_pci/Makefile @@ -40,4 +40,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/dev/ath -I${SRCTOP}/sys/dev/ath/ath_hal .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE} diff --git a/sys/modules/ath_rate/Makefile b/sys/modules/ath_rate/Makefile index c6be915bc744..b36c1b426d30 100644 --- a/sys/modules/ath_rate/Makefile +++ b/sys/modules/ath_rate/Makefile @@ -56,4 +56,4 @@ CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .include -CWARNFLAGS+= -Wno-unused-but-set-variable +CWARNFLAGS+= ${NO_WUNUSED_BUT_SET_VARIABLE}