Skip to contentSkip to conversation

perf: Fix broken build by rearranging some #includes

PATCH In review David Daney 3 participants 5 messages Jan 17, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix broken build by rearranging some #includes

From: David Daney <[email protected]>

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.

Since the #include situation is a little convoluted throughout perf, I did the following:

1) Always include util/util.h before all other include files.

2) Remove all #define _GNU_SOURCE, as it is already done in util.h.

3) Remove all #undef _GNU_SOURCE, as they don't do what a naive person might expect (or much of anything for that matter) and clutter up the source.

4) #include ctype.h in util.h, so that ctype things have uniform definitions throughout perf.

5) Remove #define of _FILE_OFFSET_BITS where util/util.h is already providing it.

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

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Joerg Roedel <[email protected]>
---
 tools/perf/builtin-annotate.c                      |    2 +-
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin-diff.c                          |    2 +-
 tools/perf/builtin-evlist.c                        |    3 +--
 tools/perf/builtin-kmem.c                          |    2 +-
 tools/perf/builtin-kvm.c                           |    2 +-
 tools/perf/builtin-lock.c                          |    2 +-
 tools/perf/builtin-probe.c                         |    5 ++---
 tools/perf/builtin-record.c                        |    2 +-
 tools/perf/builtin-report.c                        |    3 +--
 tools/perf/builtin-sched.c                         |    2 +-
 tools/perf/builtin-script.c                        |    2 +-
 tools/perf/builtin-stat.c                          |    2 +-
 tools/perf/builtin-timechart.c                     |    3 +--
 tools/perf/builtin-top.c                           |    2 +-
 tools/perf/util/cache.h                            |    2 +-
 tools/perf/util/callchain.c                        |    2 +-
 tools/perf/util/debug.c                            |    2 +-
 tools/perf/util/dwarf-aux.c                        |    2 +-
 tools/perf/util/evlist.h                           |    2 +-
 tools/perf/util/evsel.c                            |    2 +-
 tools/perf/util/header.c                           |    2 --
 tools/perf/util/hist.c                             |    2 +-
 tools/perf/util/parse-events.c                     |    2 +-
 tools/perf/util/probe-event.c                      |    4 +---
 tools/perf/util/probe-finder.c                     |    2 +-
 tools/perf/util/probe-finder.h                     |    2 +-
 .../perf/util/scripting-engines/trace-event-perl.c |    2 +-
 tools/perf/util/session.c                          |    3 ++-
 tools/perf/util/sort.h                             |    5 +++--
 tools/perf/util/thread.c                           |    2 +-
 tools/perf/util/trace-event-parse.c                |    5 ++---
 tools/perf/util/trace-event-read.c                 |    3 +--
 tools/perf/util/trace-event-scripting.c            |    2 +-
 tools/perf/util/ui/browsers/hists.c                |    4 +---
 tools/perf/util/util.c                             |    2 +-
 tools/perf/util/util.h                             |    1 +
 tools/perf/util/values.c                           |    2 +-
 tools/perf/util/xyarray.c                          |    2 +-
 39 files changed, 43 insertions(+), 52 deletions(-)
tools/perf/builtin-annotate.c +1 -1
index 806e0a2..e9f4bd7 100644
@@ -5,9 +5,9 @@
  * look up and read DSOs and symbol information and display
  * a histogram of results, along various sorting keys.
  */
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
-#include "util/util.h"
 #include "util/color.h"
 #include <linux/list.h>
 #include "util/cache.h"
tools/perf/builtin-bench.c +1 -1
index fcb9626..3d8fbea 100644
@@ -16,8 +16,8 @@
  *
  */
 
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "perf.h"
-#include "util/util.h"
 #include "util/parse-options.h"
 #include "builtin.h"
 #include "bench/bench.h"
tools/perf/builtin-diff.c +1 -1
index 4f19513..a5692fe 100644
@@ -4,6 +4,7 @@
  * Builtin diff command: Analyze two perf.data input files, look up and read
  * DSOs and symbol information, sort them and produce a diff.
  */
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
 #include "util/debug.h"
