Skip to content

Commit

Permalink
Auto merge of #86272 - nagisa:nagisa/tidy-llvm-components, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

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
  • Loading branch information
bors committed Jun 24, 2021
2 parents 7c3872e + cfcb2b6 commit d4e7cb3
Show file tree
Hide file tree
Showing 39 changed files with 517 additions and 407 deletions.
3 changes: 2 additions & 1 deletion src/test/assembly/asm/mips-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// revisions: mips32 mips64
// assembly-output: emit-asm
//[mips32] compile-flags: --target mips-unknown-linux-gnu
//[mips32] needs-llvm-components: mips
//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
// needs-llvm-components: mips
//[mips64] needs-llvm-components: mips

#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
Expand Down
3 changes: 2 additions & 1 deletion src/test/assembly/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// revisions: powerpc powerpc64
// assembly-output: emit-asm
//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
//[powerpc] needs-llvm-components: powerpc
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
// needs-llvm-components: powerpc
//[powerpc64] needs-llvm-components: powerpc

#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
#![crate_type = "rlib"]
Expand Down
3 changes: 2 additions & 1 deletion src/test/assembly/asm/riscv-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// revisions: riscv64 riscv32
// assembly-output: emit-asm
//[riscv64] compile-flags: --target riscv64imac-unknown-none-elf
//[riscv64] needs-llvm-components: riscv
//[riscv32] compile-flags: --target riscv32imac-unknown-none-elf
//[riscv32] needs-llvm-components: riscv
// compile-flags: -C target-feature=+d
// needs-llvm-components: riscv
// min-system-llvm-version: 12.0

#![feature(no_core, lang_items, rustc_attrs)]
Expand Down
2 changes: 2 additions & 0 deletions src/test/assembly/asm/x86-modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// assembly-output: emit-asm
// compile-flags: -O
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
//[x86_64] needs-llvm-components: x86
//[i686] compile-flags: --target i686-unknown-linux-gnu
//[i686] needs-llvm-components: x86
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C target-feature=+avx512bw

Expand Down
2 changes: 2 additions & 0 deletions src/test/assembly/asm/x86-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// revisions: x86_64 i686
// assembly-output: emit-asm
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
//[x86_64] needs-llvm-components: x86
//[i686] compile-flags: --target i686-unknown-linux-gnu
//[i686] needs-llvm-components: x86
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
// compile-flags: -C target-feature=+avx512bw

Expand Down
4 changes: 3 additions & 1 deletion src/test/assembly/static-relocation-model.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// min-llvm-version: 12.0.0
// needs-llvm-components: aarch64 x86 powerpc
// revisions: x64 A64 ppc64le
// assembly-output: emit-asm
// [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static
// [x64] needs-llvm-components: x86
// [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static
// [A64] needs-llvm-components: aarch64
// [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static
// [ppc64le] needs-llvm-components: powerpc

#![feature(no_core, lang_items)]
#![no_core]
Expand Down
7 changes: 5 additions & 2 deletions src/test/codegen/abi-efiapi.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Checks if the correct annotation for the efiapi ABI is passed to llvm.

// revisions:x86_64 i686 aarch64 arm riscv
// needs-llvm-components: aarch64 arm riscv

//[x86_64] compile-flags: --target x86_64-unknown-uefi
//[x86_64] needs-llvm-components: aarch64 arm riscv
//[i686] compile-flags: --target i686-unknown-linux-musl
//[i686] needs-llvm-components: aarch64 arm riscv
//[aarch64] compile-flags: --target aarch64-unknown-none
//[aarch64] needs-llvm-components: aarch64 arm riscv
//[arm] compile-flags: --target armv7r-none-eabi
//[arm] needs-llvm-components: aarch64 arm riscv
//[riscv] compile-flags: --target riscv64gc-unknown-none-elf
//[riscv] needs-llvm-components: aarch64 arm riscv
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
Expand Down
3 changes: 2 additions & 1 deletion src/test/codegen/asm-sanitize-llvm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// FIXME(nagisa): remove the flags here once all targets support `asm!`.
// FIXME(nagisa): remove the flags below once all targets support `asm!`.
// compile-flags: --target x86_64-unknown-linux-gnu
// needs-llvm-components: x86

// Verify we sanitize the special tokens for the LLVM inline-assembly, ensuring people won't
// inadvertently rely on the LLVM-specific syntax and features.
Expand Down
3 changes: 2 additions & 1 deletion src/test/codegen/default-requires-uwtable.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// revisions: WINDOWS ANDROID
// needs-llvm-components: x86 arm
// compile-flags: -C panic=abort
// [WINDOWS] compile-flags: --target=x86_64-pc-windows-msvc
// [WINDOWS] needs-llvm-components: x86
// [ANDROID] compile-flags: --target=armv7-linux-androideabi
// [ANDROID] needs-llvm-components: arm

