rust/tests
Trevor Gross c117ebefd2
Rollup merge of #140920 - RalfJung:target-feature-unification, r=nnethercote,WaffleLapkin
Extract some shared code from codegen backend target feature handling

There's a bunch of code duplication between the GCC and LLVM backends in target feature handling. This moves that into new shared helper functions in `rustc_codegen_ssa`.

The first two commits should be purely refactoring. I am fairly sure the LLVM-side behavior stays the same; if the GCC side deliberately diverges from this then I may have missed that. I did account for one divergence, which I do not know is deliberate or not: GCC does not seem to use the `-Ctarget-feature` flag to populate `cfg(target_feature)`. That seems odd, since the `-Ctarget-feature` flag is used to populate the return value of `global_gcc_features` which controls the target features actually used by GCC. ``@GuillaumeGomez`` ``@antoyo`` is there a reason `target_config` ignores `-Ctarget-feature` but `global_gcc_features`  does not? The second commit also cleans up a bunch of unneeded complexity added in https://github.com/rust-lang/rust/pull/135927.

The third commit extracts some shared logic out of the functions that populate `cfg(target_feature)` and the backend target feature set, respectively. This one actually has some slight functional changes:
- Before, with `-Ctarget-feature=-feat`, if there is some other feature `x` that implies `feat` we would *not* add `-x` to the backend target feature set. Now, we do. This fixes rust-lang/rust#134792.
- The logic that removes `x` from `cfg(target_feature)` in this case also changed a bit, avoiding a large number of calls to the (uncached) `sess.target.implied_target_features` (if there were a large number of positive features listed before a negative feature) but instead constructing a full inverse implication map when encountering the first negative feature. Ideally this would be done with queries but the backend target feature logic runs before `tcx` so we can't use that...
- Previously, if feature "a" implied "b" and "b" was unstable, then using `-Ctarget-feature=+a` would also emit a warning about `b`. I had to remove this since when accounting for negative implications, this emits a ton of warnings in a bunch of existing tests... I assume this was unintentional anyway.

The fourth commit increases consistency of the GCC backend with the LLVM backend.

The last commit does some further cleanup:
- Get rid of RUSTC_SPECIAL_FEATURES. It was only needed for s390x "backchain", but since LLVM 19 that is always a regular target feature so we don't need this hack any more. The hack also has various unintended side-effects so we don't want to keep it. Fixes https://github.com/rust-lang/rust/issues/142412.
- Move RUSTC_SPECIFIC_FEATURES handling into the shared parse_rust_feature_flag helper so all consumers of `-Ctarget-feature` that only care about actual target features (and not "crt-static") have it. Previously, we actually set `cfg(target_feature = "crt-static")` twice: once in the backend target feature logic, and once specifically for that one feature. IIUC, some targets are meant to ignore `-Ctarget-feature=+crt-static`, it seems like before this PR that flag still incorrectly enabled `cfg(target_feature = "crt-static")` (but I didn't test this).
- Move fixed_x18 handling together with retpoline handling.
- Forbid setting fixed_x18 as a regular target feature, even unstably. It must be set via the `-Z` flag.

``@bjorn3`` I did not touch the cranelift backend here, since AFAIK it doesn't really support target features. But if you ever do, please use the new helpers. :)

Cc ``@workingjubilee``
2025-06-20 02:50:38 -04:00
..
assembly Rollup merge of #140920 - RalfJung:target-feature-unification, r=nnethercote,WaffleLapkin 2025-06-20 02:50:38 -04:00
auxiliary aux: add {Meta,Pointee}Sized bounds to minicore 2025-06-16 23:04:33 +00:00
codegen Rollup merge of #140920 - RalfJung:target-feature-unification, r=nnethercote,WaffleLapkin 2025-06-20 02:50:38 -04:00
codegen-units tests: {Meta,Pointee}Sized in non-minicore tests 2025-06-16 23:04:33 +00:00
coverage coverage: Revert "unused local file IDs" due to empty function names 2025-05-27 23:33:29 +10:00
coverage-run-rustdoc
crashes Rollup merge of #140247 - BoxyUwU:iats_no_query_cycles, r=lcnr 2025-06-18 20:22:48 -04:00
debuginfo tests: {Meta,Pointee}Sized in non-minicore tests 2025-06-16 23:04:33 +00:00
incremental tests: bless remaining tests 2025-06-16 23:04:35 +00:00
mir-opt Update mir-opt tests. 2025-06-18 10:20:20 +02:00
pretty Rollup merge of #134847 - dtolnay:asymmetrical, r=fmease 2025-06-13 05:16:54 +02:00
run-make Auto merge of #139244 - jieyouxu:exp/auto-cross-run-make, r=Kobzol 2025-06-19 06:27:02 +00:00
rustdoc rustdoc: PointeeSized bounds with extern types 2025-06-16 23:04:36 +00:00
rustdoc-gui rustdoc: make srcIndex no longer a global variable 2025-06-16 20:22:24 -05:00
rustdoc-js yeet CanonicalVarInfo 2025-05-23 12:10:53 +00:00
rustdoc-js-std Consistent trait bounds for ExtractIf Debug impls 2025-05-05 19:46:46 -07:00
rustdoc-json fix clippy 2025-06-17 23:22:51 +02:00
rustdoc-ui rustdoc: {Meta,Pointee,}Sized in non-minicore 2025-06-16 23:04:36 +00:00
ui Rollup merge of #140920 - RalfJung:target-feature-unification, r=nnethercote,WaffleLapkin 2025-06-20 02:50:38 -04:00
ui-fulldeps Rollup merge of #142377 - Urgau:unremap-rustc-dev, r=jieyouxu 2025-06-18 19:40:32 +02:00
COMPILER_TESTS.md