* How to detect libbfd when building tools/bpf?
@ 2018-04-22 7:51 Wang Sheng-Hui
2018-04-23 10:05 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Wang Sheng-Hui @ 2018-04-22 7:51 UTC (permalink / raw)
To: ast, daniel, kstewart, gregkh, tglx, pombredanne; +Cc: netdev
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);
return 0;
}
root@lazyfintech:~# gcc t.c -lbfd
root@lazyfintech:~# ./a.out
demangled symbol: {ClassName::FieldName}
I thought libbfd can be reached from above.
But when I built tools/bpf, libbfd cannot be detected:
-------------------------------------------------------------------------
/linux# make O=../buildkernel/ tools/bpf
make[1]: Entering directory '/root/buildkernel'
DESCEND bpf
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ on ]
DESCEND bpftool
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ on ]
make[1]: Leaving directory '/root/buildkernel'
I wonder how should I do to get libbfd auto detected when building bpf tool?
Regards,
shenghui
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: How to detect libbfd when building tools/bpf? 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> 0 siblings, 1 reply; 3+ messages in thread From: Daniel Borkmann @ 2018-04-23 10:05 UTC (permalink / raw) To: Wang Sheng-Hui, ast, kstewart, gregkh, tglx, pombredanne Cc: netdev, acme, jakub.kicinski, quentin.monnet 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); > > 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? > root@lazyfintech:~# ./a.out > demangled symbol: {ClassName::FieldName} > > > I thought libbfd can be reached from above. > But when I built tools/bpf, libbfd cannot be detected: > ------------------------------------------------------------------------- > /linux# make O=../buildkernel/ tools/bpf > make[1]: Entering directory '/root/buildkernel' > DESCEND bpf > > Auto-detecting system features: > ... libbfd: [ OFF ] > ... disassembler-four-args: [ on ] > > DESCEND bpftool > > Auto-detecting system features: > ... libbfd: [ OFF ] > ... disassembler-four-args: [ on ] > > make[1]: Leaving directory '/root/buildkernel' > > > I wonder how should I do to get libbfd auto detected when building bpf tool? > > Regards, > shenghui ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com>]
* Re: How to detect libbfd when building tools/bpf? [not found] ` <5ade9631.046f370a.24af5.a921SMTPIN_ADDED_BROKEN@mx.google.com> @ 2018-04-25 12:01 ` Quentin Monnet 0 siblings, 0 replies; 3+ messages in thread From: Quentin Monnet @ 2018-04-25 12:01 UTC (permalink / raw) To: shhuiw, Daniel Borkmann Cc: ast, kstewart, gregkh, tglx, pombredanne, netdev, acme, jakub.kicinski 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-25 12:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).