@@ -14,7 +15,6 @@
 #include "util/tool.h"
 #include "util/sort.h"
 #include "util/symbol.h"
-#include "util/util.h"
 
 #include <stdlib.h>
 
tools/perf/builtin-evlist.c +1 -2
index 2676032..ce78b37 100644
@@ -2,10 +2,9 @@
  * Builtin evlist command: Show the list of event selectors present
  * in a perf.data file.
  */
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
-#include "util/util.h"
-
 #include <linux/list.h>
 
 #include "perf.h"
tools/perf/builtin-kmem.c +1 -1
index 39104c0..40e95bc 100644
@@ -1,7 +1,7 @@
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-kvm.c +1 -1
index 9fc6e0f..3557dd8 100644
@@ -1,7 +1,7 @@
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-lock.c +1 -1
index 2296c39..c490905 100644
@@ -1,7 +1,7 @@
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-probe.c +2 -3
index 59d43ab..f93710a 100644
@@ -20,7 +20,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  */
-#define _GNU_SOURCE
+
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include <sys/utsname.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -31,10 +32,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#undef _GNU_SOURCE
 #include "perf.h"
 #include "builtin.h"
-#include "util/util.h"
 #include "util/strlist.h"
 #include "util/strfilter.h"
 #include "util/symbol.h"
tools/perf/builtin-record.c +1 -1
index 0abfb18..dcf8159 100644
@@ -5,8 +5,8 @@
  * (or a CPU, or a PID) into the perf.data output file - for
  * later analysis via perf report.
  */
-#define _FILE_OFFSET_BITS 64
 
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
 #include "perf.h"
tools/perf/builtin-report.c +1 -2
index 25d34d4..886fd79 100644
@@ -5,10 +5,9 @@
  * look up and read DSOs and symbol information and display
  * a histogram of results, along various sorting keys.
  */
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
-#include "util/util.h"
-
 #include "util/annotate.h"
 #include "util/color.h"
 #include <linux/list.h>
tools/perf/builtin-sched.c +1 -1
index fb8b5f8..9189852 100644
@@ -1,7 +1,7 @@
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
 #include "util/evlist.h"
 #include "util/cache.h"
 #include "util/evsel.h"
tools/perf/builtin-script.c +1 -1
index bb68ddf..98204e6 100644
@@ -1,3 +1,4 @@
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
 #include "perf.h"
@@ -11,7 +12,6 @@
 #include "util/symbol.h"
 #include "util/thread.h"
 #include "util/trace-event.h"
-#include "util/util.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include <linux/bitmap.h>
tools/perf/builtin-stat.c +1 -1
index f5d2a63..8f8b53f 100644
@@ -41,9 +41,9 @@
  * Released under the GPL v2. (and only v2, not any later version)
  */
 
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "perf.h"
 #include "builtin.h"
-#include "util/util.h"
 #include "util/parse-options.h"
 #include "util/parse-events.h"
 #include "util/event.h"
tools/perf/builtin-timechart.c +1 -2
index 3b75b2e..88e1a46 100644
@@ -12,10 +12,9 @@
  * of the License.
  */
 
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
-#include "util/util.h"
-
 #include "util/color.h"
 #include <linux/list.h>
 #include "util/cache.h"
tools/perf/builtin-top.c +1 -1
index 8f80df8..37acc74 100644
@@ -17,6 +17,7 @@
  *
  * Released under the GPL v2. (and only v2, not any later version)
  */
+#include "util/util.h" /* Include first, it forces things in features.h */
 #include "builtin.h"
 
 #include "perf.h"
@@ -31,7 +32,6 @@
 #include "util/thread.h"
 #include "util/thread_map.h"
 #include "util/top.h"
-#include "util/util.h"
 #include <linux/rbtree.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
tools/perf/util/cache.h +1 -1
index fc5e5a0..bdcfa57 100644
@@ -1,8 +1,8 @@
 #ifndef __PERF_CACHE_H
 #define __PERF_CACHE_H
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdbool.h>
-#include "util.h"
 #include "strbuf.h"
 #include "../perf.h"
 
