rust/compiler/rustc_middle/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
..
dep_graph Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
hir turn hir::ItemKind::Fn into a named-field variant 2025-01-04 11:35:31 +01:00
hooks Move some code from Compiler::enter to GlobalCtxt::finish 2024-11-09 17:55:39 +00:00
infer remove non-borrowck member constraints 2024-12-20 10:04:01 +01:00
middle explicitly model that certain ABIs require/forbid certain target features 2024-12-31 12:41:20 +01:00
mir Rollup merge of #134949 - compiler-errors:froms, r=jieyouxu 2024-12-31 14:12:49 +11:00
query Auto merge of #134794 - RalfJung:abi-required-target-features, r=workingjubilee 2025-01-05 23:21:06 +00:00
thir Introduce default_field_values feature 2024-12-09 21:55:01 +00:00
traits Remove unused fields from RepeatElementCopy obligation 2025-01-02 14:46:36 -08:00
ty Auto merge of #135031 - RalfJung:intrinsics-without-body, r=oli-obk 2025-01-04 12:50:38 +00:00
util Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
arena.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
error.rs Move some code from Compiler::enter to GlobalCtxt::finish 2024-11-09 17:55:39 +00:00
lib.rs move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
lint.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
macros.rs Improve const traits diagnostics for new desugaring 2024-10-02 19:45:17 +08:00
metadata.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
tests.rs
thir.rs Introduce default_field_values feature 2024-12-09 21:55:01 +00:00
values.rs Rename ty_def_id so people will stop using it by accident 2024-12-13 16:36:38 +00:00