mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Michal Marek <mmarek@suse.cz>
Subject: [18/25] kbuild: Fix passing -Wno-* options to gcc 4.4+
Date: Tue, 22 Nov 2011 16:21:08 -0800	[thread overview]
Message-ID: <20111123002208.684095615@clark.kroah.org> (raw)
In-Reply-To: <20111123002222.GA2376@kroah.com>

2.6.32-longterm review patch.  If anyone has any objections, please let me know.

------------------
Content-Length: 3254
Lines: 78

From: Michal Marek <mmarek@suse.cz>

commit 8417da6f2128008c431c7d130af6cd3d9079922e upstream.

Starting with 4.4, gcc will happily accept -Wno-<anything> in the
cc-option test and complain later when compiling a file that has some
other warning. This rather unexpected behavior is intentional as per
http://gcc.gnu.org/PR28322, so work around it by testing for support of
the opposite option (without the no-). Introduce a new Makefile function
cc-disable-warning that does this and update two uses of cc-option in
the toplevel Makefile.

Reported-and-tested-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 Documentation/kbuild/makefiles.txt |   12 ++++++++++++
 Makefile                           |    4 ++--
 scripts/Kbuild.include             |    5 +++++
 3 files changed, 19 insertions(+), 2 deletions(-)

--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -502,6 +502,18 @@ more details, with real examples.
 	gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used.
 	Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options
 
+    cc-disable-warning
+	cc-disable-warning checks if gcc supports a given warning and returns
+	the commandline switch to disable it. This special function is needed,
+	because gcc 4.4 and later accept any unknown -Wno-* option and only
+	warn about it if there is another warning in the source file.
+
+	Example:
+		KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+
+	In the above example, -Wno-unused-but-set-variable will be added to
+	KBUILD_CFLAGS only if gcc really accepts it.
+
     cc-version
 	cc-version returns a numerical version of the $(CC) compiler version.
 	The format is <major><minor> where both are two digits. So for example
--- a/Makefile
+++ b/Makefile
@@ -538,7 +538,7 @@ KBUILD_CFLAGS += $(call cc-option, -fno-
 endif
 
 # This warning generated too much noise in a regular build.
-KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
@@ -568,7 +568,7 @@ CHECKFLAGS     += $(NOSTDINC_FLAGS)
 KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 
 # disable pointer signed / unsigned warnings in gcc 4.0
-KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
+KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
 
 # disable invalid "can't wrap" optimizations for signed / pointers
 KBUILD_CFLAGS	+= $(call cc-option,-fno-strict-overflow)
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\
 cc-option-align = $(subst -functions=0,,\
 	$(call cc-option,-falign-functions=0,-malign-functions=0))
 
+# cc-disable-warning
+# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
+cc-disable-warning = $(call try-run,\
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+
 # cc-version
 # Usage gcc-ver := $(call cc-version)
 cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))



  parent reply	other threads:[~2011-11-23  1:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23  0:22 [00/25] 2.6.32.49-longterm review Greg KH
2011-11-23  0:20 ` [01/25] [SCSI] st: fix race in st_scsi_execute_end Greg KH
2011-11-23  0:20 ` [02/25] [SCSI] Make scsi_free_queue() kill pending SCSI commands Greg KH
2011-11-23  0:20 ` [03/25] NFS/sunrpc: dont use a credential with extra groups Greg KH
2011-11-23  0:20 ` [04/25] netlink: validate NLA_MSECS length Greg KH
2011-11-23  0:20 ` [05/25] mtd: mtdchar: add missing initializer on raw write Greg KH
2011-11-23  0:20 ` [06/25] PM / Suspend: Off by one in pm_suspend() Greg KH
2011-11-23  0:20 ` [07/25] hfs: add sanity check for file name length Greg KH
2011-11-23  0:20 ` [08/25] kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0 Greg KH
2011-11-23  0:20 ` [09/25] ASoC: wm8940: Properly set codec->dapm.bias_level Greg KH
2011-11-23  0:21 ` [10/25] md/raid5: abort any pending parity operations when array fails Greg KH
2011-11-23  0:21 ` [11/25] [media] Remove the old V4L1 v4lgrab.c file Greg KH
2011-11-23  0:21 ` [12/25] Revert "ALSA: hda: Fix quirk for Dell Inspiron 910" Greg KH
2011-11-23  0:21 ` [13/25] drm/i915: Sanity check pread/pwrite Greg KH
2011-11-23  0:21 ` [14/25] drm/i915: Rephrase pwrite bounds checking to avoid any potential overflow Greg KH
2011-11-23  0:21 ` [15/25] genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier Greg KH
2011-11-23  0:21 ` [16/25] mm: avoid null pointer access in vm_struct via /proc/vmallocinfo Greg KH
2011-11-23  0:21 ` [17/25] ipv6: udp: fix the wrong headroom check Greg KH
2011-11-23  0:21 ` Greg KH [this message]
2011-11-23  0:21 ` [19/25] USB: serial: pl2303: rm duplicate id Greg KH
2011-11-23  0:21 ` [20/25] USB: Fix Corruption issue in USB ftdi driver ftdi_sio.c Greg KH
2011-11-23  0:21 ` [21/25] usb-storage: Accept 8020i-protocol commands longer than 12 bytes Greg KH
2011-11-23  0:21 ` [22/25] USB: add quirk for Logitech C600 web cam Greg KH
2011-11-23  0:21 ` [23/25] USB: quirks: adding more quirky webcams to avoid squeaky audio Greg KH
2011-11-23  0:21 ` [24/25] tty: Make tiocgicount a handler Greg KH
2011-11-23  0:21 ` [25/25] tty: icount changeover for other main devices Greg KH

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=20111123002208.684095615@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --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

all inboxes | Powered by JetHome®