From: Ingo Molnar <mingo@elte.hu>
To: Marti Raudsepp <marti@juffo.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Arjan van de Ven <arjan@linux.intel.com>,
Mike Galbraith <efault@gmx.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tools: add compatibility with libelf 0.8 and autodetect
Date: Fri, 23 Oct 2009 23:02:31 +0200 [thread overview]
Message-ID: <20091023210231.GC8356@elte.hu> (raw)
In-Reply-To: <1256330234-14079-1-git-send-email-marti@juffo.org>
* Marti Raudsepp <marti@juffo.org> wrote:
> The Makefile now automatically defines LIBELF_NO_MMAP when libelf 0.8 is
> detected. libelf 0.8 is still maintained and some distributions such as
> Arch Linux use it instead of elfutils.
>
> Signed-off-by: Marti Raudsepp <marti@juffo.org>
> ---
> tools/perf/Makefile | 6 +++++-
> tools/perf/util/symbol.c | 12 ++++++++++++
> 2 files changed, 17 insertions(+), 1 deletions(-)
Nice fix!
Mind doing a small change:
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 742a32e..46e877b 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -422,7 +422,11 @@ ifeq ($(uname_S),Darwin)
> PTHREAD_LIBS =
> endif
>
> -ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
> +ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
> + ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
> + BASIC_CFLAGS += -DLIBELF_NO_MMAP
> + endif
> +else
> msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
> endif
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 47ea060..8d1df1e 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -413,7 +413,11 @@ static int dso__synthesize_plt_symbols(struct dso *self, int v)
> if (fd < 0)
> goto out;
>
> +#ifdef LIBELF_NO_MMAP
> + elf = elf_begin(fd, ELF_C_READ, NULL);
> +#else
> elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
> +#endif
> if (elf == NULL)
> goto out_close;
>
> @@ -533,7 +537,11 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
> Elf *elf;
> int nr = 0, kernel = !strcmp("[kernel]", self->name);
>
> +#ifdef LIBELF_NO_MMAP
> + elf = elf_begin(fd, ELF_C_READ, NULL);
> +#else
> elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
> +#endif
> if (elf == NULL) {
> if (v)
> fprintf(stderr, "%s: cannot read %s ELF file.\n",
> @@ -675,7 +683,11 @@ static char *dso__read_build_id(struct dso *self, int v)
> if (fd < 0)
> goto out;
>
> +#ifdef LIBELF_NO_MMAP
> + elf = elf_begin(fd, ELF_C_READ, NULL);
> +#else
> elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
> +#endif
> if (elf == NULL) {
> if (v)
> fprintf(stderr, "%s: cannot read %s ELF file.\n",
I think we want a small cleanup here: a perf_elf_begin() wrapper in a
header file to hide this #ifdef. (That's how Git wraps environmental
libraries as well.)
Also, this would be an urgent fix for v2.6.32 too, to make perf build on
Arch Linux, agreed?
Ingo
next prev parent reply other threads:[~2009-10-23 21:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-23 20:37 [PATCH] perf tools: add compatibility with libelf 0.8 and autodetect Marti Raudsepp
2009-10-23 21:02 ` Ingo Molnar [this message]
2009-10-23 21:48 ` Marti Raudsepp
2009-10-23 21:52 ` Ingo Molnar
2009-10-23 22:10 ` Marti Raudsepp
2009-10-24 1:07 ` Lucas De Marchi
2009-10-24 1:18 ` Marti Raudsepp
2009-10-24 8:30 ` Ingo Molnar
2009-10-24 13:26 ` Lucas De Marchi
2009-10-24 15:13 ` Marti Raudsepp
2009-10-24 15:19 ` Marti Raudsepp
2009-10-24 15:41 ` Ingo Molnar
2009-10-24 16:10 ` Marti Raudsepp
2009-10-23 21:56 ` Lucas De Marchi
2009-10-23 21:59 ` Marti Raudsepp
2009-10-23 22:16 ` Lucas De Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091023210231.GC8356@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=arjan@linux.intel.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marti@juffo.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox