Commit 0a84f007f97ce6fc7c07a481a5b9808b187a0193

Authored by David Daney
Committed by Arnaldo Carvalho de Melo
1 parent d0caf29250

perf tools: Fix broken build by defining _GNU_SOURCE in Makefile

When building on my Debian/mips system, util/util.c fails to build
because commit 1aed2671738785e8f5aea663a6fda91aa7ef59b5 (perf kvm: Do
guest-only counting by default) indirectly includes stdio.h before the
feature selection in util.h is done.  This prevents _GNU_SOURCE in
util.h from enabling the declaration of getline(), from now second
inclusion of stdio.h, and the build is broken.

There is another breakage in util/evsel.c caused by include ordering,
but I didn't fully track down the commit that caused it.

The root cause of all this is an inconsistent definition of _GNU_SOURCE,
so I move the definition into the Makefile so that it is passed to all
invocations of the compiler and used uniformly for all system header
files.  All other #define and #undef of _GNU_SOURCE are removed as they
cause conflicts with the definition passed to the compiler.

All the features.h definitions (_LARGEFILE64_SOURCE _FILE_OFFSET_BITS=64
and _GNU_SOURCE) are needed by the python glue code too, so they are
moved to BASIC_CFLAGS, and the misleading comments about BASIC_CFLAGS
are removed.

This gives me a clean build on x86_64 (fc12) and mips (Debian).

Cc: David Daney <david.daney@cavium.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1326836461-11952-1-git-send-email-ddaney.cavm@gmail.com
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 8 changed files with 3 additions and 16 deletions Side-by-side Diff

... ... @@ -104,7 +104,7 @@
104 104  
105 105 CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
106 106 EXTLIBS = -lpthread -lrt -lelf -lm
107   -ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
  107 +ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
108 108 ALL_LDFLAGS = $(LDFLAGS)
109 109 STRIP ?= strip
110 110  
... ... @@ -168,10 +168,7 @@
168 168  
169 169 ### --- END CONFIGURATION SECTION ---
170 170  
171   -# Those must not be GNU-specific; they are shared with perl/ which may
172   -# be built by a different compiler. (Note that this is an artifact now
173   -# but it still might be nice to keep that distinction.)
174   -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
  171 +BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
175 172 BASIC_LDFLAGS =
176 173  
177 174 # Guard against environment variables
tools/perf/builtin-probe.c
... ... @@ -20,7 +20,6 @@
20 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21 *
22 22 */
23   -#define _GNU_SOURCE
24 23 #include <sys/utsname.h>
25 24 #include <sys/types.h>
26 25 #include <sys/stat.h>
... ... @@ -31,7 +30,6 @@
31 30 #include <stdlib.h>
32 31 #include <string.h>
33 32  
34   -#undef _GNU_SOURCE
35 33 #include "perf.h"
36 34 #include "builtin.h"
37 35 #include "util/util.h"
tools/perf/util/probe-event.c
... ... @@ -19,7 +19,6 @@
19 19 *
20 20 */
21 21  
22   -#define _GNU_SOURCE
23 22 #include <sys/utsname.h>
24 23 #include <sys/types.h>
25 24 #include <sys/stat.h>
... ... @@ -33,7 +32,6 @@
33 32 #include <limits.h>
34 33 #include <elf.h>
35 34  
36   -#undef _GNU_SOURCE
37 35 #include "util.h"
38 36 #include "event.h"
39 37 #include "string.h"
tools/perf/util/symbol.c
1   -#define _GNU_SOURCE
2 1 #include <ctype.h>
3 2 #include <dirent.h>
4 3 #include <errno.h>
tools/perf/util/trace-event-parse.c
... ... @@ -21,14 +21,13 @@
21 21 * The parts for function graph printing was taken and modified from the
22 22 * Linux Kernel that were written by Frederic Weisbecker.
23 23 */
24   -#define _GNU_SOURCE
  24 +
25 25 #include <stdio.h>
26 26 #include <stdlib.h>
27 27 #include <string.h>
28 28 #include <ctype.h>
29 29 #include <errno.h>
30 30  
31   -#undef _GNU_SOURCE
32 31 #include "../perf.h"
33 32 #include "util.h"
34 33 #include "trace-event.h"
tools/perf/util/ui/browsers/hists.c
1   -#define _GNU_SOURCE
2 1 #include <stdio.h>
3   -#undef _GNU_SOURCE
4 2 #include "../libslang.h"
5 3 #include <stdlib.h>
6 4 #include <string.h>
tools/perf/util/ui/helpline.c
1   -#define _GNU_SOURCE
2 1 #include <stdio.h>
3 2 #include <stdlib.h>
4 3 #include <string.h>
tools/perf/util/util.h
... ... @@ -40,7 +40,6 @@
40 40 #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
41 41  
42 42 #define _ALL_SOURCE 1
43   -#define _GNU_SOURCE 1
44 43 #define _BSD_SOURCE 1
45 44 #define HAS_BOOL
46 45