public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-kbuild@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Marek <mmarek@suse.cz>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Russell King - ARM Linux" <linux@arm.linux.org.uk>
Subject: [PATCH] Turn off -Wmaybe-uninitialized when building with -Os
Date: Mon, 25 Mar 2013 15:44:55 +0000	[thread overview]
Message-ID: <201303251544.55765.arnd@arndb.de> (raw)

gcc-4.7 and higher add a lot of false positive warnings about
potential uses of uninitialized warnings, but only when optimizing
for size (-Os). This is the default when building allyesconfig,
which turns on CONFIG_CC_OPTIMIZE_FOR_SIZE.

In order to avoid getting a lot of patches that initialize such
variables and accidentally hide real errors along the way, let's
just turn off this warning on the respective gcc versions
when building with size optimizations. The -Wmaybe-uninitialized
option was introduced in the same gcc version (4.7) that is now
causing the false positives, so there is no effect on older compilers.

A side effect is that when building with CONFIG_CC_OPTIMIZE_FOR_SIZE,
we might now see /fewer/ warnings about possibly uninitialized
warnings than with -O2, but that is still much better than seeing
warnings known to be bogus.

Building v3.9-rc3 allmodconfig shows how the number of false
positives is reduced:

74	x86-linux-gcc-4.7 -Os
12	x86-linux-gcc-4.7 -O2
 1	x86-linux-gcc-4.7 -Os -Wno-maybe-uninitialized
 8	arm-linux-gcc-4.6 -Os
 8	arm-linux-gcc-4.6 -Os
50	arm-linux-gcc-4.7 -Os
 8	arm-linux-gcc-4.7 -O2
 0	arm-linux-gcc-4.7 -Os -Wno-maybe-uninitialized
33	arm-linux-gcc-4.8 -Os
13	arm-linux-gcc-4.8 -O2
 0	arm-linux-gcc-4.8 -Os -Wno-maybe-uninitialized

The 8 to 13 warnings that are now hidden compared to the -O2 output
seem to all be false positives as well. The total number of
all other warnings I see is (independent of optimization level)

24	x86-linux-gcc-4.7
19	arm-linux-gcc-4.6
17	arm-linux-gcc-4.7
16	arm-linux-gcc-4.8

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
diff --git a/Makefile b/Makefile
index 22113a7..d8e3f36 100644
--- a/Makefile
+++ b/Makefile
@@ -570,7 +570,7 @@ endif # $(dot-config)
 all: vmlinux
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS	+= -Os
+KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,)
 else
 KBUILD_CFLAGS	+= -O2
 endif


             reply	other threads:[~2013-03-25 15:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 15:44 Arnd Bergmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-03-14 22:01 [PATCH] Turn off -Wmaybe-uninitialized when building with -Os Arnd Bergmann
2013-03-15 17:58 ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201303251544.55765.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mmarek@suse.cz \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox