Determining where all the copies of my crate are coming from

Let's say I have a crate with features ios, android, and desktop. I frequently compile the crate with each one of the features set individually, and also work in an IDE where I have --all-features active, which lets me see errors in both shared and platform-specific code. Unsurprisingly, this counts as four different variations of the crate, leading to four separate copies of the crate data in target/debug/deps and target/debug/incremental. (It might be nice if more of that could be shared, but I know that's a Hard Problem with Difficult Tradeoffs.)

Except sometimes it's not just four. Build configuration and certain other options have to line up as well, or else we're secretly in a fifth variation, or a sixth, or a seventh. Dependencies also sometimes split more than I expect even though they aren't listed as feature-specific. I do know one case of this, which is multiple crate-targets per package (like a bin and lib, or a lib and build script), but I still feel like I'm seeing more configurations than I'd like, and my disk space is suffering for it.

Are there any tools to reveal the configuration information that goes into a given crate variant? Or anything else to help me follow up on this proliferation? Thanks!

(Note that I'm not talking about proper cross-compilation with --target/CARGO_BUILD_TARGET here. I get that those build directories won't be shared. The ios case is built locally to run host-based tests on the library that will also, later, be built targeting aarch64-apple-ios, and in release mode to boot.)

1 Like