libbpf: stop using feature-detection Makefiles
Subsystems (4)
Andrii Nakryiko
maintainerPATCH 1/1 libbpf: stop using feature-detection Makefiles
Libbpf's Makefile relies on Linux tools infrastructure's feature detection framework, but libbpf's needs are very modest: it detects the presence of libelf and libz, both of which are mandatory. So it doesn't benefit much from the framework, but pays significant costs in terms of maintainability and debugging experience, when something goes wrong. The other feature detector, testing for the presernce of minimal BPF API in system headers is long obsolete as well, providing no value.
So stop using feature detection and just assume the presence of libelf and libz during build time. Worst case, user will get a clear and actionable linker error, e.g.:
/usr/bin/ld: cannot find -lelf
On the other hand, we completely bypass recurring issues various users reported over time with false negatives of feature detection (libelf or libz not being detected, while they are actually present in the system).
--- tools/lib/bpf/.gitignore | 1 - tools/lib/bpf/Makefile | 47 ++++------------------------------------ 2 files changed, 4 insertions(+), 44 deletions(-)
tools/lib/bpf/.gitignore +0 -1
@@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only libbpf_version.h libbpf.pc -FEATURE-DUMP.libbpf libbpf.so.* TAGS tags
tools/lib/bpf/Makefile +4 -43
80 lines not on this page · raw message
Signature · 1 line
2.24.1
Quoted 18 lines · Andrii Nakryiko
Libbpf's
Makefilerelies on Linux tools infrastructure's feature detection framework, but libbpf's needs are very modest: it detects the presence of libelf and libz, both of which are mandatory. So it doesn't benefit much from the framework, but pays significant costs in terms of maintainability and debugging experience, when something goes wrong. The other feature detector, testing for the presernce of minimal BPF API in system headers is long obsolete as well, providing no value.So stop using feature detection and just assume the presence of libelf and libz during build time. Worst case, user will get a clear and actionable linker error, e.g.:
/usr/bin/ld: cannot find -lelfOn the other hand, we completely bypass recurring issues various users reported over time with false negatives of feature detection (libelf or libz not being detected, while they are actually present in the system).
Quoted 7 lines
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Randy Dunlap <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>--- tools/lib/bpf/.gitignore | 1 - tools/lib/bpf/Makefile | 47 ++++------------------------------------ 2 files changed, 4 insertions(+), 44 deletions(-)
I've also hit these annoying cases at least once or twice.
Quoted 18 lines · Andrii Nakryiko
Libbpf's
Makefilerelies on Linux tools infrastructure's feature detection framework, but libbpf's needs are very modest: it detects the presence of libelf and libz, both of which are mandatory. So it doesn't benefit much from the framework, but pays significant costs in terms of maintainability and debugging experience, when something goes wrong. The other feature detector, testing for the presernce of minimal BPF API in system headers is long obsolete as well, providing no value.So stop using feature detection and just assume the presence of libelf and libz during build time. Worst case, user will get a clear and actionable linker error, e.g.:
/usr/bin/ld: cannot find -lelfOn the other hand, we completely bypass recurring issues various users reported over time with false negatives of feature detection (libelf or libz not being detected, while they are actually present in the system).
Quoted 7 lines
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Randy Dunlap <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>--- tools/lib/bpf/.gitignore | 1 - tools/lib/bpf/Makefile | 47 ++++------------------------------------ 2 files changed, 4 insertions(+), 44 deletions(-)
Hi Andrii,
This does indeed fix the build problems that I was seeing, so I can add:
but in the long term I think that features/libs/etc. that are used should be checked for instead of being used blindly... IMO.
Thanks.
Signature · 1 line
~Randy
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Quoted 9 lines · On Wed, 3 Feb 2021 12:34:45 -0800 you wrote:
Libbpf's
Makefilerelies on Linux tools infrastructure's feature detection framework, but libbpf's needs are very modest: it detects the presence of libelf and libz, both of which are mandatory. So it doesn't benefit much from the framework, but pays significant costs in terms of maintainability and debugging experience, when something goes wrong. The other feature detector, testing for the presernce of minimal BPF API in system headers is long obsolete as well, providing no value.[...]
Here is the summary with links:
- [bpf-next] libbpf: stop using feature-detection Makefiles
https://git.kernel.org/bpf/bpf-next/c/5f10c1aac8b2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html