Skip to contentSkip to conversation

ARC: build: Turn off -Wmaybe-uninitialized for ARC gcc 4.8

PATCH In review Vineet Gupta 2 participants 8 messages Mar 18, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARC: build: Turn off -Wmaybe-uninitialized for ARC gcc 4.8

linux-next has been reporting gazillion warnings for ARC build and I finally decided to take a bite:

http://kisskb.ellerman.id.au/kisskb/buildresult/12638735/

Most of the them are due to -Wmaybe-uninitialized

| ../kernel/sysctl.c: In function '__do_proc_doulongvec_minmax':
| ../kernel/sysctl.c:1928:12: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
|   ret = tmp - *buf;
|            ^
| ../kernel/sysctl.c:2342:29: note: 'p' was declared here
|  char *kbuf = NULL, *p;
|                     ^
| ...
| ...

Cursory look at code seemed fine and a definite gcc false positive in say kernel/sysctl.c

Mystery was why only for ARC (and not with ARM linaro toolchain based off same gcc 4.8). Turns out that -O3 (default for ARC) triggers these and if I enable -O3 for ARM kernel build, I see the same splat.

I doubt if gcc folks are going to fix warnings in gcc 4.8 (specially when this was the much advertised front page feature @
https://gcc.gnu.org/gcc-4.8/porting_to.html

Better to to silent these for ARC, atleast for gcc 4.8 when we know that these warnings are likely benign.

When we switch to later gcc, these will come back on and at that time we could fixing gcc and/or relevant kernel code.

Cc Claudiu Zissulescu <Claudiu.Zissulescu at synopsys.com>
Cc Arnd Bergmann <arnd at arndb.de>
Cc Michal Marek <mmarek at suse.cz>
Cc Geert Uytterhoeven <geert at linux-m68k.org>
Cc linux-kbuild at vger.kernel.org
Cc linux-kernel at vger.kernel.org
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
arch/arc/Makefile +5 -0
index fed12f39d8ce..aeb101e8e674 100644
@@ -48,9 +48,14 @@ endif
 upto_gcc44    :=  $(call cc-ifversion, -le, 0404, y)
 atleast_gcc44 :=  $(call cc-ifversion, -ge, 0404, y)
 atleast_gcc48 :=  $(call cc-ifversion, -ge, 0408, y)
+is_gcc48      :=  $(call cc-ifversion, -eq, 0408, y)
 
 cflags-$(atleast_gcc44)			+= -fsection-anchors
 
+# gcc 4.8 spits out false positives for default -O3
+# disable these for 4.8 and revisit when we upgrade to newer ver
+cflags-$(is_gcc48)			+= $(call cc-disable-warning,maybe-uninitialized,)
+
 cflags-$(CONFIG_ARC_HAS_LLSC)		+= -mlock
 cflags-$(CONFIG_ARC_HAS_SWAPE)		+= -mswape
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 8 lines · On Friday 18 March 2016 14:16:23 Vineet Gupta wrote:
arch/arc/Makefile +0 -0
index fed12f39d8ce..aeb101e8e674 100644
@@ -48,9 +48,14 @@ endif
 upto_gcc44    :=  $(call cc-ifversion, -le, 0404, y)
 atleast_gcc44 :=  $(call cc-ifversion, -ge, 0404, y)
 atleast_gcc48 :=  $(call cc-ifversion, -ge, 0408, y)

arch/arc/Makefile endif · line 60

Quoted 10 lines
arch/arc/Makefile +5 -0
+is_gcc48      :=  $(call cc-ifversion, -eq, 0408, y)
 
 cflags-$(atleast_gcc44)                        += -fsection-anchors
 
+# gcc 4.8 spits out false positives for default -O3
+# disable these for 4.8 and revisit when we upgrade to newer ver
+cflags-$(is_gcc48)                     += $(call cc-disable-warning,maybe-uninitialized,)
+
 cflags-$(CONFIG_ARC_HAS_LLSC)          += -mlock
 cflags-$(CONFIG_ARC_HAS_SWAPE)         += -mswape

Is this any better with gcc-4.9 or gcc-5? Maybe it's better to add the flag to the line that adds -O3 for consistency. We do the same thing for -Os in the global Makefile, as that triggers a similar load of warnings.

Arnd

#2 lore raw
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Friday 18 March 2016 14:16:23 Vineet Gupta wrote:
arch/arc/Makefile +1 -0
index fed12f39d8ce..aeb101e8e674 100644
@@ -48,9 +48,14 @@ endif
 upto_gcc44    :=  $(call cc-ifversion, -le, 0404, y)
 atleast_gcc44 :=  $(call cc-ifversion, -ge, 0404, y)
 atleast_gcc48 :=  $(call cc-ifversion, -ge, 0408, y)
+is_gcc48      :=  $(call cc-ifversion, -eq, 0408, y)
 
 cflags-$(atleast_gcc44)                        += -fsection-anchors
 
Quoted 8 lines

arch/arc/Makefile endif · line 60

Quoted 6 lines
arch/arc/Makefile +4 -0
+# gcc 4.8 spits out false positives for default -O3
+# disable these for 4.8 and revisit when we upgrade to newer ver
+cflags-$(is_gcc48)                     += $(call cc-disable-warning,maybe-uninitialized,)
+
 cflags-$(CONFIG_ARC_HAS_LLSC)          += -mlock
 cflags-$(CONFIG_ARC_HAS_SWAPE)         += -mswape

Is this any better with gcc-4.9 or gcc-5?

I don't think there's a production ARC toolchain with gcc 4.9 which we can use yet
- Claudiu is still in the the middle of upstreaming the new ARC HS port bits so things are still in flight there. These tools are off of github !

Maybe it's better to add the flag to

Quoted 2 lines

the line that adds -O3 for consistency. We do the same thing for -Os in the global Makefile, as that triggers a similar load of warnings.

Sure, but I prefer this to be only for gcc 4.8 as this warning seems to be healthy in small doses :-) At least it keeps the door open for future discussion with gcc guys !

