|
1 | | -use std::iter::FromIterator; |
2 | | - |
3 | 1 | #[cfg(feature = "master")] |
4 | 2 | use gccjit::Context; |
5 | 3 | use rustc_codegen_ssa::codegen_attrs::check_tied_features; |
6 | 4 | use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable; |
7 | | -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 5 | +use rustc_data_structures::fx::FxHashMap; |
8 | 6 | use rustc_data_structures::unord::UnordSet; |
9 | 7 | use rustc_session::Session; |
10 | 8 | use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES; |
@@ -45,12 +43,6 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri |
45 | 43 | let known_features = sess.target.rust_target_features(); |
46 | 44 | let mut featsmap = FxHashMap::default(); |
47 | 45 |
|
48 | | - // Ensure that all ABI-required features are enabled, and the ABI-forbidden ones |
49 | | - // are disabled. |
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()); |
53 | | - |
54 | 46 | // Compute implied features |
55 | 47 | let mut all_rust_features = vec![]; |
56 | 48 | for feature in sess.opts.cg.target_feature.split(',') { |
@@ -117,51 +109,11 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri |
117 | 109 | } |
118 | 110 | } |
119 | 111 |
|
120 | | - // Ensure that the features we enable/disable are compatible with the ABI. |
121 | | - if enable { |
122 | | - if abi_incompatible_set.contains(feature) { |
123 | | - sess.dcx().emit_warn(ForbiddenCTargetFeature { |
124 | | - feature, |
125 | | - enabled: "enabled", |
126 | | - reason: "this feature is incompatible with the target ABI", |
127 | | - }); |
128 | | - } |
129 | | - } else { |
130 | | - // FIXME: we have to request implied features here since |
131 | | - // negative features do not handle implied features above. |
132 | | - for &required in abi_feature_constraints.required.iter() { |
133 | | - let implied = sess.target.implied_target_features(std::iter::once(required)); |
134 | | - if implied.contains(feature) { |
135 | | - sess.dcx().emit_warn(ForbiddenCTargetFeature { |
136 | | - feature, |
137 | | - enabled: "disabled", |
138 | | - reason: "this feature is required by the target ABI", |
139 | | - }); |
140 | | - } |
141 | | - } |
142 | | - } |
143 | | - |
144 | 112 | // FIXME(nagisa): figure out how to not allocate a full hashset here. |
145 | 113 | featsmap.insert(feature, enable); |
146 | 114 | } |
147 | 115 | } |
148 | 116 |
|
149 | | - // To be sure the ABI-relevant features are all in the right state, we explicitly |
150 | | - // (un)set them here. This means if the target spec sets those features wrong, |
151 | | - // we will silently correct them rather than silently producing wrong code. |
152 | | - // (The target sanity check tries to catch this, but we can't know which features are |
153 | | - // enabled in GCC by default so we can't be fully sure about that check.) |
154 | | - // We add these at the beginning of the list so that `-Ctarget-features` can |
155 | | - // still override it... that's unsound, but more compatible with past behavior. |
156 | | - all_rust_features.splice( |
157 | | - 0..0, |
158 | | - abi_feature_constraints |
159 | | - .required |
160 | | - .iter() |
161 | | - .map(|&f| (true, f)) |
162 | | - .chain(abi_feature_constraints.incompatible.iter().map(|&f| (false, f))), |
163 | | - ); |
164 | | - |
165 | 117 | // Translate this into GCC features. |
166 | 118 | let feats = |
167 | 119 | all_rust_features.iter().flat_map(|&(enable, feature)| { |
|
0 commit comments