Skip to content

Commit 29e1283

Browse files
authored
Rollup merge of #148253 - bjorn3:dummy_backend_target_features, r=JonathanBrouwer
Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
2 parents f1c5ebe + 4d7c784 commit 29e1283

File tree

1 file changed

+29
-1
lines changed
  • compiler/rustc_interface/src

1 file changed

+29
-1
lines changed

compiler/rustc_interface/src/util.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use rustc_ast as ast;
99
use rustc_attr_parsing::{ShouldEmit, validate_attr};
1010
use rustc_codegen_ssa::back::archive::ArArchiveBuilderBuilder;
1111
use rustc_codegen_ssa::back::link::link_binary;
12+
use rustc_codegen_ssa::target_features::{self, cfg_target_feature};
1213
use rustc_codegen_ssa::traits::CodegenBackend;
13-
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
14+
use rustc_codegen_ssa::{CodegenResults, CrateInfo, TargetConfig};
1415
use rustc_data_structures::fx::FxIndexMap;
1516
use rustc_data_structures::jobserver::Proxy;
1617
use rustc_data_structures::sync;
@@ -354,6 +355,33 @@ impl CodegenBackend for DummyCodegenBackend {
354355
"dummy"
355356
}
356357

358+
fn target_config(&self, sess: &Session) -> TargetConfig {
359+
let (target_features, unstable_target_features) = cfg_target_feature(sess, |feature| {
360+
// This is a standin for the list of features a backend is expected to enable.
361+
// It would be better to parse target.features instead and handle implied features,
362+
// but target.features is a list of LLVM target features, not Rust target features.
363+
// The dummy backend doesn't know the mapping between LLVM and Rust target features.
364+
sess.target.abi_required_features().required.contains(&feature)
365+
});
366+
367+
// To report warnings about unknown features
368+
target_features::flag_to_backend_features::<0>(
369+
sess,
370+
true,
371+
|_| Default::default(),
372+
|_, _| {},
373+
);
374+
375+
TargetConfig {
376+
target_features,
377+
unstable_target_features,
378+
has_reliable_f16: true,
379+
has_reliable_f16_math: true,
380+
has_reliable_f128: true,
381+
has_reliable_f128_math: true,
382+
}
383+
}
384+
357385
fn supported_crate_types(&self, _sess: &Session) -> Vec<CrateType> {
358386
// This includes bin despite failing on the link step to ensure that you
359387
// can still get the frontend handling for binaries. For all library

0 commit comments

Comments
 (0)