Skip to content

Commit d4e7cb3

Browse files
committed
Auto merge of #86272 - nagisa:nagisa/tidy-llvm-components, r=Mark-Simulacrum
tidy: verify that test revisions with --target have associated needs-llvm-components directives This ensures that people who tend to write `--target` `#[no_core]` tests don't miss specifying the `needs-llvm-components` directive. This is necessary for the test suite to pass when LLVM is compiled with a subset of components enabled. While here I also took the opportunity to implement a more fine-grained handling of the ignore directives, so that they are evaluated for each revision, rather than for the entire test. With this even if people have `arm` component disabled, only the revision that depends on the arm component will not run. Fixes #82405
2 parents 7c3872e + cfcb2b6 commit d4e7cb3

39 files changed

+517
-407
lines changed

src/test/assembly/asm/mips-types.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// revisions: mips32 mips64
33
// assembly-output: emit-asm
44
//[mips32] compile-flags: --target mips-unknown-linux-gnu
5+
//[mips32] needs-llvm-components: mips
56
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
6-
// needs-llvm-components: mips
7+
//[mips64] needs-llvm-components: mips
78

89
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
910
#![crate_type = "rlib"]

src/test/assembly/asm/powerpc-types.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// revisions: powerpc powerpc64
33
// assembly-output: emit-asm
44
//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
5+
//[powerpc] needs-llvm-components: powerpc
56
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
6-
// needs-llvm-components: powerpc
7+
//[powerpc64] needs-llvm-components: powerpc
78

89
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
910
#![crate_type = "rlib"]

src/test/assembly/asm/riscv-types.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// revisions: riscv64 riscv32
33
// assembly-output: emit-asm
44
//[riscv64] compile-flags: --target riscv64imac-unknown-none-elf
5+
//[riscv64] needs-llvm-components: riscv
56
//[riscv32] compile-flags: --target riscv32imac-unknown-none-elf
7+
//[riscv32] needs-llvm-components: riscv
68
// compile-flags: -C target-feature=+d
7-
// needs-llvm-components: riscv
89
// min-system-llvm-version: 12.0
910

1011
#![feature(no_core, lang_items, rustc_attrs)]

src/test/assembly/asm/x86-modifiers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// assembly-output: emit-asm
44
// compile-flags: -O
55
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
6+
//[x86_64] needs-llvm-components: x86
67
//[i686] compile-flags: --target i686-unknown-linux-gnu
8+
//[i686] needs-llvm-components: x86
79
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
810
// compile-flags: -C target-feature=+avx512bw
911

src/test/assembly/asm/x86-types.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// revisions: x86_64 i686
33
// assembly-output: emit-asm
44
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
5+
//[x86_64] needs-llvm-components: x86
56
//[i686] compile-flags: --target i686-unknown-linux-gnu
7+
//[i686] needs-llvm-components: x86
68
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
79
// compile-flags: -C target-feature=+avx512bw
810

src/test/assembly/static-relocation-model.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// min-llvm-version: 12.0.0
2-
// needs-llvm-components: aarch64 x86 powerpc
32
// revisions: x64 A64 ppc64le
43
// assembly-output: emit-asm
54
// [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static
5+
// [x64] needs-llvm-components: x86
66
// [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static
7+
// [A64] needs-llvm-components: aarch64
78
// [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static
9+
// [ppc64le] needs-llvm-components: powerpc
810

911
#![feature(no_core, lang_items)]
1012
#![no_core]

src/test/codegen/abi-efiapi.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Checks if the correct annotation for the efiapi ABI is passed to llvm.
22

33
// revisions:x86_64 i686 aarch64 arm riscv
4-
// needs-llvm-components: aarch64 arm riscv
5-
64
//[x86_64] compile-flags: --target x86_64-unknown-uefi
5+
//[x86_64] needs-llvm-components: aarch64 arm riscv
76
//[i686] compile-flags: --target i686-unknown-linux-musl
7+
//[i686] needs-llvm-components: aarch64 arm riscv
88
//[aarch64] compile-flags: --target aarch64-unknown-none
9+
//[aarch64] needs-llvm-components: aarch64 arm riscv
910
//[arm] compile-flags: --target armv7r-none-eabi
11+
//[arm] needs-llvm-components: aarch64 arm riscv
1012
//[riscv] compile-flags: --target riscv64gc-unknown-none-elf
13+
//[riscv] needs-llvm-components: aarch64 arm riscv
1114
// compile-flags: -C no-prepopulate-passes
1215

1316
#![crate_type = "lib"]

src/test/codegen/asm-sanitize-llvm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// FIXME(nagisa): remove the flags here once all targets support `asm!`.
1+
// FIXME(nagisa): remove the flags below once all targets support `asm!`.
22
// compile-flags: --target x86_64-unknown-linux-gnu
3+
// needs-llvm-components: x86
34

45
// Verify we sanitize the special tokens for the LLVM inline-assembly, ensuring people won't
56
// inadvertently rely on the LLVM-specific syntax and features.

