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

Why does libbz2-rs-sys enable bzip2-sys/static #120

Open
kpcyrd opened this issue Dec 14, 2024 · 0 comments
Open

Why does libbz2-rs-sys enable bzip2-sys/static #120

kpcyrd opened this issue Dec 14, 2024 · 0 comments

Comments

@kpcyrd
Copy link

kpcyrd commented Dec 14, 2024

hello! :)

I was wondering, why does opt-ing into the Rust implementation also enable static linking on bzip2-sys? I may still have this in my dependency tree for other reasons, as there are a few other crates depending on it besides bzip2.

It also makes it slightly harder to figure out what'd happen in this specific combination (since features are additive, even when enabled from inside a transitive dependency):

cargo new --bin foo
cargo new --lib bar
cd bar
cargo add bzip2
cd ../foo
cargo add bzip2 --no-default-features -F libbz2-rs-sys
cargo add --path ../bar
cargo build

In the dependency tree there's going to be both:

% cargo tree --no-dedupe
foo v0.1.0 (/redacted/foo)
├── bar v0.1.0 (/redacted/bar)
│   └── bzip2 v0.5.0
│       ├── bzip2-sys v0.1.11+1.0.8
│       │   └── libc v0.2.168
│       │   [build-dependencies]
│       │   ├── cc v1.2.4
│       │   │   └── shlex v1.3.0
│       │   └── pkg-config v0.3.31
│       ├── libbz2-rs-sys v0.1.1
│       └── libc v0.2.168
└── bzip2 v0.5.0
    ├── bzip2-sys v0.1.11+1.0.8
    │   └── libc v0.2.168
    │   [build-dependencies]
    │   ├── cc v1.2.4
    │   │   └── shlex v1.3.0
    │   └── pkg-config v0.3.31
    ├── libbz2-rs-sys v0.1.1
    └── libc v0.2.168

But when looking at src/lib.rs in bzip2 it seems the Rust implementation is used (if both features are enabled, not(feature = "libbz2-rs-sys") can't be true):

#[cfg(not(feature = "libbz2-rs-sys"))]
extern crate bzip2_sys as ffi;
#[cfg(feature = "libbz2-rs-sys")]
extern crate libbz2_rs_sys as ffi;

But the static feature makes this harder to verify with ldd.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant