Skip to content

Commit 3aba2d9

Browse files
committed
add dedicated type for ABI target feature constraints
1 parent 940cbb8 commit 3aba2d9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/gcc_util.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
4747

4848
// Ensure that all ABI-required features are enabled, and the ABI-forbidden ones
4949
// are disabled.
50-
let (abi_enable, abi_disable) = sess.target.abi_required_features();
51-
let abi_enable_set = FxHashSet::from_iter(abi_enable.iter().copied());
52-
let abi_disable_set = FxHashSet::from_iter(abi_disable.iter().copied());
50+
let abi_feature_constraints = sess.target.abi_required_features();
51+
let abi_incompatible_set =
52+
FxHashSet::from_iter(abi_feature_constraints.incompatible.iter().copied());
5353

5454
// Compute implied features
5555
let mut all_rust_features = vec![];
@@ -72,7 +72,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
7272
}
7373
}
7474
}
75-
// Remove features that are meant for rustc, not LLVM.
75+
// Remove features that are meant for rustc, not codegen.
7676
all_rust_features.retain(|(_, feature)| {
7777
// Retain if it is not a rustc feature
7878
!RUSTC_SPECIFIC_FEATURES.contains(feature)
@@ -121,7 +121,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
121121

122122
// Ensure that the features we enable/disable are compatible with the ABI.
123123
if enable {
124-
if abi_disable_set.contains(feature) {
124+
if abi_incompatible_set.contains(feature) {
125125
sess.dcx().emit_warn(ForbiddenCTargetFeature {
126126
feature,
127127
enabled: "enabled",
@@ -131,8 +131,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
131131
} else {
132132
// FIXME: we have to request implied features here since
133133
// negative features do not handle implied features above.
134-
#[allow(rustc::potential_query_instability)] // order does not matter
135-
for &required in abi_enable_set.iter() {
134+
for &required in abi_feature_constraints.required.iter() {
136135
let implied = sess.target.implied_target_features(std::iter::once(required));
137136
if implied.contains(feature) {
138137
sess.dcx().emit_warn(ForbiddenCTargetFeature {
@@ -158,7 +157,11 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
158157
// still override it... that's unsound, but more compatible with past behavior.
159158
all_rust_features.splice(
160159
0..0,
161-
abi_enable.iter().map(|&f| (true, f)).chain(abi_disable.iter().map(|&f| (false, f))),
160+
abi_feature_constraints
161+
.required
162+
.iter()
163+
.map(|&f| (true, f))
164+
.chain(abi_feature_constraints.incompatible.iter().map(|&f| (false, f))),
162165
);
163166

164167
// Translate this into GCC features.

0 commit comments

Comments
 (0)