All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change
@ 2015-09-15  5:48 Ian Munsie
  2015-09-17  5:13 ` Michael Ellerman
  2015-11-25 16:16 ` [PATCH] " Torsten Duwe
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Munsie @ 2015-09-15  5:48 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Anton Blanchard, Michael Neuling, linuxppc-dev, Ian Munsie

From: Ian Munsie <imunsie@au1.ibm.com>

A recent change in gcc caused this build failure:

/var/lib/jenkins/workspace/gcc_kernel_build/linux/drivers/misc/cxl/cxl.h:72:27:
error: ‘CXL_PSL_DLCNTL’ defined but not used [-Werror=unused-const-variable]
 static const cxl_p1_reg_t CXL_PSL_DLCNTL  = {0x0060};

Because of this gcc commit:

Commit 1bca8cbd0c68366f07277f98ce6963e10c2aa617 by mark
PR28901 -Wunused-variable ignores unused const initialised variables in C
12 years ago it was decided that -Wunused-variable shouldn't warn about
static const variables because some code used const static char rcsid[]
strings which were never used but wanted in the code anyway. But as the
bug points out this hides some real bugs. These days the usage of
rcsids is not very popular anymore. So this patch changes the default
to warn about unused static const variables in C with
-Wunused-variable. And it adds a new option -Wno-unused-const-variable
to turn this warning off. For C++ this new warning is off by default,
since const variables can be used as #defines in C++. New testcases for
the new defaults in C and C++ are included testing the new warning and
suppressing it with an unused attribute or using
-Wno-unused-const-variable. gcc/ChangeLog

The cxl driver uses static consts in place of #defines in some cases
for type safety, so this change causes the driver to fail to build on
new copilers as these constants are not all used in every file that
imports the header. Suppress the warning for this driver to return to
the old behaviour of -Wunused-variable.

Reported-by: Anton Blanchard <anton@au1.ibm.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 drivers/misc/cxl/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
index 6f484df..6982f60 100644
--- a/drivers/misc/cxl/Makefile
+++ b/drivers/misc/cxl/Makefile
@@ -1,4 +1,4 @@
-ccflags-y := -Werror
+ccflags-y := -Werror -Wno-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
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: cxl: Fix build failure due to -Wunused-variable behaviour change
  2015-09-15  5:48 [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change Ian Munsie
@ 2015-09-17  5:13 ` Michael Ellerman
  2015-11-25 16:16 ` [PATCH] " Torsten Duwe
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2015-09-17  5:13 UTC (permalink / raw)
  To: Ian Munsie, Michael Ellerman
  Cc: linuxppc-dev, Michael Neuling, Anton Blanchard, Ian Munsie

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]