src/test/codegen/default-requires-uwtable.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// revisions: WINDOWS ANDROID
2-
// needs-llvm-components: x86 arm
32
// compile-flags: -C panic=abort
43
// [WINDOWS] compile-flags: --target=x86_64-pc-windows-msvc
4+
// [WINDOWS] needs-llvm-components: x86
55
// [ANDROID] compile-flags: --target=armv7-linux-androideabi
6+
// [ANDROID] needs-llvm-components: arm
67

78
#![feature(no_core, lang_items)]
89
#![crate_type = "lib"]

src/test/codegen/i686-macosx-deployment-target.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See issue #60235.
44

55
// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
6+
// needs-llvm-components: x86
67
// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
78
#![feature(no_core, lang_items)]
89
#![no_core]

src/test/codegen/i686-no-macosx-deployment-target.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See issue #60235.
44

55
// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
6+
// needs-llvm-components: x86
67
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
78
#![feature(no_core, lang_items)]
89
#![no_core]

src/test/codegen/sparc-struct-abi.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
//
21
// Checks that we correctly codegen extern "C" functions returning structs.
32
// See issue #52638.
43

5-
// only-sparc64
64
// compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib
5+
// needs-llvm-components: sparc
76
#![feature(no_core, lang_items)]
87
#![no_core]
98

src/test/codegen/x86_64-macosx-deployment-target.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See issue #60235.
44

55
// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
6+
// needs-llvm-components: x86
67
// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
78
#![feature(no_core, lang_items)]
89
#![no_core]

src/test/codegen/x86_64-no-macosx-deployment-target.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See issue #60235.
44

55
// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
6+
// needs-llvm-components: x86
67
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
78
#![feature(no_core, lang_items)]
89
#![no_core]

src/test/ui/asm/inline-syntax.arm.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | .intel_syntax noprefix
1313
| ^
1414

1515
error: unknown directive
16-
--> $DIR/inline-syntax.rs:29:15
16+
--> $DIR/inline-syntax.rs:31:15
1717
|
1818
LL | asm!(".intel_syntax noprefix", "nop");
1919
| ^
@@ -25,7 +25,7 @@ LL | .intel_syntax noprefix
2525
| ^
2626

2727
error: unknown directive
28-
--> $DIR/inline-syntax.rs:32:15
28+
--> $DIR/inline-syntax.rs:34:15
2929
|
3030
LL | asm!(".intel_syntax aaa noprefix", "nop");
3131
| ^
@@ -37,7 +37,7 @@ LL | .intel_syntax aaa noprefix
3737
| ^
3838

3939
error: unknown directive
40-
--> $DIR/inline-syntax.rs:35:15
40+
--> $DIR/inline-syntax.rs:37:15
4141
|
4242
LL | asm!(".att_syntax noprefix", "nop");
4343
| ^
@@ -49,7 +49,7 @@ LL | .att_syntax noprefix
4949
| ^
5050

5151
error: unknown directive
52-
--> $DIR/inline-syntax.rs:38:15
52+
--> $DIR/inline-syntax.rs:40:15
5353
|
5454
LL | asm!(".att_syntax bbb noprefix", "nop");
5555
| ^
@@ -61,7 +61,7 @@ LL | .att_syntax bbb noprefix
6161
| ^
6262

6363
error: unknown directive
64-
--> $DIR/inline-syntax.rs:41:15
64+
--> $DIR/inline-syntax.rs:43:15
6565
|
6666
LL | asm!(".intel_syntax noprefix; nop");
6767
| ^
@@ -73,7 +73,7 @@ LL | .intel_syntax noprefix; nop
7373
| ^
7474

7575
error: unknown directive
76-
--> $DIR/inline-syntax.rs:47:13
76+
--> $DIR/inline-syntax.rs:49:13
7777
|
7878
LL | .intel_syntax noprefix
7979
| ^

src/test/ui/asm/inline-syntax.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
// needs-llvm-components: arm
21
// revisions: x86_64 arm
32
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
43
//[x86_64] check-pass
4+
//[x86_64] needs-llvm-components: x86
55
//[x86_64_allowed] compile-flags: --target x86_64-unknown-linux-gnu
66
//[x86_64_allowed] check-pass
7+
//[x86_64_allowed] needs-llvm-components: x86
78
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
89
//[arm] build-fail
10+
//[arm] needs-llvm-components: arm
911

1012
#![feature(no_core, lang_items, rustc_attrs)]
1113
#![crate_type = "rlib"]

