Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee

mark some target features as 'forbidden' so they cannot be (un)set with -Ctarget-feature

The context for this is https://github.com/rust-lang/rust/issues/116344: some target features change the way floats are passed between functions. Changing those target features is unsound as code compiled for the same target may now use different ABIs.

So this introduces a new concept of "forbidden" target features (on top of the existing "stable " and "unstable" categories), and makes it a hard error to (un)set such a target feature. For now, the x86 and ARM feature `soft-float` is on that list. We'll have to make some effort to collect more relevant features, and similar features from other targets, but that can happen after the basic infrastructure for this landed. (These features are being collected in https://github.com/rust-lang/rust/issues/131799.)

I've made this a warning for now to give people some time to speak up if this would break something.

MCP: https://github.com/rust-lang/compiler-team/issues/780
This commit is contained in:
bors 2024-11-05 16:25:45 +00:00
commit e8c698bb3b
23 changed files with 372 additions and 158 deletions

View file

@ -2200,10 +2200,11 @@ rustc_queries! {
desc { "computing autoderef types for `{}`", goal.canonical.value.value }
}
query supported_target_features(_: CrateNum) -> &'tcx UnordMap<String, Option<Symbol>> {
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
arena_cache
eval_always
desc { "looking up supported target features" }
desc { "looking up Rust target features" }
}
query implied_target_features(feature: Symbol) -> &'tcx Vec<Symbol> {