Skip to content

Commit 6beec96

Browse files
authored
Unrolled build for rust-lang#140395
Rollup merge of rust-lang#140395 - RalfJung:target-feature-tests, r=petrochenkov organize and extend forbidden target feature tests In particular this adds some loongarch tests for rust-lang#135015, Cc `@heiher` Seems like the tests change so much git does not detect the renames; a commit-by-commit review should help. try-job: `x86_64-gnu-llvm-20-*`
2 parents d7df5bd + 6873a46 commit 6beec96

19 files changed

+128
-58
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
2+
--> $DIR/abi-incompatible-target-feature-attribute.rs:15:90
3+
|
4+
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
5+
| ^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`.
2+
// ignore-tidy-linelength
3+
//@ compile-flags: --crate-type=lib
4+
//@ revisions: x86 riscv
5+
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu
6+
//@[x86] needs-llvm-components: x86
7+
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf
8+
//@[riscv] needs-llvm-components: riscv
9+
#![feature(no_core, lang_items, riscv_target_feature, x87_target_feature)]
10+
#![no_core]
11+
12+
#[lang = "sized"]
13+
pub trait Sized {}
14+
15+
#[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
16+
//~^ERROR: cannot be enabled with
17+
pub unsafe fn my_fun() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
2+
--> $DIR/abi-incompatible-target-feature-attribute.rs:15:32
3+
|
4+
LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: target feature `d` must be disabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
warning: unstable feature specified for `-Ctarget-feature`: `f`
11+
|
12+
= note: this feature is not stably supported; its behavior can change in the future
13+
14+
warning: unstable feature specified for `-Ctarget-feature`: `zicsr`
15+
|
16+
= note: this feature is not stably supported; its behavior can change in the future
17+
18+
warning: 4 warnings emitted
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`.
2+
// These are just warnings for now.
3+
//@ check-pass
4+
//@ compile-flags: --crate-type=lib
5+
//@ revisions: x86 riscv
6+
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=+soft-float
7+
//@[x86] needs-llvm-components: x86
8+
//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf -Ctarget-feature=+d
9+
//@[riscv] needs-llvm-components: riscv
10+
11+
#![feature(no_core, lang_items, riscv_target_feature)]
12+
#![no_core]
13+
14+
#[lang = "sized"]
15+
pub trait Sized {}
16+
#[lang = "freeze"]
17+
pub trait Freeze {}
18+
19+
//~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly
20+
//~? WARN unstable feature specified for `-Ctarget-feature`
21+
//[riscv]~? WARN unstable feature specified for `-Ctarget-feature`
22+
//[riscv]~? WARN unstable feature specified for `-Ctarget-feature`

tests/ui/target-feature/allowed-softfloat-target-feature-flag-disable.rs renamed to tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! `x87` is a required target feature on some x86 targets, but not on this one as this one
2+
//! uses soft-floats. So ensure disabling the target feature here (which is a NOP) does
3+
//! not trigger a warning.
14
//@ compile-flags: --target=x86_64-unknown-none --crate-type=lib
25
//@ needs-llvm-components: x86
36
//@ compile-flags: -Ctarget-feature=-x87

tests/ui/target-feature/allowed-softfloat-target-feature-attribute.rs renamed to tests/ui/target-feature/abi-required-target-feature-attribute.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Enabling a target feature that is anyway required changes nothing, so this is allowed
2+
//! for `#[target_feature]`.
13
//@ compile-flags: --target=x86_64-unknown-none --crate-type=lib
24
//@ needs-llvm-components: x86
35
//@ build-pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
warning: 2 warnings emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly
2+
|
3+
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4+
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
5+
6+
warning: unstable feature specified for `-Ctarget-feature`: `d`
7+
|
8+
= note: this feature is not stably supported; its behavior can change in the future
9+
10+
warning: 2 warnings emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`.
2+
//! Also covers the case of a feature indirectly disabling another via feature implications.
3+
//@ compile-flags: --crate-type=lib
4+
//@ revisions: x86 x86-implied aarch64 riscv loongarch
5+
//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-x87
6+
//@[x86] needs-llvm-components: x86
7+
//@[x86-implied] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-sse
8+
//@[x86-implied] needs-llvm-components: x86
9+
//@[aarch64] compile-flags: --target=aarch64-unknown-linux-gnu -Ctarget-feature=-neon
10+
//@[aarch64] needs-llvm-components: aarch64
11+
//@[riscv] compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=-d
12+
//@[riscv] needs-llvm-components: riscv
13+
//@[loongarch] compile-flags: --target=loongarch64-unknown-none -Ctarget-feature=-d
14+
//@[loongarch] needs-llvm-components: loongarch
15+
// For now this is just a warning.
16+
//@ build-pass
17+
// Remove some LLVM warnings that only show up sometimes.
18+
//@ normalize-stderr: "\n[^\n]*(target-abi|lp64f)[^\n]*" -> ""
19+
20+
#![feature(no_core, lang_items)]
21+
#![no_core]
22+
23+
#[lang = "sized"]
24+
pub trait Sized {}
25+
26+
//~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly
27+
//[x86,riscv,loongarch]~? WARN unstable feature specified for `-Ctarget-feature`

tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs

-15
This file was deleted.

tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs

-13
This file was deleted.

tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs

-15
This file was deleted.

tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs

-15
This file was deleted.

0 commit comments

Comments
 (0)