-
Notifications
You must be signed in to change notification settings - Fork 271
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
Replace dangerous cargo features with rustc flags #263
Conversation
This feature was not useful for Cargo users, since Cargo does not give you the kind of fine-grained control over C library linkage that you need. So it was just unnecessarily confusing and would cause the build to break if you enabled it accidentally, say, with --all-features.
It's super dangerous to use Cargo features for this, since they can be set accidentally (or maliciously by any crate in a user's entire dep tree). Instead we can just require users set `RUSTFLAGS` appropriately, which we can easily do in our fuzzing scripts.
2c872d5
to
85075a6
Compare
external-symbols
featureif cfg!(feature = "external-symbols") { | ||
println!("cargo:rustc-link-lib=static=secp256k1"); | ||
return; | ||
} | ||
|
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.
We don't want to leave if cfg!("rust_secp_no_symbol_renaming")
here?
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.
No, all this does is set a flag that Cargo understands ... but if you are using Cargo then you shouldn't be using this flag, since you'll get symbol collisions and other messy results.
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.
Nice!
This will enable the use of --all-features
again!
In secp256k1-sys we replaced this feature with a cfg flag back in rust-bitcoin/rust-secp256k1#263 ... here we got rid of the feature but retained the feature-gate, making the functionality useless. While we are at it, whitelist the cfg flags that we _do_ use.
cc @TheBlueMatt
For Core integration you now need to add
--cfg=rust_secp_no_symbol_renaming
to your rustc flags rather than--cfg=features=external-symbols
.For fuzzing you need to add
--cfg=rust_secp_fuzz
rather than--cfg=features=fuzztarget
. Our downstream fuzzing scripts will need to be adjusted.