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 https://github.com/rust-lang/miri/pull/4648
This commit is contained in:
@@ -9,8 +9,9 @@ use rustc_ast as ast;
|
||||
use rustc_attr_parsing::{ShouldEmit, validate_attr};
|
||||
use rustc_codegen_ssa::back::archive::ArArchiveBuilderBuilder;
|
||||
use rustc_codegen_ssa::back::link::link_binary;
|
||||
use rustc_codegen_ssa::target_features::{self, cfg_target_feature};
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
|
||||
use rustc_codegen_ssa::{CodegenResults, CrateInfo, TargetConfig};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::jobserver::Proxy;
|
||||
use rustc_data_structures::sync;
|
||||
@@ -354,6 +355,33 @@ impl CodegenBackend for DummyCodegenBackend {
|
||||
"dummy"
|
||||
}
|
||||
|
||||
fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
let (target_features, unstable_target_features) = cfg_target_feature(sess, |feature| {
|
||||
// This is a standin for the list of features a backend is expected to enable.
|
||||
// It would be better to parse target.features instead and handle implied features,
|
||||
// but target.features is a list of LLVM target features, not Rust target features.
|
||||
// The dummy backend doesn't know the mapping between LLVM and Rust target features.
|
||||
sess.target.abi_required_features().required.contains(&feature)
|
||||
});
|
||||
|
||||
// To report warnings about unknown features
|
||||
target_features::flag_to_backend_features::<0>(
|
||||
sess,
|
||||
true,
|
||||
|_| Default::default(),
|
||||
|_, _| {},
|
||||
);
|
||||
|
||||
TargetConfig {
|
||||
target_features,
|
||||
unstable_target_features,
|
||||
has_reliable_f16: true,
|
||||
has_reliable_f16_math: true,
|
||||
has_reliable_f128: true,
|
||||
has_reliable_f128_math: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn supported_crate_types(&self, _sess: &Session) -> Vec<CrateType> {
|
||||
// This includes bin despite failing on the link step to ensure that you
|
||||
// can still get the frontend handling for binaries. For all library
|
||||
|
||||
Reference in New Issue
Block a user