The following nested construct actually works - does that look OK to you ?

ARCH_CFLAGS += -O3 $(call cc-ifversion, -lt, 0408, $(call cc-disable-warning,maybe-uninitialized,))

Thx,
-Vineet

Quoted 7 lines

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 3 lines · On Friday 18 March 2016 15:50:11 Vineet Gupta wrote:

Sure, but I prefer this to be only for gcc 4.8 as this warning seems to be healthy in small doses At least it keeps the door open for future discussion with gcc guys !

FWIW, testing on ARM with gcc-6.0 -O3, I also get tons of maybe-uninitialized warnings. It's unlikely that this is architecture specific or fixed in newer compiler versions.

Quoted 3 lines

The following nested construct actually works - does that look OK to you ?

ARCH_CFLAGS += -O3 $(call cc-ifversion, -lt, 0408, $(call cc-disable-warning,maybe-uninitialized,))

Yes, that seems ok.

I don't really understand why -O3 is needed though, maybe it's better to assume that it won't be needed in future gcc versions and do

ARCH_CFLAGS += $(call cc-ifversion, -lt, 0408, -O3 $(call cc-disable-warning,maybe-uninitialized,))

Arnd

#4 lore raw
Quoted 8 lines · Arnd Bergmann
Quoted 3 lines · On Friday 18 March 2016 15:50:11 Vineet Gupta wrote:

Sure, but I prefer this to be only for gcc 4.8 as this warning seems to be healthy in small doses At least it keeps the door open for future discussion with gcc guys !

FWIW, testing on ARM with gcc-6.0 -O3, I also get tons of maybe-uninitialized warnings. It's unlikely that this is architecture specific or fixed in newer compiler versions.

So we disable this for good just like -Os.
What a shame - seemed like a reasonable safety net for programming errors.

Quoted 5 lines
Quoted 3 lines

The following nested construct actually works - does that look OK to you ?

ARCH_CFLAGS += -O3 $(call cc-ifversion, -lt, 0408, $(call cc-disable-warning,maybe-uninitialized,))

Yes, that seems ok.

There was typo actually -lt needed to be -eq

Quoted 2 lines

I don't really understand why -O3 is needed though, maybe it's better to assume that it won't be needed in future gcc versions and do