On Tue, 2015-15-09 at 05:48:34 UTC, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> A recent change in gcc caused this build failure:
> 
> /var/lib/jenkins/workspace/gcc_kernel_build/linux/drivers/misc/cxl/cxl.h:72:27:
> error: ‘CXL_PSL_DLCNTL’ defined but not used [-Werror=unused-const-variable]
>  static const cxl_p1_reg_t CXL_PSL_DLCNTL  = {0x0060};
> 
> Because of this gcc commit:
> 
> Commit 1bca8cbd0c68366f07277f98ce6963e10c2aa617 by mark
> PR28901 -Wunused-variable ignores unused const initialised variables in C
> 12 years ago it was decided that -Wunused-variable shouldn't warn about
> static const variables because some code used const static char rcsid[]
> strings which were never used but wanted in the code anyway. But as the
> bug points out this hides some real bugs. These days the usage of
> rcsids is not very popular anymore. So this patch changes the default
> to warn about unused static const variables in C with
> -Wunused-variable. And it adds a new option -Wno-unused-const-variable
> to turn this warning off. For C++ this new warning is off by default,
> since const variables can be used as #defines in C++. New testcases for
> the new defaults in C and C++ are included testing the new warning and
> suppressing it with an unused attribute or using
> -Wno-unused-const-variable. gcc/ChangeLog
> 
> The cxl driver uses static consts in place of #defines in some cases
> for type safety, so this change causes the driver to fail to build on
> new copilers as these constants are not all used in every file that
> imports the header. Suppress the warning for this driver to return to
> the old behaviour of -Wunused-variable.
> 
> Reported-by: Anton Blanchard <anton@au1.ibm.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/2cd55c68c0a49a75433b15c7

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change
  2015-09-15  5:48 [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change Ian Munsie
  2015-09-17  5:13 ` Michael Ellerman
@ 2015-11-25 16:16 ` Torsten Duwe
  2015-11-25 22:58   ` Anton Blanchard
  2015-11-25 23:41   ` Michael Ellerman
  1 sibling, 2 replies; 6+ messages in thread
From: Torsten Duwe @ 2015-11-25 16:16 UTC (permalink / raw)
  To: Ian Munsie
  Cc: Michael Ellerman, linuxppc-dev, Michael Neuling, Anton Blanchard

On Tue, Sep 15, 2015 at 03:48:34PM +1000, Ian Munsie wrote:
> --- a/drivers/misc/cxl/Makefile
> +++ b/drivers/misc/cxl/Makefile
> @@ -1,4 +1,4 @@
> -ccflags-y := -Werror
> +ccflags-y := -Werror -Wno-unused-const-variable

JFYI, my gcc-4.3 does not like this switch.
What's the minimum compiler version to build this code?

	Torsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change
  2015-11-25 16:16 ` [PATCH] " Torsten Duwe
@ 2015-11-25 22:58   ` Anton Blanchard
  2015-11-25 23:41   ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Anton Blanchard @ 2015-11-25 22:58 UTC (permalink / raw)
  To: Torsten Duwe; +Cc: Ian Munsie, Michael Ellerman, linuxppc-dev, Michael Neuling

Hi Torsten,

> > -ccflags-y := -Werror
> > +ccflags-y := -Werror -Wno-unused-const-variable
> 
> JFYI, my gcc-4.3 does not like this switch.
> What's the minimum compiler version to build this code?

-Werror is such a moving target. I'm also seeing issues when building
with clang, eg:

drivers/misc/cxl/native.c:223:20: warning: unused function
'detach_spa' [-Wunused-function]

Anton

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change
  2015-11-25 16:16 ` [PATCH] " Torsten Duwe
  2015-11-25 22:58   ` Anton Blanchard
@ 2015-11-25 23:41   ` Michael Ellerman
  2015-12-01 14:47     ` Torsten Duwe
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2015-11-25 23:41 UTC (permalink / raw)
  To: Torsten Duwe, Ian Munsie
  Cc: linuxppc-dev, Michael Neuling, Anton Blanchard, Michael Ellerman

On Wed, 2015-11-25 at 17:16 +0100, Torsten Duwe wrote:
> On Tue, Sep 15, 2015 at 03:48:34PM +1000, Ian Munsie wrote:
> > --- a/drivers/misc/cxl/Makefile
> > +++ b/drivers/misc/cxl/Makefile
> > @@ -1,4 +1,4 @@
> > -ccflags-y := -Werror
> > +ccflags-y := -Werror -Wno-unused-const-variable
> 
> JFYI, my gcc-4.3 does not like this switch.
> What's the minimum compiler version to build this code?

I build everything with gcc 4.4.4, so if it breaks with that I will notice.

Does it work if you wrap it in cc-option? eg:

ccflags-y := -Werror $(call cc-option,-Wno-unused-const-variable)


cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change
  2015-11-25 23:41   ` Michael Ellerman
@ 2015-12-01 14:47     ` Torsten Duwe
  0 siblings, 0 replies; 6+ messages in thread
From: Torsten Duwe @ 2015-12-01 14:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Ian Munsie, linuxppc-dev, Michael Neuling, Anton Blanchard,
	Michael Ellerman

On Thu, Nov 26, 2015 at 10:41:53AM +1100, Michael Ellerman wrote:
> On Wed, 2015-11-25 at 17:16 +0100, Torsten Duwe wrote:
> > On Tue, Sep 15, 2015 at 03:48:34PM +1000, Ian Munsie wrote:
> > > --- a/drivers/misc/cxl/Makefile
> > > +++ b/drivers/misc/cxl/Makefile
> > > @@ -1,4 +1,4 @@
> > > -ccflags-y := -Werror
> > > +ccflags-y := -Werror -Wno-unused-const-variable
> > 
> > JFYI, my gcc-4.3 does not like this switch.
> > What's the minimum compiler version to build this code?
> 
> I build everything with gcc 4.4.4, so if it breaks with that I will notice.
> 
> Does it work if you wrap it in cc-option? eg:
> 
> ccflags-y := -Werror $(call cc-option,-Wno-unused-const-variable)

Yes, now it builds. It also looks cleaner to me: compilers which check
for "unused-const-variable"s should have this switch and the check is disabled.
All other (known :) warnings error out.

	Torsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-12-01 14:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15  5:48 [PATCH] cxl: Fix build failure due to -Wunused-variable behaviour change Ian Munsie
2015-09-17  5:13 ` Michael Ellerman
2015-11-25 16:16 ` [PATCH] " Torsten Duwe
2015-11-25 22:58   ` Anton Blanchard
2015-11-25 23:41   ` Michael Ellerman
2015-12-01 14:47     ` Torsten Duwe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.