-
Notifications
You must be signed in to change notification settings - Fork 49
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
Make novendor feature the default #64
Conversation
I was hoping the .github/workflow/ci.yml would cause a CI run. I do not know how to run these myself. |
See: libbpf/libbpf-sys#64 The "static" feature will now get libbpf-sys to do all the static compilation of the libraries required by libbpf rather than the application developer statically compiling these libraries themselves, or relying on the distribution to provide static versions. The default feature will no longer link libbpf statically. All libbpf libraries, including libbpf, will now be dynamically linked to distribution provided shared libraries CHANGELOG NOTE libbpf#1: feature "static" allows libelf and zlib to be statically linked. Completely static binaries can now be compiled via the command `RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu`. CHANGELOG NOTE libbpf#2: "static" feature will not work with musl. Signed-off-by: Michael Mullin <[email protected]>
I'd think we should enable support for running pull requests, not just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with this change, though I am somewhat worried about the backwards compat story (but will leave the call to Alex). But the provided interface should be sufficient for libbpf-rs
's intents and purposes (I hope).
That being said, I still firmly believe that conceptually (read: outside of my libbpf-rs
tinted view) this crate should not make any policy decisions such as vendoring one library implies vendoring another or vendoring one library implies static linking. As such,
[features]
default = ['vendored-libbpf'] # current behavior, we can keep it or change it; just a proposal
vendored = ['vendored-libbpf', 'vendored-elf', 'vendored-zlib']
vendored-libbpf = []
vendored-elf = []
vendored-zlib = []
static = ['static-libbpf', 'static-elf', 'static-zlib']
static-libbpf = []
static-elf = []
static-zlib = []
is the right approach, in my opinion (earlier discussion). This is in line with libbpf-sys
not building any opinionated abstractions on top of what the C library provides.
(I won't push for that as I don't use libbpf-sys
in anything but libbpf-rs
, and as I explained above, for libbpf-rs
the proposed interface should suffice)
I do like & agree with this, but I'm not going to have time to do the work myself and I don't feel strongly enough to insist that it be done like this. Though (again, if I'm understanding this PR correctly) it seems like we could merge this PR and come back later to add the more granular control without breaking backward compatibility. Do you agree @mmullin-halcyon? |
I'm wondering if there is a theoretical problem with mixing and matching vendored libraries with non-vendored libraries. EG. without any of these changes, could a binary compiled with libbpf.a but with libelf.so and libz.so have issues if libelf.so has a breaking update shipped by a distribution provider? Or if we mix&match vendorized deps, could we have a binary compiled with libbpf.a+libelf.a but libz.so have issues if libz.so has a breaking update? Is this risk higher or lower than a binary which is completely non-vendored having troubles if libbpf.so ever updates? |
Oh yeah, I bet there are all sorts of ways a user might get in trouble by trying to mix these. But my general philosophy here is: have sane defaults, and allow users an escape hatch if they need it. I don't want to presume I know all the reasons someone might want to statically compile libelf and libbpf but not libz, or whatever. |
Thanks for sharing your opinion, @alexforster. Yes, I agree we could add the more elaborate features later. So as per my understanding the only change for this PR to be ready is to re-introduce the |
056e2f6
to
0c56831
Compare
See: libbpf/libbpf-sys#64 The "static" feature will now get libbpf-sys to do all the static compilation of the libraries required by libbpf rather than the application developer statically compiling these libraries themselves, or relying on the distribution to provide static versions. The default feature will no longer link libbpf statically. All libbpf libraries, including libbpf, will now be dynamically linked to distribution provided shared libraries CHANGELOG NOTE libbpf#1: feature "static" allows libelf and zlib to be statically linked. Completely static binaries can now be compiled via the command `RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu`. CHANGELOG NOTE libbpf#2: "static" feature will not work with musl. Signed-off-by: Michael Mullin <[email protected]>
0c56831
to
1410562
Compare
Make novendor feature the default Merge vendored feature into static There is now only two settings - default (formerly novendor, all libs are dynamic) - static (formerly vendored, all libs are static) Side Effect: Clients of libbpf-sys will now compile zlib and elfutils as part of the libbpf-sys project. This has the benefit of ensuring that the libraries are well suited for the rust bindings, but takes extra time during compilation Signed-off-by: Michael Mullin <[email protected]>
1410562
to
6029e64
Compare
@alexforster Any comments? |
@alexforster can this pull request be moved forward? |
It seems like all the people involved are fine with this, including @alexforster. So I'm going ahead and merging this, as it's been pending for a while. Until we cut a release on crates.io this is easily revertable, if necessary. @alexforster please yell if you disagree. |
Sorry, thanks for stepping in. I'm still somewhat concerned that we're going to break people by changing the default. I'm hesitant to veto because of that though, because the vast majority of users of this crate only pull it in transitively. Is there any way we can proactively get the ecosystem ready before publishing a release? |
@alexforster The only thing I can suggest is that this change requires a Major semantic version update. Major semantic versioning should protect all consumers who are using ... I think... I've been doing rust for 5 years now and I still get confused on the semantic versioning stuff. The issue is that some consumers may have an expectation of "backported bug/security fixes" to a 1.x branch for 3 to 6 months or so. I think most developers using bpf understand that it is a fast moving technology and they would understand a statement of "version 1.x is deprecated, please upgrade to 2.x for further bug fixes" |
Yeah, I know we could also semver bump, but I reeeally like that we currently match major and minor semver with libbpf itself, and only deviate in patch. (A completely OCD thing, I know :) |
@alexforster I do agree that matching major versions between libbpf-sys and libbpf are good for minimizing confusion. As for breakage. It seems like libbpf-rs is the biggest consumer of libbpf-sys, and @danielocfb is saying that he'll be able to accommodate this change just fine. There are a bunch of other dependencies on crates.io (https://crates.io/crates/libbpf-sys/reverse_dependencies), and comparing to libbpf-rs, they are much smaller in terms of downloads. So I think majority of libbpf-sys uses are going through libbpf-rs, and should have much smaller volume. So maybe this change won't cause much churn? Separately, to minimize the need for customer to do any changes, maybe we should just leave If neither of the above works, what should we do to unblock libbpf-sys release? |
So thinking about this a bit more...it's fine that --- Cargo.toml
+++ Cargo.toml
@@ -9,3 +9,6 @@ members = [
"examples/tproxy",
]
resolver = "2"
+
+[patch.crates-io]
+libbpf-sys = { git = "https://github.com/libbpf/libbpf-sys.git", rev = "c043865bc069c886b5ac1f87a62d2c2a48f3ce70" }
I'd say...let's just cut a new major version. It's really not worth it dealing with this fallout. That's exactly what semantic versioning is about and supposed to help with. |
Though actually that could also be problematic. Similar to what happened as part of the |
I mean, with the caveat that I forget why we even needed to change the default vendoring strategy... can we just not? I love the new more granular features, but I'm not quite sure why those mean we need to break semver. I personally have codebases that will be broken by this change, and I also personally directly depend on both libbpf-sys and libbpf-rs (I needed to break out of the abstraction for some reason). Maintainer-me feels uncomfortable releasing a change that will break user-me. |
I suppose @mmullin-halcyon 's reasoning is explained a bit over in It seems as if we can preserve existing behavior and, based on what we encountered so far and @alexforster 's stance, I am fine with it. That being said -- and I know it's shifting the goal post a bit -- but I discussed this more with @anakryiko and not to put words in his mouth but I think we are both confused by what is changing and to what. Not that we don't understand after reading commit messages, code and comments, just that it's non obvious and needs to be looked up all the time. So in our discussion we basically converged back on my earlier proposal, which makes it very explicit what is going on: [features]
default = ['vendored-libbpf'] # current behavior, we can keep it or change it; just a proposal
vendored = ['vendored-libbpf', 'vendored-elf', 'vendored-zlib']
vendored-libbpf = []
vendored-elf = []
vendored-zlib = []
static = ['static-libbpf', 'static-elf', 'static-zlib']
static-libbpf = []
static-elf = []
static-zlib = [] So here is my proposal: while we are reworking these features let's do it as above. @alexforster seemed fine with it and @anakryiko expressed his support as well. I'd be happy to implement it. |
I'm on board with that. |
Goals: Unfortunately for my goal, Fedora no longer distributes libelf as a static library; thus it must be compiled sometime during the development process. This can be done either as a setup process where the developer manually downloads libelf, and compiles it by hand, or it could be done by libbpf-sys and allow developers to not worry about the libelf compilation process (which isn't fun). Though it imposes a maintenance cost upon the libbpf-sys project, I expect that many other users of the libbpf-rs/libbpf-sys environment desire to have a static final application without the difficulties of manually installing static libelf. The competing project Aya explains that creating a fully stand alone binary is one of their important features (https://github.com/aya-rs/aya). The addition of zlib into libbpf-sys is somewhat gold plating. I believe that the major distributions still supply a static version of this library in their package manager, but there is the risk that distributions might not continue to do so, similar to how Fedora stopped shipping static libelf. My secondary goal is to enable speedy compiles for non-release builds and speedy Thoughts: I think that separating out libelf from zlib is more effort than it's worth, and I don't really understand the reason why libbpf should ever use a vendored .so, but I admit that this might simply be my lack of imagination. |
Can you use this to choose flags based on debug/release? |
This change overhauls the vendoring & static linking features that the library exposes. Please refer to the larger discussion [0] for additional context, but in short we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. That is to say, conceptually we fully decouple [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes, in an attempt to make everything more to the point. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. We could alternatively move to a model where we err out on combinations that make little sense/are risky/whatever. Doing so could be beneficial if we ever were to loosen some of those dependencies down the line to minimize chance of breakage. I am unsure how likely that really is or whether it would be cause for concern, and I generally like the declarative nature of "this feature depends on this other" in Cargo.toml, but we could change that if we feel strongly. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Closes: libbpf#70 Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. We could alternatively move to a model where we err out on combinations that make little sense/are risky/whatever. Doing so could be beneficial if we ever were to loosen some of those dependencies down the line to minimize chance of breakage. I am unsure how likely that really is or whether it would be cause for concern, and I generally like the declarative nature of "this feature depends on this other" in Cargo.toml, but we could change that if we feel strongly. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Closes: libbpf#70 Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. We could alternatively move to a model where we err out on combinations that make little sense/are risky/whatever. Doing so could be beneficial if we ever were to loosen some of those dependencies down the line to minimize chance of breakage. I am unsure how likely that really is or whether it would be cause for concern, and I generally like the declarative nature of "this feature depends on this other" in Cargo.toml, but we could change that if we feel strongly. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] libbpf#64 (comment) Closes: libbpf#70 Signed-off-by: Daniel Müller <[email protected]>
This change overhauls the vendoring & static linking features that the library exposes. Please refer to the larger discussion [0] for additional context, but in short: we introduce separate features for vendoring/linking each of the three system library dependencies: libbpf, libelf, zlib. "static" and "vendored" meta-features are still available, which apply to all three libraries in unison. The remaining dependencies are expressed declaratively via dependent features. E.g., because zlib is only a dependency of libbpf (and not a direct one), linking it statically implies linking libbpf statically. In the future, this design would make it possible to enable additional configurations. For example, currently vendoring any library implies linking it statically, because we only build the static version. This is more of a simplification than a strict requirement and if needed, we could support dynamic linking when using a vendored copy. We could alternatively move to a model where we err out on combinations that make little sense/are risky/whatever. Doing so could be beneficial if we ever were to loosen some of those dependencies down the line to minimize chance of breakage. I am unsure how likely that really is or whether it would be cause for concern, and I generally like the declarative nature of "this feature depends on this other" in Cargo.toml, but we could change that if we feel strongly. The default features mirror the previous default and no behavior change should occur. The existing novendor feature is kept but deprecated and should be removed in the future (a warning will be printed as part of the build). It was certainly one of the main causes of confusion where novendor and vendored could co-exist and it was hard to understand what would or wouldn't happen. In the new world, users are advised to simply build with all features disabled. I tested everything on a binary depending on libbpf-sys with various features enabled and spot checked the expected dynamic library dependencies. We could enshrine that as a CI step, but given that this logic is expected to change infrequently I didn't go down that road. [0] #64 (comment) Closes: #70 Signed-off-by: Daniel Müller <[email protected]>
Make novendor feature the default
Merge vendored feature into static
There is now only two settings
Side Effect: Clients of libbpf-sys will now compile zlib and elfutils as part of the libbpf-sys project. This has the benefit of ensuring that the libraries are well suited for the rust bindings, but takes extra time during compilation