tools/perf/util/callchain.c +1 -1
index 9f7106a..adb2d84 100644
@@ -9,13 +9,13 @@
  *
  */
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <errno.h>
 #include <math.h>
 
-#include "util.h"
 #include "callchain.h"
 
 bool ip_callchain__valid(struct ip_callchain *chain,
tools/perf/util/debug.c +1 -1
index 26817da..c15f342 100644
@@ -1,5 +1,6 @@
 /* For general debugging purposes */
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include "../perf.h"
 
 #include <string.h>
@@ -10,7 +11,6 @@
 #include "color.h"
 #include "event.h"
 #include "debug.h"
-#include "util.h"
 
 int verbose;
 bool dump_trace = false, quiet = false;
tools/perf/util/dwarf-aux.c +1 -1
index ee51e9b..0edf62f 100644
@@ -17,8 +17,8 @@
  *
  */
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdbool.h>
-#include "util.h"
 #include "debug.h"
 #include "dwarf-aux.h"
 
tools/perf/util/evlist.h +1 -1
index 8922aee..b9f80c0 100644
@@ -1,11 +1,11 @@
 #ifndef __PERF_EVLIST_H
 #define __PERF_EVLIST_H 1
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <linux/list.h>
 #include <stdio.h>
 #include "../perf.h"
 #include "event.h"
-#include "util.h"
 #include <unistd.h>
 
 struct pollfd;
tools/perf/util/evsel.c +1 -1
index 667f3b7..a63c302 100644
@@ -7,11 +7,11 @@
  * Released under the GPL v2. (and only v2, not any later version)
  */
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <byteswap.h>
 #include "asm/bug.h"
 #include "evsel.h"
 #include "evlist.h"
-#include "util.h"
 #include "cpumap.h"
 #include "thread_map.h"
 
tools/perf/util/header.c +0 -2
index 3e7e0b0..c555656 100644
@@ -1,5 +1,3 @@
-#define _FILE_OFFSET_BITS 64
-
 #include "util.h"
 #include <sys/types.h>
 #include <byteswap.h>
tools/perf/util/hist.c +1 -1
index 6f505d1..0ef4829 100644
@@ -1,5 +1,5 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include "annotate.h"
-#include "util.h"
 #include "build-id.h"
 #include "hist.h"
 #include "session.h"
tools/perf/util/parse-events.c +1 -1
index b029296..7ead31a 100644
@@ -1,5 +1,5 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include "../../../include/linux/hw_breakpoint.h"
-#include "util.h"
 #include "../perf.h"
 #include "evlist.h"
 #include "evsel.h"
tools/perf/util/probe-event.c +1 -3
index eb25900..492fa41 100644
@@ -18,8 +18,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  */
+#include "util.h" /* Include first, as it forces things in features.h */
 
-#define _GNU_SOURCE
 #include <sys/utsname.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -33,8 +33,6 @@
 #include <limits.h>
 #include <elf.h>
 
-#undef _GNU_SOURCE
-#include "util.h"
 #include "event.h"
 #include "string.h"
 #include "strlist.h"
tools/perf/util/probe-finder.c +1 -1
index 5d73262..4bd79e4 100644
@@ -20,6 +20,7 @@
  */
 
 #include <sys/utsname.h>
+#include "util.h" /* Include first, it forces things in features.h */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -36,7 +37,6 @@
 #include <linux/bitops.h>
 #include "event.h"
 #include "debug.h"
-#include "util.h"
 #include "symbol.h"
 #include "probe-finder.h"
 
tools/perf/util/probe-finder.h +1 -1
index 17e94d0..c0a7c1b 100644
@@ -1,8 +1,8 @@
 #ifndef _PROBE_FINDER_H
 #define _PROBE_FINDER_H
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdbool.h>
-#include "util.h"
 #include "probe-event.h"
 
 #define MAX_PROBE_BUFFER	1024
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
index e30749e..605d20c 100644
@@ -19,6 +19,7 @@
  *
  */
 
+#include "../util.h" /* Include first, it forces things in features.h */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -26,7 +27,6 @@
 #include <errno.h>
 
 #include "../../perf.h"
-#include "../util.h"
 #include "../thread.h"
 #include "../event.h"
 #include "../trace-event.h"
tools/perf/util/session.c +2 -1
index b5ca255..c3a25df 100644
@@ -1,4 +1,5 @@
-#define _FILE_OFFSET_BITS 64
+
+#include "util.h" /* Include first, it forces things in features.h */
 
 #include <linux/kernel.h>
 
tools/perf/util/sort.h +3 -2
index 3f67ae3..4ba8f11 100644
@@ -1,8 +1,9 @@
 #ifndef __PERF_SORT_H
 #define __PERF_SORT_H
-#include "../builtin.h"
 
-#include "util.h"
+#include "util.h" /* Include first, it forces things in features.h */
+
+#include "../builtin.h"
 
 #include "color.h"
 #include <linux/list.h>
tools/perf/util/thread.c +1 -1
index fb4b7ea..e550a4a 100644
@@ -1,10 +1,10 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include "../perf.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include "session.h"
 #include "thread.h"
-#include "util.h"
 #include "debug.h"
 
 static struct thread *thread__new(pid_t pid)
tools/perf/util/trace-event-parse.c +2 -3
index 6c164dc..e80e1fd 100644
@@ -21,16 +21,15 @@
  *  The parts for function graph printing was taken and modified from the
  *  Linux Kernel that were written by Frederic Weisbecker.
  */
-#define _GNU_SOURCE
+#include "util.h" /* Include first, it forces things in features.h */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
 
-#undef _GNU_SOURCE
 #include "../perf.h"
-#include "util.h"
 #include "trace-event.h"
 
 int header_page_ts_offset;
tools/perf/util/trace-event-read.c +1 -2
index f55cc3a..035ebff 100644
@@ -18,7 +18,7 @@
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
-#define _FILE_OFFSET_BITS 64
+#include "util.h" /* Include first, it forces things in features.h */
 
 #include <dirent.h>
 #include <stdio.h>
@@ -37,7 +37,6 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
 #include "trace-event.h"
 
 static int input_fd;
tools/perf/util/trace-event-scripting.c +1 -1
index a3fdf55..26e1e6d 100644
@@ -19,6 +19,7 @@
  *
  */
 
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -26,7 +27,6 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
 #include "trace-event.h"
 
 struct scripting_context *scripting_context;
tools/perf/util/ui/browsers/hists.c +1 -3
index 1212a38..b85c3c6 100644
@@ -1,6 +1,5 @@
-#define _GNU_SOURCE
+#include "../../util.h" /* Include first, it forces things in features.h */
 #include <stdio.h>
-#undef _GNU_SOURCE
 #include "../libslang.h"
 #include <stdlib.h>
 #include <string.h>
@@ -12,7 +11,6 @@
 #include "../../hist.h"
 #include "../../pstack.h"
 #include "../../sort.h"
-#include "../../util.h"
 
 #include "../browser.h"
 #include "../helpline.h"
tools/perf/util/util.c +1 -1
index 8131410..b35089f 100644
@@ -1,5 +1,5 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include "../perf.h"
-#include "util.h"
 #include <sys/mman.h>
 
 /*
tools/perf/util/util.h +1 -0
index b9c530c..8e64cab 100644
@@ -80,6 +80,7 @@
 #include "../../../include/linux/magic.h"
 #include "types.h"
 #include <sys/ttydefaults.h>
+#include <ctype.h>
 
 extern const char *graph_line;
 extern const char *graph_dotted_line;
tools/perf/util/values.c +1 -1
index 697c8b4e..5e4183d 100644
@@ -1,6 +1,6 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include <stdlib.h>
 
-#include "util.h"
 #include "values.h"
 
 void perf_read_values_init(struct perf_read_values *values)
tools/perf/util/xyarray.c +1 -1
index 22afbf6..fa7af9f 100644
@@ -1,5 +1,5 @@
+#include "util.h" /* Include first, it forces things in features.h */
 #include "xyarray.h"
-#include "util.h"
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
 {
Signature · 1 line
1.7.2.3
#1 lore raw

Hi,

Quoted 8 lines · David Daney

From: David Daney<[email protected]>

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.

I've experienced similar problem wrt pwrite() last week. The fix was simply removing ctype.h from inclusion for my case.

Quoted 9 lines

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

Since the #include situation is a little convoluted throughout perf, I did the following:

1) Always include util/util.h before all other include files.

Quoted 8 lines

2) Remove all #define _GNU_SOURCE, as it is already done in util.h.

