aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-08-05 08:05:16 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-05 08:12:08 -0400
commit2cdbc46d7b2cb0acb68c3ecad93b000552121fa6 (patch)
treef56deaa9e5c3c030d1a0c53a158a43a3212759d8 /tools
parent114cfab222233f50f46d7162cf7d99fdc6c271e5 (diff)
perf: Auto-detect libbfd
Since the C++ demangling isn't needed for everybody and bfd/iberty aren't widely/easily available on all machines, make it optional. It also allows you to forcefully disable demangling by using NO_DEMANGLE=1 and otherwise tries to detect libbfd/libiberty combinations that result in a compiling demangler. Reported-by: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Kyle McMartin <kyle@mcmartin.ca> LKML-Reference: <20090801082048.GX12579@kernel.dk> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile18
-rw-r--r--tools/perf/util/symbol.c9
2 files changed, 26 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4b20fa47c3ab..ff905aceb4fd 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -345,7 +345,6 @@ BUILTIN_OBJS += builtin-stat.o
345BUILTIN_OBJS += builtin-top.o 345BUILTIN_OBJS += builtin-top.o
346 346
347PERFLIBS = $(LIB_FILE) 347PERFLIBS = $(LIB_FILE)
348EXTLIBS = -lbfd -liberty
349 348
350# 349#
351# Platform specific tweaks 350# Platform specific tweaks
@@ -374,6 +373,23 @@ ifeq ($(uname_S),Darwin)
374 PTHREAD_LIBS = 373 PTHREAD_LIBS =
375endif 374endif
376 375
376ifdef NO_DEMANGLE
377 BASIC_CFLAGS += -DNO_DEMANGLE
378else
379
380 has_bfd := $(shell sh -c "(echo '\#include <stdio.h>'; echo '\#include <bfd.h>'; echo '\#ifndef DMGL_PARAMS'; echo '\#define DMGL_PARAMS (1 << 0)'; echo '\#define DMGL_ANSI (1 << 1)'; echo '\#endif'; echo 'int main(int argc, char **argv) { bfd_demangle(NULL, argv[0], DMGL_PARAMS | DMGL_ANSI); return 0; }') | gcc -x c - -lbfd > /dev/null 2>&1 && echo y")
381
382 has_bfd_iberty := $(shell sh -c "(echo '\#include <stdio.h>'; echo '\#include <bfd.h>'; echo '\#ifndef DMGL_PARAMS'; echo '\#define DMGL_PARAMS (1 << 0)'; echo '\#define DMGL_ANSI (1 << 1)'; echo '\#endif'; echo 'int main(int argc, char **argv) { bfd_demangle(NULL, argv[0], DMGL_PARAMS | DMGL_ANSI); return 0; }') | gcc -x c - -lbfd -liberty > /dev/null 2>&1 && echo y")
383
384 ifeq ($(has_bfd),y)
385 EXTLIBS += -lbfd
386 else ifeq ($(has_bfd_iberty),y)
387 EXTLIBS += -lbfd -liberty
388 else
389 BASIC_CFLAGS += -DNO_DEMANGLE
390 endif
391endif
392
377ifndef CC_LD_DYNPATH 393ifndef CC_LD_DYNPATH
378 ifdef NO_R_TO_GCC_LINKER 394 ifdef NO_R_TO_GCC_LINKER
379 # Some gcc does not accept and pass -R to the linker to specify 395 # Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index b4fe0579bd6b..0580b94785e7 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,7 +6,16 @@
6#include <libelf.h> 6#include <libelf.h>
7#include <gelf.h> 7#include <gelf.h>
8#include <elf.h> 8#include <elf.h>
9
10#ifndef NO_DEMANGLE
9#include <bfd.h> 11#include <bfd.h>
12#else
13static inline
14char *bfd_demangle(void __used *v, const char __used *c, int __used i)
15{
16 return NULL;
17}
18#endif
10 19
11const char *sym_hist_filter; 20const char *sym_hist_filter;
12 21