1
Fork 0
rust/compiler/rustc_codegen_gcc/src
bors feb32c6546 Auto merge of #134794 - RalfJung:abi-required-target-features, r=workingjubilee
Add a notion of "some ABIs require certain target features"

I think I finally found the right shape for the data and checks that I recently added in https://github.com/rust-lang/rust/pull/133099, https://github.com/rust-lang/rust/pull/133417, https://github.com/rust-lang/rust/pull/134337: we have a notion of "this ABI requires the following list of target features, and it is incompatible with the following list of target features". Both `-Ctarget-feature` and `#[target_feature]` are updated to ensure we follow the rules of the ABI.  This removes all the "toggleability" stuff introduced before, though we do keep the notion of a fully "forbidden" target feature -- this is needed to deal with target features that are actual ABI switches, and hence are needed to even compute the list of required target features.

We always explicitly (un)set all required and in-conflict features, just to avoid potential trouble caused by the default features of whatever the base CPU is. We do this *before* applying `-Ctarget-feature` to maintain backward compatibility; this poses a slight risk of missing some implicit feature dependencies in LLVM but has the advantage of not breaking users that deliberately toggle ABI-relevant target features. They get a warning but the feature does get toggled the way they requested.

For now, our logic supports x86, ARM, and RISC-V (just like the previous logic did). Unsurprisingly, RISC-V is the nicest. ;)

As a side-effect this also (unstably) allows *enabling* `x87` when that is harmless. I used the opportunity to mark SSE2 as required on x86-64, to better match the actual logic in LLVM and because all x86-64 chips do have SSE2. This infrastructure also prepares us for requiring SSE on x86-32 when we want to use that for our ABI (and for float semantics sanity), see https://github.com/rust-lang/rust/issues/133611, but no such change is happening in this PR.

r? `@workingjubilee`
2025-01-05 23:21:06 +00:00
..
back Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
intrinsic chore: fix some typos 2024-12-18 23:23:44 +08:00
abi.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
allocator.rs Replace -Z default-hidden-visibility with -Z default-visibility 2024-10-01 22:32:13 +10:00
asm.rs codegen #[naked] functions using global_asm! 2024-12-10 21:41:03 +01:00
attributes.rs rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
base.rs Merge commit '3187d32079' into subtree-update 2024-09-27 22:00:17 +02:00
builder.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
callee.rs Effects cleanup 2024-10-26 10:19:07 +08:00
common.rs cg_gcc: Factor out rustc_target::abi 2024-10-08 18:24:56 -07:00
consts.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
context.rs rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973) 2024-12-02 01:14:40 +07:00
coverageinfo.rs Unbox and unwrap the contents of StatementKind::Coverage 2024-03-23 22:05:11 +11:00
debuginfo.rs When the required discriminator value exceeds LLVM's limits, drop the debug info for the function instead of panicking. 2024-11-19 05:19:09 -08:00
declare.rs Merge commit '3187d32079' into subtree-update 2024-09-27 22:00:17 +02:00
errors.rs adjust GCC backend 2024-12-31 12:41:20 +01:00
gcc_util.rs add dedicated type for ABI target feature constraints 2025-01-05 10:46:30 +01:00
int.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
lib.rs upstream rustc_codegen_llvm changes for enzyme/autodiff 2025-01-01 21:42:45 +01:00
mono_item.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
type_.rs Rename supertraits of CodegenMethods. 2024-09-17 10:24:43 +10:00
type_of.rs cg_gcc: rustc_abi::Abi => BackendRepr 2024-10-29 15:01:01 -07:00