Re: [PATCH] basic perf support for sparc

From: Kyle McMartin
Date: Sun Aug 02 2009 - 15:45:24 EST


On Sun, Aug 02, 2009 at 08:41:48PM +0200, Ingo Molnar wrote:
> Could we somehow define a weak symbol for those library functions
> ourselves and thus just fall back to that (which does nothing)
> instead of failing the link?
>

Well, you could just dlopen the object, but that's kind of gross...

Why not abuse the perf Makefile, which already has this kind of
portability gunk in it?

$ make NO_BFD_DEMANGLE=1
succeeds with no libbfd.

$ make
succeeds when libbfd is around.

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index a5e9b87..67ab097 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -345,7 +345,6 @@ BUILTIN_OBJS += builtin-stat.o
BUILTIN_OBJS += builtin-top.o

PERFLIBS = $(LIB_FILE)
-EXTLIBS = -lbfd

#
# Platform specific tweaks
@@ -541,6 +540,11 @@ endif
ifdef NO_EXTERNAL_GREP
BASIC_CFLAGS += -DNO_EXTERNAL_GREP
endif
+ifdef NO_BFD_DEMANGLE
+ BASIC_CFLAGS += -DNO_BFD_DEMANGLE
+else
+ EXTLIBS += -lbfd
+endif

ifeq ($(PERL_PATH),)
NO_PERL=NoThanks
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2810605..736b8db 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,10 +6,20 @@
#include <libelf.h>
#include <gelf.h>
#include <elf.h>
+
+#ifndef NO_BFD_DEMANGLE
#include <bfd.h>
+#endif /* NO_BFD_DEMANGLE */

const char *sym_hist_filter;

+#ifdef NO_BFD_DEMANGLE
+static inline char *bfd_demangle(void __used *v, const char __used *c,
+ int __used i) {
+ return NULL;
+}
+#endif
+
#ifndef DMGL_PARAMS
#define DMGL_PARAMS (1 << 0) /* Include function args */
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/