All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin.monnet@netronome.com>
To: shhuiw <shhuiw@foxmail.com>, Daniel Borkmann <daniel@iogearbox.net>
Cc: ast <ast@kernel.org>, kstewart <kstewart@linuxfoundation.org>,
	gregkh <gregkh@linuxfoundation.org>, tglx <tglx@linutronix.de>,
	pombredanne <pombredanne@nexb.com>,
	netdev <netdev@vger.kernel.org>,
	acme@redhat.com, jakub.kicinski@netronome.com
Subject: Re: How to detect libbfd when building tools/bpf?
Date: Wed, 25 Apr 2018 13:01:22 +0100	[thread overview]
Message-ID: <5cd0d971-fa32-3db3-638c-86db16b35b2a@netronome.com> (raw)
In-Reply-To: <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com>

2018-04-24 10:27 UTC+0800 ~ shhuiw <shhuiw@foxmail.com>
> 
> 
> On 04/23/18 18:05, Daniel Borkmann wrote:
>> On 04/22/2018 09:51 AM, Wang Sheng-Hui wrote:
>>> Sorry to trouble you !
>>>
>>> I run debian and installed binutils-dev beforehand.
>>> Then I copied tools/build/feature/test-libbfd.c to t.c and run:
>>> ------------------------------------------------------------------------
>>> root@lazyfintech:~# cat t.c
>>> #include <bfd.h>
>>>
>>> extern int printf(const char *format, ...);
>>>
>>> int main(void)
>>> {
>>>     char symbol[4096] = "FieldName__9ClassNameFd";
>>>     char *tmp;
>>>
>>>     tmp = bfd_demangle(0, symbol, 0);
>>>
>>>     printf("demangled symbol: {%s}\n", tmp);
- On some distributions (e.g. OpenSUSE), there is no default alias
>>>
>>>     return 0;
>>> }
>>> root@lazyfintech:~# gcc t.c -lbfd
>> Can you run with 'gcc t.c -lbfd -lz -liberty -ldl' since this is
>> what the Makefile for the feature test is doing:
>>
>>    $(OUTPUT)test-libbfd.bin:
>>          $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
>>
>> Seems most likely that you're missing some of the remaining libs
>> to have the feature test properly detect it?
> I missed the lib iberty. After the lib installed, the auto-detect can work.
> 
> Thanks, Daniel!

For the record, we (at least Jakub and I) know about this issue with
libbfd detection for bpf tools. In theory the Makefile *should* refuse
to build if libbfd is not detected (since libbfd is required), but
checking the result from the detection was apparently omitted when
detection itself was added to the Makefile. This would be trivial to
patch in the Makefile, but I would like to have the detection itself
fixed before that:

- On some distributions (e.g. OpenSUSE), there is no default alias
libbfd.so to libbfd-<version>.so, which causes the static library
libbfd.a to be picked. But the latter does not include libiberty, which
must be available on the system, and called on the command line
("-liberty") for the feature to be detected (or for bpftool to be compiled).

- Some other distributions (e.g. Debian and derivatives) have this
alias, and for them it is not required to link against any version of
libiberty (it seems to be already included in libbfd.so). On such
systems, installing libiberty is not a requirement to compile the tools.

So fixing the Makefile to make libbfd detection mandatory would force
all users to install libiberty to compile bpftool, when it is actually
not required for many of them. I have proposed, internally, a couple of
patches to fix libbfd detection, but I haven't found something clean
enough so far to propose it on this list. But I intend to come back to
it and to fix it eventually, so that libbfd detection would no longer
appear as "OFF" when all needed components are present on the system.

Cheers,
Quentin

      parent reply	other threads:[~2018-04-25 12:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-22  7:51 How to detect libbfd when building tools/bpf? Wang Sheng-Hui
2018-04-23 10:05 ` Daniel Borkmann
     [not found]   ` <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com>
2018-04-25 12:01     ` Quentin Monnet [this message]

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=5cd0d971-fa32-3db3-638c-86db16b35b2a@netronome.com \
    --to=quentin.monnet@netronome.com \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=netdev@vger.kernel.org \
    --cc=pombredanne@nexb.com \
    --cc=shhuiw@foxmail.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.