1
Fork 0

mark some target features as 'forbidden' so they cannot be (un)set

For now, this is just a warning, but should become a hard error in the future
This commit is contained in:
Ralf Jung 2024-09-02 11:45:59 +02:00
parent 2dece5bb62
commit ffad9aac27
23 changed files with 372 additions and 158 deletions

View file

@ -20,8 +20,8 @@ use rustc_span::symbol::Ident;
use rustc_span::{Span, sym};
use rustc_target::spec::{SanitizerSet, abi};
use crate::errors::{self, MissingFeatures, TargetFeatureDisableOrEnable};
use crate::target_features::{check_target_feature_trait_unsafe, from_target_feature};
use crate::errors;
use crate::target_features::{check_target_feature_trait_unsafe, from_target_feature_attr};
fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage {
use rustc_middle::mir::mono::Linkage::*;
@ -73,7 +73,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_BUILTINS;
}
let supported_target_features = tcx.supported_target_features(LOCAL_CRATE);
let rust_target_features = tcx.rust_target_features(LOCAL_CRATE);
let mut inline_span = None;
let mut link_ordinal_span = None;
@ -281,10 +281,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
check_target_feature_trait_unsafe(tcx, did, attr.span);
}
}
from_target_feature(
from_target_feature_attr(
tcx,
attr,
supported_target_features,
rust_target_features,
&mut codegen_fn_attrs.target_features,
);
}
@ -676,10 +676,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
.next()
.map_or_else(|| tcx.def_span(did), |a| a.span);
tcx.dcx()
.create_err(TargetFeatureDisableOrEnable {
.create_err(errors::TargetFeatureDisableOrEnable {
features,
span: Some(span),
missing_features: Some(MissingFeatures),
missing_features: Some(errors::MissingFeatures),
})
.emit();
}