From mboxrd@z Thu Jan 1 00:00:00 1970 From: Quentin Monnet Subject: Re: How to detect libbfd when building tools/bpf? Date: Wed, 25 Apr 2018 13:01:22 +0100 Message-ID: <5cd0d971-fa32-3db3-638c-86db16b35b2a@netronome.com> References: <3d29dfa6-0aa6-5a9d-6997-88b76c4938bf@iogearbox.net> <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: ast , kstewart , gregkh , tglx , pombredanne , netdev , acme@redhat.com, jakub.kicinski@netronome.com To: shhuiw , Daniel Borkmann Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:55824 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbeDYMB2 (ORCPT ); Wed, 25 Apr 2018 08:01:28 -0400 Received: by mail-wm0-f66.google.com with SMTP id a8so6702432wmg.5 for ; Wed, 25 Apr 2018 05:01:28 -0700 (PDT) In-Reply-To: <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 2018-04-24 10:27 UTC+0800 ~ shhuiw > > > 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 >>> >>> 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-.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