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

Replace dangerous cargo features with rustc flags #263

Merged
merged 3 commits into from
Dec 22, 2020

Conversation

apoelstra
Copy link
Member

@apoelstra apoelstra commented Dec 22, 2020

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.

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.
@apoelstra apoelstra changed the title remove external-symbols feature Replace dangerous cargo features with rustc flags Dec 22, 2020
Comment on lines -29 to -33
if cfg!(feature = "external-symbols") {
println!("cargo:rustc-link-lib=static=secp256k1");
return;
}

Copy link
Member

@elichai elichai Dec 22, 2020

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?

Copy link
Member Author

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.

Copy link
Contributor

@thomaseizinger thomaseizinger left a 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!

@apoelstra apoelstra merged commit 67c9be3 into rust-bitcoin:master Dec 22, 2020
@apoelstra apoelstra deleted the 2020-12--no-extsymb branch December 22, 2020 21:25
@elichai elichai mentioned this pull request Nov 18, 2021
5 tasks
apoelstra added a commit to BlockstreamResearch/rust-secp256k1-zkp that referenced this pull request Jun 10, 2024
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.
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.

3 participants