-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the problem you are trying to solve
The cargo metadata command, unlike other cargo commands, defaults to fetching information for dependencies across all target platforms. This in turn means that any tool that calls cargo metadata
and doesn't supply --filter-platform
ends up downloading a potentially large number of dependencies for targets that other cargo commands wouldn't have fetched. This is usually unintended on the part of the tools that invoke cargo metadata, as they are often fine with just getting the metadata filtered to the current platform.
Unfortunately, the current state of affairs requires users of cargo metadata to determine the host triple to pass to --filter-platform
, which usually means invoking rustc -vV
and parsing out the host:
line if the user hasn't passed in an explicit target tuple (mozilla/cbindgen#676, rust-lang/rust-analyzer#6912, intellij-rust/intellij-rust#7185). That is cumbersome, error-prone, and doesn't pick up things like reconfiguration of rustc through .cargo/config.toml
and the like.
Describe the solution you'd like
The cargo metadata --filter-platform
flag should support a new value, host
, that uses the target triple for the current host platform. Callers can then use that value rather than try to determine that value themselves.