-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: cfg_os_version_min #3750
base: master
Are you sure you want to change the base?
RFC: cfg_os_version_min #3750
Conversation
A set of comparison functions can be provided by `rustc` for common formats such as 2- and 3-part semantic versioning. | ||
When a platform detects a key it doesn’t support it will return `false` and emit a warning. | ||
|
||
Each target platform will set the minimum API versions it supports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is no way for the user to configure which minimum API version they want to use? That would make it impossible for eg the libc crate to gate api's behind #[cfg(os_version_min)]
corresponding to the libc version that introduced the API in question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. One of the issues with the original proposals was there was too much going on. This RFC aims to add the minimally useful feature. Adding compiler flags and Cargo configs to control the minimum version can be a future extension.
With this RFC it is still possible for libc to gate APIs like that. However, you'd need a new target in order to set a different minimal libc version.
The idea is great, but I think the syntax can be improved. It makes more sense to have this feature under the existing cfg(target_os("windows", min_version = "...")) Another idea: cfg(target_os = "windows >= ...") |
That may work for windows but not, for example, Linux where you may want to cfg on the kernel version or the libc version (or even both). libc isn't really a |
Right, so this could be done with a cfg(target_libc("glibc", min_version = "...")) But of course this would add more complexity. |
This RFC is largely the work of @rylev and @chriswailes. As suggested by @tmandry I have stripped it down to an MVP that just adds
os_version_min
.Rendered