Skip to content

Commit c2c6896

Browse files
authored
Rollup merge of #84099 - tmiasko:asm-only-x86_64, r=Amanieu
Check for asm support in UI tests that require it Add `needs-asm-support` compiletest directive, and use it in asm tests that require asm support without relying on any architecture specific features. Closes #84038.
2 parents d2529c8 + 5e87f97 commit c2c6896

File tree

9 files changed

+33
-6
lines changed

9 files changed

+33
-6
lines changed

src/test/ui/asm/bad-options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// only-x86_64
1+
// needs-asm-support
22

33
#![feature(asm)]
44

src/test/ui/asm/naked-invalid-attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Checks that #[naked] attribute can be placed on function definitions only.
22
//
3-
// ignore-wasm32 asm unsupported
3+
// needs-asm-support
44
#![feature(asm)]
55
#![feature(naked_functions)]
66
#![naked] //~ ERROR should be applied to a function definition

src/test/ui/feature-gates/feature-gate-naked_functions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-asm-support
12
#![feature(asm)]
23

34
#[naked]

src/test/ui/feature-gates/feature-gate-naked_functions.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the `#[naked]` attribute is an experimental feature
2-
--> $DIR/feature-gate-naked_functions.rs:3:1
2+
--> $DIR/feature-gate-naked_functions.rs:4:1
33
|
44
LL | #[naked]
55
| ^^^^^^^^
@@ -8,7 +8,7 @@ LL | #[naked]
88
= help: add `#![feature(naked_functions)]` to the crate attributes to enable
99

1010
error[E0658]: the `#[naked]` attribute is an experimental feature
11-
--> $DIR/feature-gate-naked_functions.rs:9:1
11+
--> $DIR/feature-gate-naked_functions.rs:10:1
1212
|
1313
LL | #[naked]
1414
| ^^^^^^^^

src/test/ui/rfc-2091-track-caller/error-with-naked.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-asm-support
12
#![feature(asm, naked_functions)]
23

34
#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]`

src/test/ui/rfc-2091-track-caller/error-with-naked.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
2-
--> $DIR/error-with-naked.rs:3:1
2+
--> $DIR/error-with-naked.rs:4:1
33
|
44
LL | #[track_caller]
55
| ^^^^^^^^^^^^^^^
66

77
error[E0736]: cannot use `#[track_caller]` with `#[naked]`
8-
--> $DIR/error-with-naked.rs:12:5
8+
--> $DIR/error-with-naked.rs:13:5
99
|
1010
LL | #[track_caller]
1111
| ^^^^^^^^^^^^^^^

src/tools/compiletest/src/header.rs

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl EarlyProps {
4444
let mut props = EarlyProps::default();
4545
let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
4646
let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some();
47+
let has_asm_support = util::has_asm_support(&config.target);
4748
let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target);
4849
let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target);
4950
let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target);
@@ -76,6 +77,10 @@ impl EarlyProps {
7677
props.ignore = true;
7778
}
7879

80+
if !has_asm_support && config.parse_name_directive(ln, "needs-asm-support") {
81+
props.ignore = true;
82+
}
83+
7984
if !rustc_has_profiler_support && config.parse_needs_profiler_support(ln) {
8085
props.ignore = true;
8186
}

src/tools/compiletest/src/header/tests.rs

+11
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ fn sanitizers() {
223223
assert!(parse_rs(&config, "// needs-sanitizer-thread").ignore);
224224
}
225225

226+
#[test]
227+
fn asm_support() {
228+
let mut config = config();
229+
230+
config.target = "avr-unknown-gnu-atmega328".to_owned();
231+
assert!(parse_rs(&config, "// needs-asm-support").ignore);
232+
233+
config.target = "i686-unknown-netbsd".to_owned();
234+
assert!(!parse_rs(&config, "// needs-asm-support").ignore);
235+
}
236+
226237
#[test]
227238
fn test_extract_version_range() {
228239
use super::{extract_llvm_version, extract_version_range};

src/tools/compiletest/src/util.rs

+9
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ const BIG_ENDIAN: &[&str] = &[
128128
"sparcv9",
129129
];
130130

131+
static ASM_SUPPORTED_ARCHS: &[&str] = &[
132+
"x86", "x86_64", "arm", "aarch64", "riscv32", "riscv64", "nvptx64", "hexagon", "mips",
133+
"mips64", "spirv", "wasm32",
134+
];
135+
136+
pub fn has_asm_support(triple: &str) -> bool {
137+
ASM_SUPPORTED_ARCHS.contains(&get_arch(triple))
138+
}
139+
131140
pub fn matches_os(triple: &str, name: &str) -> bool {
132141
// For the wasm32 bare target we ignore anything also ignored on emscripten
133142
// and then we also recognize `wasm32-bare` as the os for the target

0 commit comments

Comments
 (0)