Stop listing ring in Cargo.lock when ring feature is not enabled#487
Open
ismailhkose wants to merge 1 commit intorustls:rel-0.103from
Open
Stop listing ring in Cargo.lock when ring feature is not enabled#487ismailhkose wants to merge 1 commit intorustls:rel-0.103from
ismailhkose wants to merge 1 commit intorustls:rel-0.103from
Conversation
The `alloc = ["ring?/alloc", ...]` weak optional-dep activator caused
Cargo to record `ring` as a resolved dep in downstream lockfiles even
when no consumer activates `rustls-webpki/ring`. This was confusing
to users on the rustls + alternative-provider path (e.g. rustls-symcrypt),
who saw `ring` pinned in their Cargo.lock without it actually being
compiled.
Move the `ring/alloc` activation onto the `ring` feature itself, and
have the `ring` feature imply `alloc`. This matches the practical
reality that the ring-backed RSA verification algorithms in
src/ring_algs.rs are gated on `cfg(all(feature = "ring", feature = "alloc"))`
and reference ring APIs that are themselves gated on `ring/alloc`, so
ring users in practice always also enable alloc.
Note: this is a minor feature-graph expansion. Enabling `ring` without
`alloc` previously yielded an ECDSA-only build; now `ring` transitively
activates `alloc` and exposes RSA APIs as well. No public API is
removed, and no existing build configuration breaks.
Verified locally:
* cargo check across {default, --no-default-features, alloc, ring,
ring+alloc, ring+std, aws-lc-rs, --all-features} all pass
* cargo test --features ring,alloc,std passes (all suites green)
* cargo test --features aws-lc-rs,alloc,std passes (all suites green)
* In a downstream rustls + rustls-symcrypt workspace, `ring` no longer
appears in Cargo.lock and rustls-webpki's resolved deps shrink to
rustls-pki-types and untrusted.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rel-0.103 #487 +/- ##
==========================================
Coverage 97.42% 97.42%
==========================================
Files 19 19
Lines 3845 3845
==========================================
Hits 3746 3746
Misses 99 99 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
I don't like the trade-off of working around a Cargo resolver issue by forcing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Downstream consumers of
rustls-webpki0.103.x that do not enable theringfeature still seering v0.17.14recorded in theirCargo.lock. The crate is never actually compiled (verified viacargo tree,cargo metadata, and inspection oftarget/), but the phantom entry shows up in dependency audits and confuses users on the rustls + alternative-provider path (e.g. consumers usingrustls-symcrypt,rustls-graviola, or another custom provider).Root cause: the
allocfeature uses the weak optional-dep activatorring?/alloc. Cargo's resolver records resolved versions for any optional dep referenced viadep?/..., even when the activation condition is never met by any consumer in the workspace.Fix
Drop
ring?/allocfrom theallocfeature. Move thering/allocactivation onto theringfeature itself, and haveringimplyalloc.This matches the existing source layout: the ring-backed RSA verification algorithms in
src/ring_algs.rsare gated oncfg(all(feature = \"ring\", feature = \"alloc\"))and reference ring APIs that themselves requirering/alloc, so any practical user of theringfeature already had to enableallocfor a useful RSA-capable build.Verification
cargo checkacross{default, --no-default-features, alloc, ring, ring,alloc, ring,std, aws-lc-rs, --all-features}— all passcargo test --features ring,alloc,std --no-default-features— all suites greencargo test --features aws-lc-rs,alloc,std --no-default-features— all suites greenring?/allocdeletion alone) is insufficient: it breaks--features ring,allocbecause the RSA algorithm static items reference ring APIs gated onring/alloc. Hence the two-line variant in this PR.rustls+rustls-symcrypt(noringfeature enabled by anyone), applying this patch via[patch.crates-io]causesringto disappear fromCargo.lockandrustls-webpki's resolved deps to shrink torustls-pki-typesanduntrusted.Compatibility
Minor feature-graph expansion: enabling
ringnow transitively activatesallocandring/alloc, exposing RSA APIs in addition to ECDSA. No public API is removed.The only edge case affected is a no_std-with-ring-but-explicitly-no-alloc build, which previously got an ECDSA-only surface and now picks up
allocimplicitly. Worth a CHANGELOG note. In practice this configuration is uncommon since the ECDSA-only ring build offers a small benefit and most ring-feature users enableallocanyway.Scope
mainalready addresses this differently for 0.104 (commit drops theringandaws-lc-rsintegrations from the main crate entirely, splitting them into separaterustls-ring/rustls-aws-lc-rscrates). This PR only targetsrel-0.103to clean up the lockfile noise on the currently released line during the time before 0.104 stable.