public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning
@ 2011-06-02 20:47 Darren Hart
  2011-06-02 21:27 ` Darren Hart
  2011-06-03  7:41 ` Ingo Molnar
  0 siblings, 2 replies; 3+ messages in thread
From: Darren Hart @ 2011-06-02 20:47 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Darren Hart, Ingo Molnar, Bruce Ashfield

I ran into the following build failure with gcc 4.6:

	bench/sched-pipe.c: In function 'bench_sched_pipe':
	bench/sched-pipe.c:58:6: error: variable 'ret' set but not used
	[-Werror=unused-but-set-variable]
	cc1: all warnings being treated as errors

As the main kernel Makefile has added -Wno-unused-but-set-variable
and sched-pipe.c claims:

	/*
	 * why does "ret" exist?
	 * discarding returned value of read(), write()
	 * causes error in building environment for perf
	 */

This patch creates a new perf/Makefile variable, LESS_WARNINGS and
adds -Wno-unused-but-set-variable. The new variable helps distinguish
between the added warnings in EXTRA_WARNINGS versus those we want to
remove, including the existing -Wno-system-headers which I moved to
LESS_WARNINGS.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 tools/perf/Makefile |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 032ba63..fdb35dc 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -74,7 +74,6 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
-EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
@@ -85,6 +84,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
 
+#
+# Disable warnings that cause build problems or needlessly polute output:
+#
+
+LESS_WARNINGS := -Wno-system-headers
+LESS_WARNINGS := $(LESS_WARNINGS) -Wno-unused-but-set-variable
+
 ifeq ("$(origin DEBUG)", "command line")
   PERF_DEBUG = $(DEBUG)
 endif
@@ -92,7 +98,7 @@ ifndef PERF_DEBUG
   CFLAGS_OPTIMIZE = -O6
 endif
 
-CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
+CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(LESS_WARNINGS) $(EXTRA_CFLAGS)
 EXTLIBS = -lpthread -lrt -lelf -lm
 ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 ALL_LDFLAGS = $(LDFLAGS)
-- 
1.7.1


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

* Re: [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning
  2011-06-02 20:47 [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning Darren Hart
@ 2011-06-02 21:27 ` Darren Hart
  2011-06-03  7:41 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Darren Hart @ 2011-06-02 21:27 UTC (permalink / raw)
  To: Darren Hart; +Cc: Linux Kernel Mailing List, Ingo Molnar, Bruce Ashfield

Nevermind, this appears to be user error as the __used directive now
upstream should address this. Apologies.

--
Darren

On 06/02/2011 01:47 PM, Darren Hart wrote:
> I ran into the following build failure with gcc 4.6:
> 
> 	bench/sched-pipe.c: In function 'bench_sched_pipe':
> 	bench/sched-pipe.c:58:6: error: variable 'ret' set but not used
> 	[-Werror=unused-but-set-variable]
> 	cc1: all warnings being treated as errors
> 
> As the main kernel Makefile has added -Wno-unused-but-set-variable
> and sched-pipe.c claims:
> 
> 	/*
> 	 * why does "ret" exist?
> 	 * discarding returned value of read(), write()
> 	 * causes error in building environment for perf
> 	 */
> 
> This patch creates a new perf/Makefile variable, LESS_WARNINGS and
> adds -Wno-unused-but-set-variable. The new variable helps distinguish
> between the added warnings in EXTRA_WARNINGS versus those we want to
> remove, including the existing -Wno-system-headers which I moved to
> LESS_WARNINGS.
> 
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Bruce Ashfield <bruce.ashfield@windriver.com>
> ---
>  tools/perf/Makefile |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 032ba63..fdb35dc 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -74,7 +74,6 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
> -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
> @@ -85,6 +84,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
>  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
>  
> +#
> +# Disable warnings that cause build problems or needlessly polute output:
> +#
> +
> +LESS_WARNINGS := -Wno-system-headers
> +LESS_WARNINGS := $(LESS_WARNINGS) -Wno-unused-but-set-variable
> +
>  ifeq ("$(origin DEBUG)", "command line")
>    PERF_DEBUG = $(DEBUG)
>  endif
> @@ -92,7 +98,7 @@ ifndef PERF_DEBUG
>    CFLAGS_OPTIMIZE = -O6
>  endif
>  
> -CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
> +CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(LESS_WARNINGS) $(EXTRA_CFLAGS)
>  EXTLIBS = -lpthread -lrt -lelf -lm
>  ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
>  ALL_LDFLAGS = $(LDFLAGS)

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel

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

* Re: [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning
  2011-06-02 20:47 [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning Darren Hart
  2011-06-02 21:27 ` Darren Hart
@ 2011-06-03  7:41 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2011-06-03  7:41 UTC (permalink / raw)
  To: Darren Hart; +Cc: Linux Kernel Mailing List, Bruce Ashfield


* Darren Hart <dvhart@linux.intel.com> wrote:

> This patch creates a new perf/Makefile variable, LESS_WARNINGS and 
> adds -Wno-unused-but-set-variable. The new variable helps 
> distinguish between the added warnings in EXTRA_WARNINGS versus 
> those we want to remove, including the existing -Wno-system-headers 
> which I moved to LESS_WARNINGS.

Btw., while you resolved the issue, it would nevertheless nice to 
introduce a 'make WERROR=0' build method that removes -Werror.

Would you be interested in sending a patch for that?

There would be several advantages of such a patch:

 - GCC often introduces new warnings with lots of false positives - 
   breaking -Werror builds. WERROR=0 would allow one to build perf 
   without much fuss - while people would still send patches to avoid 
   the fuss of having to type WERROR=0 :-)

 - bisecting back to commits that produce a (mostly harmless) warning 
   on some compiler is more difficult. With WERROR=0 one could bisect 
   without worrying about harmless warnings.

Thanks,

	Ingo

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

end of thread, other threads:[~2011-06-03  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-02 20:47 [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning Darren Hart
2011-06-02 21:27 ` Darren Hart
2011-06-03  7:41 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox