linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: acme@redhat.com, peterz@infradead.org, mingo@elte.hu, jolsa@redhat.com
Subject: [PATCH v3] tools/perf/inject: fix dwarf support detection
Date: Mon, 18 Dec 2017 10:13:00 -0800	[thread overview]
Message-ID: <1513620780-30770-1-git-send-email-eranian@google.com> (raw)

I ran into problems trying to use the JIT support and display
source-level information. Basically, there was no dwarf debug
info generated in the jitted-XX.so files, yet I had libdw-dev
installed.

Turns out that the feature test build for test-dwarf.bin was broken
for me. It would die for the wrong reason:

/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libdw.so: undefined reference to `elf_compress@ELFUTILS_1.7'

In other words, the libdw has a dependency on libelf which the Makefile
was not accounting for. Thus perf was not compiled with HAVE_DWARF_SUPPORT
and the code in genelf.c was not compiled in.

This patch fixes the issue by adding -lelf to the build rule for test-dwarf.c.

I wasted quite some time trying to debug this, so I have added a warning
in builtin-inject.c so that the user is warned that in case dwarf support
is disabled, no source line information will be generated in the output
.so files from the jitted code.

In v2, we removed the extraneaous echo in the make target.
In v3, we removed the superfluous -lelf from the static build DWARFLIBS.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 tools/build/feature/Makefile | 9 +++++++--
 tools/perf/builtin-inject.c  | 3 +++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index cff38f342283..6fd6f3174c61 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -104,9 +104,14 @@ __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(
 $(OUTPUT)test-setns.bin:
 	$(BUILD)
 
-DWARFLIBS := -ldw
+#
+# there may be a dependency between libdw and libelf such as
+# /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libdw.so: undefined reference to `elf_compress@ELFUTILS_1.7'
+# so force linking with libelf
+#
+DWARFLIBS := -ldw -lelf
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+DWARFLIBS += -lebl -lz -llzma -lbz2
 endif
 
 $(OUTPUT)test-dwarf.bin:
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 16a28547ca86..524255ed9a39 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -856,6 +856,9 @@ int cmd_inject(int argc, const char **argv)
 	}
 #ifdef HAVE_JITDUMP
 	if (inject.jit_mode) {
+#ifndef HAVE_DWARF_SUPPORT
+		pr_warning("perf tool compiled without dwarf, no source line information will be generated\n");
+#endif
 		inject.tool.mmap2	   = perf_event__jit_repipe_mmap2;
 		inject.tool.mmap	   = perf_event__jit_repipe_mmap;
 		inject.tool.ordered_events = true;
-- 
2.7.4

                 reply	other threads:[~2017-12-18 18:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1513620780-30770-1-git-send-email-eranian@google.com \
    --to=eranian@google.com \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).