Skip to content
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

Add std_detect::detect::features() API that returns iterator of target-features and reject unstable features in feature-detection macros #739

Merged
merged 5 commits into from
Sep 16, 2019

Conversation

gnzlbg
Copy link
Contributor

@gnzlbg gnzlbg commented Apr 23, 2019

This PR implements an unstable features() function in std::detect that returns an iterator over the target features, returning a tuple of the target-feature name, and whether it is enabled or disabled in the current host.

This can be used to implement a solution to rust-lang/rust#54688 using our own run-time feature detection system.

The refactor required to implement this also allows us to close #667

@gnzlbg gnzlbg force-pushed the feature_iterator branch from a93d94d to 6703f2a Compare May 9, 2019 16:04
@lu-zero
Copy link
Contributor

lu-zero commented Sep 13, 2019

Do you plan to rebase this? I could use something like this to map the env var content to the features.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 13, 2019

Yep, I'll merge this today.

Copy link
Contributor

@lu-zero lu-zero left a comment

Choose a reason for hiding this comment

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

It looks fine and I'd use it

@lu-zero
Copy link
Contributor

lu-zero commented Sep 16, 2019

It rebases cleanly but if I try to build it I get:

    Checking core_arch v0.1.5 (/Users/lu_zero/Sources/rust/stdarch/crates/core_arch)
error[E0658]: non-builtin inner attributes are unstable
 --> crates/core_arch/src/simd.rs:3:1
  |
3 | #![rustfmt::skip]
  | ^^^^^^^^^^^^^^^^^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/54726
  = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 16, 2019

Damn I forgot about this.

@lu-zero
Copy link
Contributor

lu-zero commented Sep 16, 2019

Actually I had a problem with my local repo and origin/master was pointing to the wrong place, so a rebase isn't immediate :)

(if you have time to rebase and push would be great)

@gnzlbg gnzlbg changed the title Add std_detect::detect::features() API that returns iterator of target-features Add std_detect::detect::features() API that returns iterator of target-features and reject unstable features in feature-detection macros Sep 16, 2019
@lu-zero
Copy link
Contributor

lu-zero commented Sep 16, 2019

If it survives I guess it should be good to go pending some shuffling/amending.

@gnzlbg gnzlbg merged commit 7e498df into rust-lang:master Sep 16, 2019
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 16, 2019

Gonna update stdarch upstream and do a crater run. There might be code in the wild accidentally relying on some of the unstable features.

oconnor663 added a commit to oconnor663/stdsimd that referenced this pull request Feb 27, 2020
rust-lang#739 added per-feature
stabilization of runtime CPU feature detection. In so doing, it
de-stabilized some detection features that had been stable since Rust
1.27.0, breaking some published crates (on nightly). This commit
re-stabilizes the subset of AVX-512 detection features that were
included in 1.27.0 (that is, the pre-Ice-Lake subset). Other instruction
sets (MMX in particular) remain de-stabilized, pending a decision about
whether should ever stabilize them.

See rust-lang/rust#68905.
Amanieu pushed a commit that referenced this pull request Mar 19, 2020
…#842)

* re-stabilize the AVX-512 features that were stabilized in Rust 1.27.0

#739 added per-feature
stabilization of runtime CPU feature detection. In so doing, it
de-stabilized some detection features that had been stable since Rust
1.27.0, breaking some published crates (on nightly). This commit
re-stabilizes the subset of AVX-512 detection features that were
included in 1.27.0 (that is, the pre-Ice-Lake subset). Other instruction
sets (MMX in particular) remain de-stabilized, pending a decision about
whether should ever stabilize them.

See rust-lang/rust#68905.

* add a comment explaining feature detection stability

* adjust stabilizations to match most recent proposal

rust-lang/rust#68905 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std_detect is_x86_feature_detected macro should reject unstable features if they are not enabled
2 participants