Unneeded dependency compiled

⚓ Rust    📅 2025-11-26    👤 surdeus    👁️ 7      

surdeus

I have a workspace with several packages.
The root Cargo.toml lists rustls under [workspace.dependencies]

Only one of the packages in the codebase is directly dependent on rustls.
It uses this to set up a default crypto provider: rustls::crypto::aws_lc_rs::default_provider()

What I can't explain (and this is causing me problems whilst cross-compiling), is that when I use "cargo build --bin" for a binary in another package, which, according to "cargo tree", has no dependency on aws-lc-rs or rustls whatsoever, it will still compile the aws crates!
In particular, it is the file cc_builder.rs in the source code of aws-lc-rs that is failing during cross compilation.

I know how to fork from aws-lc-rs and use "[patch]" in the root Cargo.toml to prevent running into the cross-compilation error, but I'd rather have an explanation as to why aws-lc-rs is compiled for a binary that doesn't depend on it?

I'm using cargo 1.91.1

2 posts - 2 participants

Read full topic

🏷️ Rust_feed