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

Use feature guard instead of environment variable to enable static link #653

Closed
BusyJay opened this issue Jun 22, 2017 · 5 comments
Closed

Comments

@BusyJay
Copy link
Contributor

BusyJay commented Jun 22, 2017

Using environment variable will have following shortcomings:

  • A rebuild won't be triggered when set an environment variable;
  • If some project always prefer linking statically, there is no clean way to build such a binary.

Features guard can solve both perfectly, and also a rusty way.

@sfackler
Copy link
Owner

This change would probably need to be made in pkg-config first.

@BusyJay
Copy link
Contributor Author

BusyJay commented Jun 26, 2017

I don't get it. OPENSSL_STATIC is not used by pkg-config, right? I think it should be simply adding if cfg!(feature = "static-link") at line https://github.com/sfackler/rust-openssl/blob/master/openssl-sys/build.rs#L395.

@sfackler
Copy link
Owner

OPENSSL_STATIC is used by pkg-config: https://docs.rs/pkg-config/0.3.9/pkg_config/.

@BusyJay
Copy link
Contributor Author

BusyJay commented Jun 26, 2017

Oh, I see. Sorry for my carelessness. Since pkg_confg supports passing --static explicitly, it should be able to check the features and add the flags without breaking old behavior.

@alexcrichton
Copy link
Collaborator

I'd personally find build configuration like this to be more naturally done as environment variables than as features. For example someone building a crate shouldn't need to modify Cargo.toml to configure the build. Additionally crates themselves shoudn't really care whether OpenSSL is linked statically or dynamically, that's more of a question of whomever is generating the final build artifact.

I think the biggest problem with using environment variables, build scripts don't get rerun if they're changed, has now been fixed

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

3 participants