Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757847AbdLRITE (ORCPT ); Mon, 18 Dec 2017 03:19:04 -0500 Received: from mail-io0-f175.google.com ([209.85.223.175]:43616 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751376AbdLRITD (ORCPT ); Mon, 18 Dec 2017 03:19:03 -0500 X-Google-Smtp-Source: ACJfBotfhkW9aA+GuUI8ySzum2voP798huM2e6BF1fg8LwWlP8dsvr5o8gDnvMBE9Z3ea9I6QXjIxy0mfZ1LOH9ofkI= MIME-Version: 1.0 In-Reply-To: <20171218030510.GA25654@krava.home> References: <1512752538-10230-1-git-send-email-eranian@google.com> <20171218030510.GA25654@krava.home> From: Stephane Eranian Date: Mon, 18 Dec 2017 00:19:01 -0800 Message-ID: Subject: Re: [PATCH v2] tools/perf/inject: fix dwarf support detection To: Jiri Olsa Cc: LKML , Arnaldo Carvalho de Melo , Peter Zijlstra , mingo@elte.hu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3028 Lines: 75 On Sun, Dec 17, 2017 at 7:05 PM, Jiri Olsa wrote: > On Fri, Dec 08, 2017 at 09:02:18AM -0800, Stephane Eranian wrote: >> 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. >> >> Signed-off-by: Stephane Eranian >> --- >> tools/build/feature/Makefile | 7 ++++++- >> tools/perf/builtin-inject.c | 3 +++ >> 2 files changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile >> index cff38f342283..be5679707aa0 100644 >> --- a/tools/build/feature/Makefile >> +++ b/tools/build/feature/Makefile >> @@ -104,7 +104,12 @@ __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 > > you can remove '-lelf' from above line then (again) > Ok, I get it now. I thought you were talking about the line I added! Let me resubmit. Thanks. > jirka > >> endif >> 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 >>