Subject: Re: Build failure: -Wno-unused-const-variable DNE on old GCC

From: Arnd Bergmann <[email-masked]>
Date: Thu, 07 Jan 2016 21:25:51 +0100

On Thursday 07 January 2016 10:54:06 Brian Norris wrote:
> 
> I'm using a GCC 4.6.3 compiler for some compile tests, and I noticed
> that commit 2cd55c68c0a4 ("cxl: Fix build failure due to -Wunused-variable
> behaviour change") breaks my builds, because the
> -Wno-unused-const-variable doesn't exist on GCC 4.6.3.
> 
>   drivers/misc/cxl/base.c: At top level:
>   cc1: error: unrecognized command line option "-Wno-unused-const-variable" [-Werror]
> 
> Any thoughts on how to best fix this? I'd like not to have to scrounge
> up a new cross compiler just for build tests.
> 

This should do:

diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
index 6982f603fadc..add2cc17ed91 100644
--- a/drivers/misc/cxl/Makefile
+++ b/drivers/misc/cxl/Makefile
@@ -1,4 +1,4 @@
-ccflags-y := -Werror -Wno-unused-const-variable
+ccflags-y := -Werror $(call cc-disable-warning,unused-const-variable)
 
 cxl-y				+= main.o file.o irq.o fault.o native.o
 cxl-y				+= context.o sysfs.o debugfs.o pci.o trace.o

Alternatively, remove the -Werror. We occasionally get people that add this
flag to a Makefile, but it tends to cause more trouble whenever a new
gcc version arrives.

	Arnd