diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 765512eb0b418..5aaab09f79c6c 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -1524,7 +1524,15 @@ impl Target { // There's no SPE for PowerPC64, and we currently don't support any soft-float // targets. (If we ever add one, we need to match on `RustcAbi::Softfloat` similar // to other targets above.) - FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] } + match self.llvm_abiname { + // The ELFv2 ABI requires vector registers for passing f128 and any future + // 16-byte aligned types. + LlvmAbi::ElfV2 => FeatureConstraints { + required: &["hard-float", "altivec"], + incompatible: &["spe"], + }, + _ => FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }, + } } Arch::Sparc => { // We currently don't have a soft-float target for SPARC. diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64.stderr new file mode 100644 index 0000000000000..acf87e599739b --- /dev/null +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64.stderr @@ -0,0 +1,7 @@ +warning: target feature `altivec` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #162235 + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64le.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64le.stderr new file mode 100644 index 0000000000000..acf87e599739b --- /dev/null +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.powerpc64le.stderr @@ -0,0 +1,7 @@ +warning: target feature `altivec` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #162235 + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs index b6c0481e41553..c632ac04ba4ae 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs @@ -1,13 +1,19 @@ //! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`. //! Also covers the case of a feature indirectly disabling another via feature implications. //@ compile-flags: --crate-type=lib -//@ revisions: x86 x86-implied aarch64 riscv loongarch +//@ revisions: x86 x86-implied aarch64 powerpc64 powerpc64le riscv loongarch //@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-x87 //@[x86] needs-llvm-components: x86 //@[x86] build-pass //@[x86-implied] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-sse //@[x86-implied] needs-llvm-components: x86 //@[x86-implied] build-pass +//@[powerpc64] compile-flags: --target=powerpc64-unknown-linux-musl -Ctarget-feature=-altivec +//@[powerpc64] needs-llvm-components: powerpc +//@[powerpc64] build-pass +//@[powerpc64le] compile-flags: --target=powerpc64le-unknown-linux-gnu -Ctarget-feature=-altivec +//@[powerpc64le] needs-llvm-components: powerpc +//@[powerpc64le] build-pass //@[riscv] compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=-d //@[riscv] needs-llvm-components: riscv //@[riscv] build-pass @@ -31,5 +37,5 @@ extern crate minicore; use minicore::*; -//[x86,x86-implied,riscv,loongarch]~? WARN must be enabled to ensure that the ABI +//[x86,x86-implied,powerpc64,powerpc64le,riscv,loongarch]~? WARN must be enabled to ensure that the ABI //[aarch64]~? ERROR must be enabled to ensure that the ABI