3) Remove all #undef _GNU_SOURCE, as they don't do what a naive person might expect (or much of anything for that matter) and clutter up the source.

4) #include ctype.h in util.h, so that ctype things have uniform definitions throughout perf.

Among other things, ctype.h isn't needed at all since util.h redefines all of ctype macros anyway. I've posted a patch which removes ctype.h inclusions as Ingo's suggestion.

https://lkml.org/lkml/2012/1/16/510

Thanks,
Namhyung Kim

#2 lore raw
In reply to David Daney

Hi, again

Quoted 23 lines · David Daney

From: David Daney<[email protected]>

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.

Since the #include situation is a little convoluted throughout perf, I did the following:

1) Always include util/util.h before all other include files.

2) Remove all #define _GNU_SOURCE, as it is already done in util.h.

3) Remove all #undef _GNU_SOURCE, as they don't do what a naive person might expect (or much of anything for that matter) and clutter up the source.

Quoted 7 lines

4) #include ctype.h in util.h, so that ctype things have uniform definitions throughout perf.

5) Remove #define of _FILE_OFFSET_BITS where util/util.h is already providing it.

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

Instead of reordering, how about adding -D_GNU_SOURCE on Makefile and removing the line from util.h? If util.h would always be included at first, the end result should be same, right? And this way, we don't need to care about the ordering anymore.

