Skip to content

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

Merged
gnzlbg merged 5 commits into
rust-lang:masterfrom
gnzlbg:feature_iterator
Sep 16, 2019
Merged

Conversation

@gnzlbg

@gnzlbggnzlbg commented Apr 23, 2019

Copy link
Copy Markdown
Contributor

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
gnzlbgforce-pushed the feature_iterator branch from a93d94d to 6703f2aCompareMay 9, 2019 16:04
@lu-zero

Copy link
Copy Markdown
Contributor

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

@gnzlbg

Copy link
Copy Markdown
ContributorAuthor

Yep, I'll merge this today.

@lu-zerolu-zero left a comment

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.

It looks fine and I'd use it

@lu-zero

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

Damn I forgot about this.

@lu-zero

Copy link
Copy Markdown
Contributor

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)

@gnzlbggnzlbg changed the title Add std_detect::detect::features() API that returns iterator of target-featuresAdd std_detect::detect::features() API that returns iterator of target-features and reject unstable features in feature-detection macrosSep 16, 2019
@lu-zero

Copy link
Copy Markdown
Contributor

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

@gnzlbg
gnzlbg merged commit 7e498df into rust-lang:masterSep 16, 2019
@gnzlbg

Copy link
Copy Markdown
ContributorAuthor

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 freeto 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

@gnzlbg@lu-zero