[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5cd0d971-fa32-3db3-638c-86db16b35b2a@netronome.com>
Date: Wed, 25 Apr 2018 13:01:22 +0100
From: Quentin Monnet <quentin.monnet@...ronome.com>
To: shhuiw <shhuiw@...mail.com>, Daniel Borkmann <daniel@...earbox.net>
Cc: ast <ast@...nel.org>, kstewart <kstewart@...uxfoundation.org>,
gregkh <gregkh@...uxfoundation.org>, tglx <tglx@...utronix.de>,
pombredanne <pombredanne@...b.com>,
netdev <netdev@...r.kernel.org>, acme@...hat.com,
jakub.kicinski@...ronome.com
Subject: Re: How to detect libbfd when building tools/bpf?
2018-04-24 10:27 UTC+0800 ~ shhuiw <shhuiw@...mail.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@...yfintech:~# 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@...yfintech:~# 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
Powered by blists - more mailing lists