Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Allow build with unvendored libbpf #17992

Open
nethershaw opened this issue Jun 22, 2024 · 2 comments
Open

[Feat]: Allow build with unvendored libbpf #17992

nethershaw opened this issue Jun 22, 2024 · 2 comments
Labels
feature request New features needs triage Issues which need to be manually labelled

Comments

@nethershaw
Copy link

nethershaw commented Jun 22, 2024

Problem

Bundling libraries is generally recognized as harmful.

As a Gentoo user, I have struggled with properly supporting Netdata on my system for almost as long as Netdata has existed. The upstream installer script and netdata-updater introduce too many conflicts with the way things are supposed to be managed on a source distribution, so I have always preferred using ebuilds for installation.

That entails having to research and compensate for changes in Netdata's build system, disabling features I cannot or do not have the time to properly support in an ebuild, simply holding back my installation at a deprecated version containing known issues because the ebuild needs work, or -- most importantly -- (re)discovering how to dereference one of the libraries Netdata bundles (because this keeps changing in frustrating ways). Our distribution philosophy does not allow packages to bundle libraries for which a proper package already exists, and we must avoid multiple copies of a library on the system; one obvious example of this is libbpf.

The area currently in the most transitional state seems to be the eBPF plugin. A proper source build against system libraries required independently checking out all three of the netdata, kernel-collector, and ebpf-co-re repositories while depending on the system to provide a dev-libs/libbpf[static] dependency. Patches were applied to prevent the build system compiling libbpf itself and use system includes. It made the ebuild significantly more bespoke and less maintainable, but it worked until Netdata 1.45.5.

If I want to use the eBPF plugin (in Gentoo, this would be decided by the USE environment variable containing the string bpf when the ebuild looks for it), I must now attempt to understand the changes made to CMakeLists.txt since then, and understand the topological changes pertaining to how libbpf is bundled, and contrive a maintainable patch set that will conveniently unbundle it and replace it with my system's library, and then I get to find out whether Netdata itself will tolerate the difference. Every update to Netdata entails the risk that this kind of work might have to be done because of the bundled libraries.

Such a state of affairs prevents me from meaningfully contributing to the maintenance of the distribution package in a timely fashion; sometimes I can do this faster or better than the official maintainer, but this time I cannot.

Description

CMakeLists.txt already contains build flags such as ENABLE_BUNDLED_JSONC, ENABLE_BUNDLED_YAML, and ENABLE_BUNDLED_PROTOBUF. A similar boolean flag that falls back on the system library when falsy, e.g. ENABLE_BUNDLED_LIBBPF, is all that would be needed to obviate heaps of work and difficult-to-maintain patchsets that slow down or prevent releases on Gentoo.

Netdata should not rely on any changes to its bundled copy of libbpf that have not been upstreamed. If upstream would not accept them, then they don't belong in that library.

Importance

must have

Value proposition

  1. Complete feature support and timely release tracking in official Gentoo distribution packages for Netdata, whereas users of the Gentoo distribution currently have no perfect solution.

Proposed implementation

Consider a modular build flag as described above.

@nethershaw nethershaw added feature request New features needs triage Issues which need to be manually labelled labels Jun 22, 2024
@Ferroin
Copy link
Member

Ferroin commented Jun 24, 2024

@thiagoftsm Do we have actual code patches on top of upstream libbpf, or is an unmodified upstream build fine barring versioning constraints? AFAICT from the git logs we aren’t using any custom patches, and the only commits not in the upstream tree are all either merge commits (or functional merge commits) or are CI related, but I’m not sure if I missed anything somehow. And if the answer is that we work with an unmodified upstream build, can we please officially commit to continue working with an unmodified upstream build? This uncertainty is a majority of the reason that I’ve not already done what’s being requested here for libbpf.


Regarding the eBPF code itself (from the kernel-collector and ebpf-co-re repos), I’m fairly certain that needing to either manually handle building that stuff locally (and possibly forgo support if they break things) or just use the officially published code we provide are going to continue to be the only options we officially support there for the foreseeable future, but I can definitely add a CMake option to skip trying to install the eBPF code so that a manually built copy can be used.

@thiagoftsm
Copy link
Contributor

Hello @Ferroin ,

As we chat hours ago in our Slack channel. We are applying a patch to run on Debian 10. This is the unique difference between our source code and official libbpf source code.

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New features needs triage Issues which need to be manually labelled
Projects
None yet
Development

No branches or pull requests

3 participants