#![feature(no_core, lang_items)]
#![crate_type = "lib"]
Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/i686-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See issue #60235.

// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
// needs-llvm-components: x86
// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
#![feature(no_core, lang_items)]
#![no_core]
Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/i686-no-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See issue #60235.

// compile-flags: -O --target=i686-apple-darwin --crate-type=rlib
// needs-llvm-components: x86
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
#![feature(no_core, lang_items)]
#![no_core]
Expand Down
3 changes: 1 addition & 2 deletions src/test/codegen/sparc-struct-abi.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// Checks that we correctly codegen extern "C" functions returning structs.
// See issue #52638.

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

Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/x86_64-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See issue #60235.

// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
// needs-llvm-components: x86
// rustc-env:MACOSX_DEPLOYMENT_TARGET=10.9
#![feature(no_core, lang_items)]
#![no_core]
Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/x86_64-no-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See issue #60235.

// compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib
// needs-llvm-components: x86
// unset-rustc-env:MACOSX_DEPLOYMENT_TARGET
#![feature(no_core, lang_items)]
#![no_core]
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/asm/inline-syntax.arm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL | .intel_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:29:15
--> $DIR/inline-syntax.rs:31:15
|
LL | asm!(".intel_syntax noprefix", "nop");
| ^
Expand All @@ -25,7 +25,7 @@ LL | .intel_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:32:15
--> $DIR/inline-syntax.rs:34:15
|
LL | asm!(".intel_syntax aaa noprefix", "nop");
| ^
Expand All @@ -37,7 +37,7 @@ LL | .intel_syntax aaa noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:35:15
--> $DIR/inline-syntax.rs:37:15
|
LL | asm!(".att_syntax noprefix", "nop");
| ^
Expand All @@ -49,7 +49,7 @@ LL | .att_syntax noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:38:15
--> $DIR/inline-syntax.rs:40:15
|
LL | asm!(".att_syntax bbb noprefix", "nop");
| ^
Expand All @@ -61,7 +61,7 @@ LL | .att_syntax bbb noprefix
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:41:15
--> $DIR/inline-syntax.rs:43:15
|
LL | asm!(".intel_syntax noprefix; nop");
| ^
Expand All @@ -73,7 +73,7 @@ LL | .intel_syntax noprefix; nop
| ^

error: unknown directive
--> $DIR/inline-syntax.rs:47:13
--> $DIR/inline-syntax.rs:49:13
|
LL | .intel_syntax noprefix
| ^
Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/asm/inline-syntax.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// needs-llvm-components: arm
// revisions: x86_64 arm
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
//[x86_64] check-pass
//[x86_64] needs-llvm-components: x86
//[x86_64_allowed] compile-flags: --target x86_64-unknown-linux-gnu
//[x86_64_allowed] check-pass
//[x86_64_allowed] needs-llvm-components: x86
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
//[arm] build-fail
//[arm] needs-llvm-components: arm

#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/asm/inline-syntax.x86_64.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:55:14
--> $DIR/inline-syntax.rs:57:14
|
LL | global_asm!(".intel_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(bad_asm_style)]` on by default

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

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

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

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

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

warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:47:13
--> $DIR/inline-syntax.rs:49:13
|
LL | .intel_syntax noprefix
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// revisions: nll_target

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
// build-pass
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
// only-thumbv8m.main-none-eabi
#![feature(abi_c_cmse_nonsecure_call)]
#![no_std]
// needs-llvm-components: arm
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
#![no_core]
#[lang="sized"]
pub trait Sized { }
#[lang="copy"]
pub trait Copy { }

extern "rust-intrinsic" {
pub fn transmute<T, U>(e: T) -> U;
}

#[no_mangle]
pub fn test(a: u32, b: u32, c: u32, d: u32) -> u32 {
let non_secure_function = unsafe {
core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>(
transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>(
0x10000004,
)
};
Expand Down
18 changes: 14 additions & 4 deletions src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
// build-fail
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
// only-thumbv8m.main-none-eabi
#![feature(abi_c_cmse_nonsecure_call)]
#![no_std]
// needs-llvm-components: arm
// min-llvm-version: 11.0
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
#![no_core]
#[lang="sized"]
pub trait Sized { }
#[lang="copy"]
pub trait Copy { }

extern "rust-intrinsic" {
pub fn transmute<T, U>(e: T) -> U;
}

#[no_mangle]
pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 {
let non_secure_function = unsafe {
core::mem::transmute::<
transmute::<
usize,
extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32>
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
// only-thumbv8m.main-none-eabi
#![feature(abi_c_cmse_nonsecure_call)]
#![no_std]
// needs-llvm-components: arm
#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)]
#![no_core]
#[lang="sized"]
trait Sized { }

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

error: aborting due to previous error

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

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

Expand Down
Loading

0 comments on commit d4e7cb3

Please sign in to comment.