From: Ian Munsie <hidden> Date: 2015-09-15 05:50:02
From: Ian Munsie <redacted>
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 <redacted>
Signed-off-by: Ian Munsie <redacted>
---
drivers/misc/cxl/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-09-17 05:13:28
On Tue, 2015-15-09 at 05:48:34 UTC, Ian Munsie wrote:
From: Ian Munsie <redacted>
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 <redacted>
Signed-off-by: Ian Munsie <redacted>
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
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
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