Thanks,
Namhyung

#3 lore raw
Quoted 32 lines · Namhyung Kim

Hi, again

Quoted 29 lines · David Daney

From: David Daney<[email protected]>

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.

Since the #include situation is a little convoluted throughout perf, I did the following:

1) Always include util/util.h before all other include files.

2) Remove all #define _GNU_SOURCE, as it is already done in util.h.

3) Remove all #undef _GNU_SOURCE, as they don't do what a naive person might expect (or much of anything for that matter) and clutter up the source.

4) #include ctype.h in util.h, so that ctype things have uniform definitions throughout perf.

5) Remove #define of _FILE_OFFSET_BITS where util/util.h is already providing it.

Quoted 7 lines
Quoted 1 line

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

Instead of reordering, how about adding -D_GNU_SOURCE on Makefile and removing the line from util.h? If util.h would always be included at first, the end result should be same, right? And this way, we don't need to care about the ordering anymore.

Yeah, that is better. I had tried it first, but then reversed course as I found so many random #define _GNU_SOURCE, that I thought there must have been a reason.

Upon further thought on the subject, I think you are right. We need to present a consistent set of features.h defines to the entire perf program.

I withdraw this patch from consideration, and will send a new one soon, that does the -D_GNU_SOURCE.

David Daney

#4 lore raw
In reply to David Daney

Hi, again.

Quoted 23 lines · David Daney

From: David Daney<[email protected]>

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.

Since the #include situation is a little convoluted throughout perf, I did the following:

1) Always include util/util.h before all other include files.

2) Remove all #define _GNU_SOURCE, as it is already done in util.h.

3) Remove all #undef _GNU_SOURCE, as they don't do what a naive person might expect (or much of anything for that matter) and clutter up the source.

Quoted 7 lines

4) #include ctype.h in util.h, so that ctype things have uniform definitions throughout perf.

5) Remove #define of _FILE_OFFSET_BITS where util/util.h is already providing it.

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

Instead of reordering, how about adding -D_GNU_SOURCE on Makefile and removing the line from util.h? If util.h would always be included at first, the end result should be same, right? And this way, we don't need to care about the ordering anymore.

Thanks,
Namhyung