Skip to content

Commit db83e29

Browse files
authored
Rollup merge of rust-lang#128221 - calebzulawski:implied-target-features, r=Amanieu
Add implied target features to target_feature attribute See [zulip](https://rust-lang.zulipchat.com/#narrow/stream/208962-t-libs.2Fstdarch/topic/Why.20would.20target-feature.20include.20implied.20features.3F) for some context. Adds implied target features, e.g. `#[target_feature(enable = "avx2")]` acts like `#[target_feature(enable = "avx2,avx,sse4.2,sse4.1...")]`. Fixes rust-lang#128125, fixes rust-lang#128426 The implied feature sets are taken from [the rust reference](https://doc.rust-lang.org/reference/attributes/codegen.html?highlight=target-fea#x86-or-x86_64), there are certainly more features and targets to add. Please feel free to reassign this to whoever should review it. r? ``@Amanieu``
2 parents 67d7e92 + f0bcdea commit db83e29

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Diff for: src/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
7575
let function_features = codegen_fn_attrs
7676
.target_features
7777
.iter()
78-
.map(|features| features.as_str())
78+
.map(|features| features.name.as_str())
7979
.collect::<Vec<&str>>();
8080

8181
if let Some(features) = check_tied_features(

Diff for: src/gcc_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
6565

6666
let feature = backend_feature_name(s)?;
6767
// Warn against use of GCC specific feature names on the CLI.
68-
if diagnostics && !supported_features.iter().any(|&(v, _)| v == feature) {
69-
let rust_feature = supported_features.iter().find_map(|&(rust_feature, _)| {
68+
if diagnostics && !supported_features.iter().any(|&(v, _, _)| v == feature) {
69+
let rust_feature = supported_features.iter().find_map(|&(rust_feature, _, _)| {
7070
let gcc_features = to_gcc_features(sess, rust_feature);
7171
if gcc_features.contains(&feature) && !gcc_features.contains(&rust_feature) {
7272
Some(rust_feature)

Diff for: src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ pub fn target_features(
486486
sess.target
487487
.supported_target_features()
488488
.iter()
489-
.filter_map(|&(feature, gate)| {
489+
.filter_map(|&(feature, gate, _)| {
490490
if sess.is_nightly_build() || allow_unstable || gate.is_stable() {
491491
Some(feature)
492492
} else {

0 commit comments

Comments
 (0)