Skip to content

RFC: Add required-targets for workspace package selection - #4013

Merged
weihanglo merged 57 commits into
rust-lang:mainfrom
Sakib25800:required-targets
Nov 1, 2026
Merged

weihanglo merged 57 commits into
rust-lang:mainfrom
Sakib25800:required-targets

Conversation

@Sakib25800

@Sakib25800 Sakib25800 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

View all comments

Summary

Add a required-targets field to the [package] table of Cargo.toml so packages can declare target requirements using cfg syntax.

This builds on #3759 by @carloskiki, and addresses feedback from that proposal.

Rendered

FCP

Tracking issue: rust-lang/cargo#17671

@ranger-ross ranger-ross added the T-cargo Relevant to the Cargo team, which will review and decide on the RFC. label Oct 6, 2026
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Outdated

## Target-specific dependency resolution

`Cargo.lock`, and by extension, `cargo vendor`, must assume that a package may be built on any platform that has or will exist. This means that if a transitive dependency pulls in Windows-specific dependencies, `cargo vendor` will include them when run on a Linux-only application. Being able to tell `cargo vendor` what platforms to care about can reduce the space used in a repo and reduce churn.

@WhyNotHugo WhyNotHugo Oct 6, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, cargo vendor for lot of projects which have ~3MB in dependencies download ~200MB in additional dependencies for unsupported platforms. A huge interest in being able to declare supported targets is to make cargo vendor useful.

Why does this RFC specifically spell out that this misbehaviour must continue?

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That problem is related but as we discussed in #3759, the solutions will end up being very different. This section does talk a lot about that design (a resolver.targets in .cargo/config.toml). See also my comment at #4013 (comment)

Since these can be different RFCs they should so we can have more focused conversations and move things along more smoothly. See also https://epage.github.io/dev/pr-style/#c-isolate

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I kept that from the original RFC. I've now reduced resolver.targets to a quick mention under Related work and removed the design details.

The original RFC has essentially split into two proposals: required-targets for workspace package selection (this one) and resolver.targets for targeted dependency resolution and vendoring, to be covered in another RFC.

@epage

epage commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@Sakib25800 as I'm assuming this is your first RFC, I would recommend

  • Never edit history
  • Make edits in response to feedback in its own commit
  • Reply to the feedback with the commit hash.
  • Only resolve a thread if you are very sure you understood the feedback and handled it as the person expected.

Sakib25800 and others added 3 commits October 14, 2026 22:05
Per rust-lang#4013 (comment)

Co-authored-by: Ed Page <eopage@gmail.com>
Per rust-lang#4013 (comment)

Co-authored-by: Ed Page <eopage@gmail.com>
Per rust-lang#4013 (comment)

Co-authored-by: Ed Page <eopage@gmail.com>
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
Comment thread text/0000-cargo-required-targets.md Resolved
@epage

epage commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@epage

epage commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@rfcbot resolve dependency
@rfcbot resolve no-resolver-rationale
@rfcbot resolve strip-on-publish
@rfcbot resolve supported-cfgs

@epage

epage commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@rfcbot resolve publish

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weihanglo weihanglo moved this to FCP merge in Cargo status tracker Oct 20, 2026
@rust-rfcbot rust-rfcbot added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed proposed-final-comment-period Currently awaiting signoff of all team members in order to enter the final comment period. labels Oct 22, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this RFC. S-waiting-on-review Status: This is awaiting some action from the reviewer. to-announce and removed final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. labels Nov 1, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks folks for your participation! This has passed FCP. Merging right now.

Further discussion and progress update would happen in rust-lang/cargo#17671.

View changes since this review

@weihanglo
weihanglo merged commit 3bdcd22 into rust-lang:main Nov 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This RFC is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this RFC. S-waiting-on-review Status: This is awaiting some action from the reviewer. T-cargo Relevant to the Cargo team, which will review and decide on the RFC. to-announce

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants