Setting tag linux-2.6-32-36
[linux-2.6.git] / linux-2.6-10004-gcc-4.6-perf.patch
1 From    Darren Hart <>
2 Subject [PATCH] perf: fix gcc4.6 build failure with unused-but-set warning
3 Date    Thu, 2 Jun 2011 13:47:48 -0700
4 I ran into the following build failure with gcc 4.6:
5
6         bench/sched-pipe.c: In function 'bench_sched_pipe':
7         bench/sched-pipe.c:58:6: error: variable 'ret' set but not used
8         [-Werror=unused-but-set-variable]
9         cc1: all warnings being treated as errors
10
11 As the main kernel Makefile has added -Wno-unused-but-set-variable
12 and sched-pipe.c claims:
13
14         /*
15          * why does "ret" exist?
16          * discarding returned value of read(), write()
17          * causes error in building environment for perf
18          */
19 This patch creates a new perf/Makefile variable, LESS_WARNINGS and
20 adds -Wno-unused-but-set-variable. The new variable helps distinguish
21 between the added warnings in EXTRA_WARNINGS versus those we want to
22 remove, including the existing -Wno-system-headers which I moved to
23 LESS_WARNINGS.
24
25 Signed-off-by: Darren Hart <dvhart@linux.intel.com>
26 Cc: Ingo Molnar <mingo@elte.hu>
27 Cc: Bruce Ashfield <bruce.ashfield@windriver.com>
28 ---
29  tools/perf/Makefile |   10 ++++++++--
30  1 files changed, 8 insertions(+), 2 deletions(-)
31 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
32 index 032ba63..fdb35dc 100644
33 --- a/tools/perf/Makefile
34 +++ b/tools/perf/Makefile
35 @@ -74,7 +74,6 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
36  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
37  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
38  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
39 -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
40  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
41  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
42  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
43 @@ -85,6 +84,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
44  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
45  EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
46  
47 +#
48 +# Disable warnings that cause build problems or needlessly polute output:
49 +#
50 +
51 +LESS_WARNINGS := -Wno-system-headers
52 +LESS_WARNINGS := $(LESS_WARNINGS) -Wno-unused-but-set-variable
53 +
54  ifeq ("$(origin DEBUG)", "command line")
55    PERF_DEBUG = $(DEBUG)
56  endif
57 @@ -92,7 +98,7 @@ ifndef PERF_DEBUG
58    CFLAGS_OPTIMIZE = -O6
59  endif
60  
61 -CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
62 +CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(LESS_WARNINGS) $(EXTRA_CFLAGS)
63  EXTLIBS = -lpthread -lrt -lelf -lm
64  ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
65  ALL_LDFLAGS = $(LDFLAGS)