Unneeded dependency compiled

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

Does this package that directly depends on rustls (or any other package that directly or indirectly depends on rustls) also get compiled?

No, the package that actually depends on rustls doesn't get compiled when using "cargo build --bin "

Do you have a reproducer that you can share?

My bad, after some searching I found the answers I was looking for!

First of all, I have found that there really is a dependency, I just couldn't see it with cargo tree. What I needed was cargo tree --workspace --all-features --no-dedupe.

Secondly, I found a way to get the rustls compiled without the need for aws-lc-rs.

So all is well, I guess the only question that remains is: could I alternatively have included rustls in our source code twice, once with aws-lc-rs and once without?