|
1 | 1 | use crate::back::write::create_informational_target_machine;
|
2 | 2 | use crate::errors::{
|
3 | 3 | PossibleFeature, TargetFeatureDisableOrEnable, UnknownCTargetFeature,
|
4 |
| - UnknownCTargetFeaturePrefix, |
| 4 | + UnknownCTargetFeaturePrefix, UnstableCTargetFeature, |
5 | 5 | };
|
6 | 6 | use crate::llvm;
|
7 | 7 | use libc::c_int;
|
@@ -531,25 +531,34 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
531 | 531 | };
|
532 | 532 |
|
533 | 533 | let feature = backend_feature_name(s)?;
|
534 |
| - // Warn against use of LLVM specific feature names on the CLI. |
535 |
| - if diagnostics && !supported_features.iter().any(|&(v, _)| v == feature) { |
536 |
| - let rust_feature = supported_features.iter().find_map(|&(rust_feature, _)| { |
537 |
| - let llvm_features = to_llvm_features(sess, rust_feature); |
538 |
| - if llvm_features.contains(&feature) && !llvm_features.contains(&rust_feature) { |
539 |
| - Some(rust_feature) |
| 534 | + // Warn against use of LLVM specific feature names and unstable features on the CLI. |
| 535 | + if diagnostics { |
| 536 | + let feature_state = supported_features.iter().find(|&&(v, _)| v == feature); |
| 537 | + if feature_state.is_none() { |
| 538 | + let rust_feature = supported_features.iter().find_map(|&(rust_feature, _)| { |
| 539 | + let llvm_features = to_llvm_features(sess, rust_feature); |
| 540 | + if llvm_features.contains(&feature) |
| 541 | + && !llvm_features.contains(&rust_feature) |
| 542 | + { |
| 543 | + Some(rust_feature) |
| 544 | + } else { |
| 545 | + None |
| 546 | + } |
| 547 | + }); |
| 548 | + let unknown_feature = if let Some(rust_feature) = rust_feature { |
| 549 | + UnknownCTargetFeature { |
| 550 | + feature, |
| 551 | + rust_feature: PossibleFeature::Some { rust_feature }, |
| 552 | + } |
540 | 553 | } else {
|
541 |
| - None |
542 |
| - } |
543 |
| - }); |
544 |
| - let unknown_feature = if let Some(rust_feature) = rust_feature { |
545 |
| - UnknownCTargetFeature { |
546 |
| - feature, |
547 |
| - rust_feature: PossibleFeature::Some { rust_feature }, |
548 |
| - } |
549 |
| - } else { |
550 |
| - UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None } |
551 |
| - }; |
552 |
| - sess.emit_warning(unknown_feature); |
| 554 | + UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None } |
| 555 | + }; |
| 556 | + sess.emit_warning(unknown_feature); |
| 557 | + } else if feature_state.is_some_and(|(_name, feature_gate)| feature_gate.is_some()) |
| 558 | + { |
| 559 | + // An unstable feature. Warn about using it. |
| 560 | + sess.emit_warning(UnstableCTargetFeature { feature }); |
| 561 | + } |
553 | 562 | }
|
554 | 563 |
|
555 | 564 | if diagnostics {
|
|
0 commit comments