public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH 1/3] perf tools: Separate lbfd check out of NO_DEMANGLE condition
Date: Wed, 02 Oct 2013 10:18:32 +0900	[thread overview]
Message-ID: <87d2noo4gn.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1380437526.1727.10.camel@leonhard> (Namhyung Kim's message of "Sun, 29 Sep 2013 15:52:06 +0900")

Hi Jiri,

On Sun, 29 Sep 2013 15:52:06 +0900, Namhyung Kim wrote:
> Hi Jiri,
>
> 2013-09-27 (금), 16:32 +0200, Jiri Olsa:
>> We fail build with NO_DEMANGLE with missing -lbfd externals error.
>> The reason is that we now use bfd code in srcline object:
>>   perf tools: Implement addr2line directly using libbfd
>> 
>> So we need to check/add -lbfd always now.
>> 
>> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
>> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
>> Cc: Ingo Molnar <mingo@elte.hu>
>> Cc: Namhyung Kim <namhyung@kernel.org>
>> Cc: Paul Mackerras <paulus@samba.org>
>> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
>> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>> Cc: David Ahern <dsahern@gmail.com>
>> ---
>>  tools/perf/config/Makefile | 17 ++++++++---------
>>  1 file changed, 8 insertions(+), 9 deletions(-)
>> 
>> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
>> index 8b49a00..40a41c6 100644
>> --- a/tools/perf/config/Makefile
>> +++ b/tools/perf/config/Makefile
>> @@ -360,6 +360,13 @@ else
>>    endif
>>  endif
>>  
>> +FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
>> +has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
>> +ifeq ($(has_bfd),y)
>> +  EXTLIBS += -lbfd
>> +  CFLAGS += -DLIBBFD_SUPPORT
>> +endif
>> +
>>  ifdef NO_DEMANGLE
>>    CFLAGS += -DNO_DEMANGLE
>>  else
>> @@ -367,11 +374,7 @@ else
>>      EXTLIBS += -liberty
>>      CFLAGS += -DHAVE_CPLUS_DEMANGLE
>>    else
>> -    FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
>> -    has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
>> -    ifeq ($(has_bfd),y)
>> -      EXTLIBS += -lbfd
>> -    else
>> +    ifneq ($(has_bfd),y)
>>        FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
>>        has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
>>        ifeq ($(has_bfd_iberty),y)
>> @@ -397,10 +400,6 @@ else
>>    endif
>>  endif
>>  
>> -ifndef ($(filter -lbfd,$(EXTLIBS)),)
>> -  CFLAGS += -DLIBBFD_SUPPORT
>> -endif
>> -
>>  ifndef NO_STRLCPY
>>    ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y)
>>      CFLAGS += -DHAVE_STRLCPY
>
> Is it enough to check on -lbfd only?  I guess libbfd can have additional
> dependencies to libiberty and libz.  If so, this patch can fail to set
> -DLIBBFD_SUPPORT, right?

I tested this on my system.  At first I guessed (without testing) it
cannot build SOURCE_BFD with -lbfd only due to additional -liberty and
-lz dependency, but it's not.  Actually the libfd.so is a plain text
file which contains linker script like this:

  $ file /lib64/libbfd.so
  /lib64/libbfd.so: ASCII text

  $ cat /lib64/libbfd.so
  /* GNU ld script */
  
  /* Ensure this .so library will not be used by a link for a different format
     on a multi-architecture system.  */
  OUTPUT_FORMAT(elf64-x86-64)
  
  /* The libz dependency is unexpected by legacy build scripts.  */
  INPUT ( /usr/lib64/libbfd.a -liberty -lz )


So it should handle external dependencies.  But it doesn't.

  $ cat bfd.c
  #include <bfd.h>
  
  int main(void)
  {
  	bfd_demangle(0, 0, 0);
  	return 0;
  }

  namhyung@sejong:tmp$ gcc bfd.c -lbfd
  /usr/lib64/libbfd.a(plugin.o): In function `try_load_plugin':
  (.text+0x1ab): undefined reference to `dlopen'
  /usr/lib64/libbfd.a(plugin.o): In function `try_load_plugin':
  (.text+0x1ca): undefined reference to `dlsym'
  /usr/lib64/libbfd.a(plugin.o): In function `try_load_plugin':
  (.text+0x263): undefined reference to `dlerror'
  collect2: error: ld returned 1 exit status


It seems that it needs libdl for loading plugins.  Adding -ldl makes
above build successfully.  So we need to add -ldl for EXTLIBS IMHO.
Without it, make NO_GTK2=1 NO_LIBPERL=1 NO_LIBPYTHON=1 will fail to
check libbfd correctly (FYI, libperl and libpython add -ldl to the
dependency list).

Thanks,
Namhyung

  parent reply	other threads:[~2013-10-02  1:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26 18:55 [PATCH] perf tools: Add missing -ldl for gtk build Jiri Olsa
2013-09-27  2:27 ` Namhyung Kim
2013-09-27 14:32 ` [PATCH 1/3] perf tools: Separate lbfd check out of NO_DEMANGLE condition Jiri Olsa
2013-09-27 14:32   ` [PATCH 2/3] perf tools: Adding missing ifdef for cmd_trace call Jiri Olsa
2013-09-27 14:32   ` [BUG/RFC 3/3] perf tools: Add missing GTK2_SUPPORT ifdefs Jiri Olsa
2013-09-27 18:54     ` Arnaldo Carvalho de Melo
2013-09-29  6:54       ` Namhyung Kim
2013-09-29  6:52   ` [PATCH 1/3] perf tools: Separate lbfd check out of NO_DEMANGLE condition Namhyung Kim
2013-09-30  3:13     ` Jiri Olsa
2013-10-02  1:18     ` Namhyung Kim [this message]
2013-10-02  8:17       ` Jiri Olsa
2013-10-02  8:38         ` Namhyung Kim
2013-10-02 10:08           ` Ingo Molnar
2013-10-15  5:28 ` [tip:perf/core] perf tools: Add missing -ldl for gtk build tip-bot for Jiri Olsa

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=87d2noo4gn.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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