Skip to content

Commit ac70558

Browse files
committed
target_features: explain what exacty 'implied' means here
1 parent f5b6257 commit ac70558

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,13 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
344344
})
345345
{
346346
if enabled {
347+
// Also add all transitively implied features.
347348
features.extend(sess.target.implied_target_features(std::iter::once(feature)));
348349
} else {
350+
// `!feature` implies `!other_feature` if `other_feature` (transitively) implies `feature`,
351+
// i.e., if `other_feature` is a reverse dependency of `feature`.
352+
// So we have to remove `other_feature`.
353+
349354
// We don't care about the order in `features` since the only thing we use it for is the
350355
// `features.contains` below.
351356
#[allow(rustc::potential_query_instability)]

compiler/rustc_target/src/target_features.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ impl Stability {
9292
//
9393
// Stabilizing a target feature requires t-lang approval.
9494

95+
// If feature A "implies" feature B, then:
96+
// - when A gets enabled (via `-Ctarget-feature` or `#[target_feature]`), we also enable B
97+
// - when B gets disabled (via `-Ctarget-feature`), we also disable A
98+
//
99+
// Both of these are also applied transitively.
95100
type ImpliedFeatures = &'static [&'static str];
96101

97102
const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[

0 commit comments

Comments
 (0)