Not sure what you mean, -O3 for triggering the warnings or -O3 in ARC makefile at all. Assuming it's latter, this is how its been forever and was added consciously as performance seemed better with -O3 than the default -O2.

Quoted 9 lines

ARCH_CFLAGS += $(call cc-ifversion, -lt, 0408, -O3 $(call cc-disable-warning,maybe-uninitialized,))

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 6 lines · On Friday 18 March 2016 16:13:28 Vineet Gupta wrote:
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · On Friday 18 March 2016 15:50:11 Vineet Gupta wrote:

Sure, but I prefer this to be only for gcc 4.8 as this warning seems to be healthy in small doses At least it keeps the door open for future discussion with gcc guys !

Quoted 6 lines
Quoted 3 lines

FWIW, testing on ARM with gcc-6.0 -O3, I also get tons of maybe-uninitialized warnings. It's unlikely that this is architecture specific or fixed in newer compiler versions.

So we disable this for good just like -Os.
What a shame - seemed like a reasonable safety net for programming errors.

Yes, it's an immensely useful warning, if you manage to avoid the false positives.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

The following nested construct actually works - does that look OK to you ?

ARCH_CFLAGS += -O3 $(call cc-ifversion, -lt, 0408, $(call cc-disable-warning,maybe-uninitialized,))

Yes, that seems ok.

Quoted 8 lines

There was typo actually -lt needed to be -eq

Quoted 2 lines

I don't really understand why -O3 is needed though, maybe it's better to assume that it won't be needed in future gcc versions and do

Not sure what you mean, -O3 for triggering the warnings or -O3 in ARC makefile at all. Assuming it's latter, this is how its been forever and was added consciously as performance seemed better with -O3 than the default -O2.

I think it's dangerous to use -O3 in one architecture when nothing else uses it. If you don't have a strong reason to use -O3, maybe just drop that use the default -O2 -Wmaybe-uninitialized like everyone else does.

On a related note, I have submitted a patch that turns CONFIG_CC_OPTIMIZE_FOR_SIZE into a choice statement, so we actually get the -Wmaybe-uninitialized warnings in an allyesconfig or allmodconfig build. It would be trivial to extend that to give the choice between -Os, -O2 and -O3, and then pick -O3 in a defconfig, over the -O2 default.

Arnd

#6 lore raw
Quoted 3 lines · Arnd Bergmann

I think it's dangerous to use -O3 in one architecture when nothing else uses it. If you don't have a strong reason to use -O3, maybe just drop that use the default -O2 -Wmaybe-uninitialized like everyone else does.

I know what u mean. In fact top level makefile change has bitten us atleast once. However ARC gcc tends to generate better code (likely others do too) at -O3 and increased inlining etc reflects in several benchmarks. Maybe its due to the micro-architecture and smaller hardware call return stack - I'm not sure. So I'm ready to pay that maintenance price. And it has been like this for 5+ years and I fear that switching to -O2 might unravel something unwarranted for.

OTOH, I'd rather prefer -O3 for all arches but that ain't gonna happen for obvious reasons :-)

Quoted 5 lines

On a related note, I have submitted a patch that turns CONFIG_CC_OPTIMIZE_FOR_SIZE into a choice statement, so we actually get the -Wmaybe-uninitialized warnings in an allyesconfig or allmodconfig build. It would be trivial to extend that to give the choice between -Os, -O2 and -O3, and then pick -O3 in a defconfig, over the -O2 default.

Is it posted already. I couldn't find it with quick googling.

Thx,
-Vineet

#7 lore raw
Quoted 10 lines · On Friday 18 March 2016 18:31:53 Vineet Gupta wrote:
Quoted 6 lines

On a related note, I have submitted a patch that turns CONFIG_CC_OPTIMIZE_FOR_SIZE into a choice statement, so we actually get the -Wmaybe-uninitialized warnings in an allyesconfig or allmodconfig build. It would be trivial to extend that to give the choice between -Os, -O2 and -O3, and then pick -O3 in a defconfig, over the -O2 default.

Is it posted already. I couldn't find it with quick googling.

https://lkml.org/lkml/2016/2/12/315

Arnd