src/test/ui/asm/inline-syntax.x86_64.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
warning: avoid using `.intel_syntax`, Intel syntax is the default
2-
--> $DIR/inline-syntax.rs:55:14
2+
--> $DIR/inline-syntax.rs:57:14
33
|
44
LL | global_asm!(".intel_syntax noprefix", "nop");
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(bad_asm_style)]` on by default
88

99
warning: avoid using `.intel_syntax`, Intel syntax is the default
10-
--> $DIR/inline-syntax.rs:29:15
10+
--> $DIR/inline-syntax.rs:31:15
1111
|
1212
LL | asm!(".intel_syntax noprefix", "nop");
1313
| ^^^^^^^^^^^^^^^^^^^^^^
1414

1515
warning: avoid using `.intel_syntax`, Intel syntax is the default
16-
--> $DIR/inline-syntax.rs:32:15
16+
--> $DIR/inline-syntax.rs:34:15
1717
|
1818
LL | asm!(".intel_syntax aaa noprefix", "nop");
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
22-
--> $DIR/inline-syntax.rs:35:15
22+
--> $DIR/inline-syntax.rs:37:15
2323
|
2424
LL | asm!(".att_syntax noprefix", "nop");
2525
| ^^^^^^^^^^^^^^^^^^^^
2626

2727
warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
28-
--> $DIR/inline-syntax.rs:38:15
28+
--> $DIR/inline-syntax.rs:40:15
2929
|
3030
LL | asm!(".att_syntax bbb noprefix", "nop");
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^
3232

3333
warning: avoid using `.intel_syntax`, Intel syntax is the default
34-
--> $DIR/inline-syntax.rs:41:15
34+
--> $DIR/inline-syntax.rs:43:15
3535
|
3636
LL | asm!(".intel_syntax noprefix; nop");
3737
| ^^^^^^^^^^^^^^^^^^^^^^
3838

3939
warning: avoid using `.intel_syntax`, Intel syntax is the default
40-
--> $DIR/inline-syntax.rs:47:13
40+
--> $DIR/inline-syntax.rs:49:13
4141
|
4242
LL | .intel_syntax noprefix
4343
| ^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// revisions: nll_target
22

3-
// The following revisions are disabled due to missing support from two-phase beyond autorefs
3+
// The nll_beyond revision is disabled due to missing support from two-phase beyond autorefs
44
//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref
5-
//[nll_beyond] should-fail
5+
//[nll_beyond]should-fail
66

77
//[nll_target]compile-flags: -Z borrowck=mir
88

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
// build-pass
22
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3-
// only-thumbv8m.main-none-eabi
4-
#![feature(abi_c_cmse_nonsecure_call)]
5-
#![no_std]
3+
// needs-llvm-components: arm
4+
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
5+
#![no_core]
6+
#[lang="sized"]
7+
pub trait Sized { }
8+
#[lang="copy"]
9+
pub trait Copy { }
10+
11+
extern "rust-intrinsic" {
12+
pub fn transmute<T, U>(e: T) -> U;
13+
}
614

715
#[no_mangle]
816
pub fn test(a: u32, b: u32, c: u32, d: u32) -> u32 {
917
let non_secure_function = unsafe {
10-
core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>(
18+
transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>(
1119
0x10000004,
1220
)
1321
};

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
// build-fail
12
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
2-
// only-thumbv8m.main-none-eabi
3-
#![feature(abi_c_cmse_nonsecure_call)]
4-
#![no_std]
3+
// needs-llvm-components: arm
4+
// min-llvm-version: 11.0
5+
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
6+
#![no_core]
7+
#[lang="sized"]
8+
pub trait Sized { }
9+
#[lang="copy"]
10+
pub trait Copy { }
11+
12+
extern "rust-intrinsic" {
13+
pub fn transmute<T, U>(e: T) -> U;
14+
}
515

616
#[no_mangle]
717
pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 {
818
let non_secure_function = unsafe {
9-
core::mem::transmute::<
19+
transmute::<
1020
usize,
1121
extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32>
1222
(
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
2-
// only-thumbv8m.main-none-eabi
3-
#![feature(abi_c_cmse_nonsecure_call)]
4-
#![no_std]
2+
// needs-llvm-components: arm
3+
#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)]
4+
#![no_core]
5+
#[lang="sized"]
6+
trait Sized { }
57

68
pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781]

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers.
2-
--> $DIR/wrong-abi-location-1.rs:6:1
1+
error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers.
2+
--> $DIR/wrong-abi-location-1.rs:8:1
33
|
4-
LL | pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | pub extern "C-cmse-nonsecure-call" fn test() {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
2-
// only-thumbv8m.main-none-eabi
3-
#![feature(abi_c_cmse_nonsecure_call)]
4-
#![no_std]
2+
// needs-llvm-components: arm
3+
#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)]
4+
#![no_core]
5+
#[lang="sized"]
6+
trait Sized { }
57

68
extern "C-cmse-nonsecure-call" { //~ ERROR [E0781]
79
fn test();

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers.
2-
--> $DIR/wrong-abi-location-2.rs:6:1
2+
--> $DIR/wrong-abi-location-2.rs:8:1
33
|
44
LL | / extern "C-cmse-nonsecure-call" {
5-
LL | | fn test(); //~ ERROR [E0781]
5+
LL | | fn test();
66
LL | | }
77
| |_^
88

0 commit comments

Comments
 (0)