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

Add vendored cargo feature #309

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add vendored cargo feature #309

wants to merge 1 commit into from

Conversation

kpcyrd
Copy link

@kpcyrd kpcyrd commented Nov 11, 2024

This is already the default behavior of the zstd crate, but this feature allows the following:

[feature]
vendored = ["openssl/vendored", "zstd/vendored"]

[dependencies]
openssl = "0.10"
zstd = { version = "0.13", features = ["pkg-config"] }

With a Cargo.toml like this, the default behavior would by dynamic linking for both openssl and zstd, and a static binary could be built with:

cargo build --target x86_64-unknown-linux-musl -F vendored

At the moment, the Cargo.toml would need to be written like this:

[feature]
default = ["zstd/pkg-config"]
vendored = ["openssl/vendored"]

[dependencies]
openssl = "0.10"
zstd = "0.13"

And built like this:

cargo build --target x86_64-unknown-linux-musl --no-default-features -F vendored

I also made sure that, even with the vendored feature set, one could still opt into dynamic linking with:

ZSTD_SYS_USE_PKG_CONFIG=1 cargo build

The options take precedence in this order (lowest to highest):

  1. default (vendored)
  2. pkg-config (dynamically linked)
  3. vendored (vendored)
  4. ZSTD_SYS_USE_PKG_CONFIG=1 (dynamically linked)

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

Successfully merging this pull request may close these issues.

1 participant