-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Support --filter-platform=host for cargo metadata #9423
Copy link
Copy link
Closed
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-metadataE-easyExperience: EasyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-metadataE-easyExperience: EasyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 metadataand doesn't supply--filter-platformends 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 invokingrustc -vVand parsing out thehost: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.tomland the like.Describe the solution you'd like
The
cargo metadata --filter-platformflag 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.