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

fix rustls-aws-lc-rs feature #2015

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Conversation

stormshield-gt
Copy link
Contributor

@stormshield-gt stormshield-gt commented Oct 17, 2024

In the current Rust editions, if a dependency is declared as optional and it also exists a feature with the same name, dep:name will activate both the feature and the optional dependency.

That is the case for the rustls feature, so sadly

rustls-aws-lc-rs = ["dep:rustls", "rustls/aws-lc-rs", "aws-lc-rs"]

will also activate the rustls feature, which also activates ring.

There is a zulip discussion about this surprising behavior here.

Hopefully, in Rust 2024 edition, with this change, the behavior will be less surprising.

The PR introduce a breaking change, but as far as I know, there is no other way to fix this

Edit: I misunderstood the zulip thread; it's the crate/feature syntax that activates both the optional dependency and the feature if there is one with the same name. Not the dep:crate one. We can just use the crate?/feature syntax here and it should be non-breaking.

@djc
Copy link
Member

djc commented Oct 17, 2024

The PR introduce a breaking change, but as far as I know, there is no other way to fix this

I don't think we want to do a breaking change for this.

@stormshield-gt
Copy link
Contributor Author

I don't think we want to do a breaking change for this.

I see, do you have any ideas about other alternatives?

Right now the aws-lc-rs rustls-aws-lc-rs features cannot be used in the current state because quinn still uses the ring provider when they are activated.

By executing this command on main we can see that the ring feature is activated on quinn-proto, so in case of using rustls-aws-lc-rs we will fallback to use ring:

$ cargo tree -p quinn -f "{p} {f}" --no-default-features --features rustls-aws-lc-rs
quinn v0.11.5 (/home/tudyg/dev/forks/quinn/quinn) aws-lc-rs,rustls-aws-lc-rs
├── bytes v1.7.2 default,std
├── pin-project-lite v0.2.14
├── quinn-proto v0.11.8 (/home/tudyg/dev/forks/quinn/quinn-proto) aws-lc-rs,ring,rustls,rustls-aws-lc-rs,rustls-ring

@djc
Copy link
Member

djc commented Oct 17, 2024

Maybe we can rename the rustls dependency to something else (like, rustls-core or something), adapting the code, to avoid dep:rustls triggering the feature of the same name?

@djc
Copy link
Member

djc commented Oct 17, 2024

Note that we haven't released #1962 yet, so changing the aws-lc-rs features in backwards-incompatible ways could also be an option.

@stormshield-gt
Copy link
Contributor Author

Some job failures (https://github.com/quinn-rs/quinn/actions/runs/11383037824/job/31667830692?pr=2015) seems unrelated to this PR, maybe this PR #2007 didn't pass fully the PR CI?

Maybe we can rename the rustls dependency to something else (like, rustls-core or something), adapting the code, to avoid dep:rustls triggering the feature of the same name?

Great idea, I will try this out

@stormshield-gt
Copy link
Contributor Author

stormshield-gt commented Oct 17, 2024

I misunderstood the zulip thread; it's the crate/feature syntax that activates both the optional dependency and the feature if there is one with the same name. Not the dep:crate one. We can just use the crate?/feature syntax here and it should be non-breaking.

I've added an edit to the PR description just in case

@stormshield-gt
Copy link
Contributor Author

I've noticed some related things; I don't know where to put this out, so I put it here.

  • Why the smoll and async-std are optional but not tokio? Some people, not us, might want to use the smoll and async-std runtime without compiling tokio.
  • In the code the smol and the runtime-smol features are used interchangeably in #[cfg()]. Maybe it could be better to just use the runtime-smol everywhere, so we could use the crate/?feature syntax in the Cargo.toml. It will get rid of the implicit smol feature, better anticipating the 2024 edition.

@stormshield-gt stormshield-gt changed the title Remove the rustls feature, as it's also activated with dep:rustls fix rustls-aws-lc-rs feature Oct 17, 2024
@Ralith
Copy link
Collaborator

Ralith commented Oct 17, 2024

Why the smoll and async-std are optional but not tokio? Some people, not us, might want to use the smoll and async-std runtime without compiling tokio.

We use some portable synchronization primitives provided by tokio. When the runtime-tokio feature is not enabled, then the runtime components of tokio will not be compiled, so such a hypothetical user needn't be concerned about wasted compile time or code size.

Maybe it could be better to just use the runtime-smol everywhere

Seems reasonable.

@djc djc added this pull request to the merge queue Oct 17, 2024
@djc
Copy link
Member

djc commented Oct 17, 2024

Looks great, thanks!

Merged via the queue into quinn-rs:main with commit 184568e Oct 17, 2024
14 checks passed
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