Skip to content

Implement cfg_os_version_min #136867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Feb 11, 2025

Implement the cfg_os_version_min feature that is being RFC'd in rust-lang/rfcs#3750, tracking issue #136866. This implementation only handles Apple targets, but it should be fairly easy to add support for other targets after this.

The RFC is not finalized, and as such things may change (especially the syntax). Regardless, I think it makes sense to start experimenting with it; even if the feature is ultimately rejected, it is necessary for the standard library (an example is that it would allow us to ship #122408 without a dangerous fallback).

Using this in the standard library is done in a draft PR.

CC @ChrisDenton @BlackHoleFox
@rustbot label O-apple
r? rust-lang/compiler

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 11, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

These commits modify compiler targets.
(See the Target Tier Policy.)

@rust-log-analyzer

This comment has been minimized.

@jieyouxu

This comment was marked as resolved.

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 11, 2025
@madsmtm
Copy link
Contributor Author

madsmtm commented Feb 11, 2025

since it looks like some of the design questions haven't quite settled yet

Hmm, I was hoping to resolve those in future PRs, since I believe this feature is useful to the standard library today (or rather yesterday), regardless of future semantics and syntax.

Would it help if I renamed it to rustc_os_version_min in the meantime?

@Urgau
Copy link
Member

Urgau commented Feb 11, 2025

You should ask T-lang to approve this PR as an "T-lang experiment", that way it could implemented in the compiler even without an FCP on the RFC.

@madsmtm
Copy link
Contributor Author

madsmtm commented Feb 11, 2025

T-lang experiment

Right, that's what it's called, couldn't remember, thanks! (filed #136871 so that I'll be able to find it in the future)

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

Hmm, I was hoping to resolve those in future PRs, since I believe this feature is useful to the standard library today (or rather yesterday), regardless of future semantics and syntax.

Would it help if I renamed it to rustc_os_version_min in the meantime?

Probably worth trying this as a T-lang experiment yeah

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Feb 11, 2025
Copy link
Member

@SparrowLii SparrowLii left a comment

Choose a reason for hiding this comment

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

Thanks for your work! But I know little about this feature so r? compiler

@rustbot rustbot assigned jieyouxu and unassigned SparrowLii Feb 12, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 12, 2025
…=scottmcm

dev-guide: Link to `t-lang` procedures for new features

I was confused in rust-lang#136867, because while I did remember that such a procedure existed, but I couldn't seem to find it in the dev guide.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 12, 2025
Rollup merge of rust-lang#136871 - madsmtm:link-to-lang-procedures, r=scottmcm

dev-guide: Link to `t-lang` procedures for new features

I was confused in rust-lang#136867, because while I did remember that such a procedure existed, but I couldn't seem to find it in the dev guide.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Feb 13, 2025
dev-guide: Link to `t-lang` procedures for new features

I was confused in rust-lang/rust#136867, because while I did remember that such a procedure existed, but I couldn't seem to find it in the dev guide.
@bors
Copy link
Collaborator

bors commented Feb 15, 2025

☔ The latest upstream changes (presumably #137046) made this pull request unmergeable. Please resolve the merge conflicts.

@madsmtm madsmtm force-pushed the cfg_os_version_min branch from bb55488 to 2a44225 Compare March 26, 2025 14:33
@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@madsmtm madsmtm marked this pull request as draft March 26, 2025 14:43
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 28, 2025

☔ The latest upstream changes (presumably #139037) made this pull request unmergeable. Please resolve the merge conflicts.

Zalathar added a commit to Zalathar/rust that referenced this pull request Apr 4, 2025
…=Noratrieb

Refactor Apple version handling in the compiler

Move various Apple version handling code in the compiler out `rustc_codegen_ssa` and into a place where it can be accessed by `rustc_attr_parsing`, which I found to be necessary when doing rust-lang#136867. Thought I'd split it out to make it easier to land, and to make further changes like rust-lang#131477 have fewer conflicts / PR dependencies.

There should be no functional changes in this PR.

`@rustbot` label O-apple
r? rust-lang/compiler
Zalathar added a commit to Zalathar/rust that referenced this pull request Apr 4, 2025
…=Noratrieb

Refactor Apple version handling in the compiler

Move various Apple version handling code in the compiler out `rustc_codegen_ssa` and into a place where it can be accessed by `rustc_attr_parsing`, which I found to be necessary when doing rust-lang#136867. Thought I'd split it out to make it easier to land, and to make further changes like rust-lang#131477 have fewer conflicts / PR dependencies.

There should be no functional changes in this PR.

``@rustbot`` label O-apple
r? rust-lang/compiler
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2025
…oratrieb

Refactor Apple version handling in the compiler

Move various Apple version handling code in the compiler out `rustc_codegen_ssa` and into a place where it can be accessed by `rustc_attr_parsing`, which I found to be necessary when doing rust-lang#136867. Thought I'd split it out to make it easier to land, and to make further changes like rust-lang#131477 have fewer conflicts / PR dependencies.

There should be no functional changes in this PR.

`@rustbot` label O-apple
r? rust-lang/compiler
@madsmtm madsmtm force-pushed the cfg_os_version_min branch from 2a44225 to b15e23c Compare April 6, 2025 13:45
@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm force-pushed the cfg_os_version_min branch from b15e23c to bf8be08 Compare April 6, 2025 15:10
@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm force-pushed the cfg_os_version_min branch from bf8be08 to b440c36 Compare April 6, 2025 23:42
@rust-log-analyzer

This comment has been minimized.

Based on in-progress RFC: rust-lang/rfcs#3750.

Only implemented for Apple platforms for now, but written in a way that
should be easily expandable to include other platforms.
@madsmtm madsmtm force-pushed the cfg_os_version_min branch from b440c36 to 00bdfcc Compare April 7, 2025 00:44
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Apr 7, 2025
Refactor Apple version handling in the compiler

Move various Apple version handling code in the compiler out `rustc_codegen_ssa` and into a place where it can be accessed by `rustc_attr_parsing`, which I found to be necessary when doing rust-lang/rust#136867. Thought I'd split it out to make it easier to land, and to make further changes like rust-lang/rust#131477 have fewer conflicts / PR dependencies.

There should be no functional changes in this PR.

`@rustbot` label O-apple
r? rust-lang/compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants