Skip to content

Commit 1b0972c

Browse files
Rollup merge of rust-lang#124597 - cuviper:x86-64-v3, r=workingjubilee
Use an explicit x86-64 cpu in tests that are sensitive to it There are a few tests that depend on some target features **not** being enabled by default, and usually they are correct with the default x86-64 target CPU. However, in downstream builds we have modified the default to fit our distros -- `x86-64-v2` in RHEL 9 and `x86-64-v3` in RHEL 10 -- and the latter especially trips tests that expect not to have AVX. These cases are few enough that we can just set them back explicitly.
2 parents 871f047 + 393d933 commit 1b0972c

10 files changed

+34
-25
lines changed

tests/assembly/simd-intrinsic-mask-reduce.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// verify that simd mask reductions do not introduce additional bit shift operations
22
//@ revisions: x86 aarch64
33
//@ [x86] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel
4+
// Set the base cpu explicitly, in case the default has been changed.
5+
//@ [x86] compile-flags: -C target-cpu=x86-64
46
//@ [x86] needs-llvm-components: x86
57
//@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
68
//@ [aarch64] needs-llvm-components: aarch64

tests/assembly/x86_64-floating-point-clamp.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// so check to make sure that's what it's actually emitting.
33

44
//@ assembly-output: emit-asm
5-
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
5+
// Set the base cpu explicitly, in case the default has been changed.
6+
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64
67
//@ only-x86_64
78
//@ ignore-sgx
89

tests/codegen/target-feature-inline-closure.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ only-x86_64
2-
//@ compile-flags: -Copt-level=3
2+
// Set the base cpu explicitly, in case the default has been changed.
3+
//@ compile-flags: -Copt-level=3 -Ctarget-cpu=x86-64
34

45
#![crate_type = "lib"]
56
#![feature(target_feature_11)]

tests/ui/asm/x86_64/target-feature-attr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ only-x86_64
2+
// Set the base cpu explicitly, in case the default has been changed.
3+
//@ compile-flags: -C target-cpu=x86-64
24

35
#![feature(avx512_target_feature)]
46

tests/ui/asm/x86_64/target-feature-attr.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: register class `ymm_reg` requires the `avx` target feature
2-
--> $DIR/target-feature-attr.rs:18:40
2+
--> $DIR/target-feature-attr.rs:20:40
33
|
44
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
55
| ^^^^^^^^^^^^^
66

77
error: register class `ymm_reg` requires the `avx` target feature
8-
--> $DIR/target-feature-attr.rs:18:55
8+
--> $DIR/target-feature-attr.rs:20:55
99
|
1010
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
1111
| ^^^^^^^^^^^^^
1212

1313
error: register class `ymm_reg` requires the `avx` target feature
14-
--> $DIR/target-feature-attr.rs:18:70
14+
--> $DIR/target-feature-attr.rs:20:70
1515
|
1616
LL | asm!("vaddps {2:y}, {0:y}, {1:y}", in(ymm_reg) x, in(ymm_reg) y, lateout(ymm_reg) x);
1717
| ^^^^^^^^^^^^^^^^^^
1818

1919
error: register class `kreg` requires at least one of the following target features: avx512bw, avx512f
20-
--> $DIR/target-feature-attr.rs:33:23
20+
--> $DIR/target-feature-attr.rs:35:23
2121
|
2222
LL | asm!("/* {0} */", in(kreg) x);
2323
| ^^^^^^^^^^

tests/ui/consts/const-eval/const_fn_target_feature.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ only-x86_64
2-
//@ compile-flags:-C target-feature=+ssse3
2+
// Set the base cpu explicitly, in case the default has been changed.
3+
//@ compile-flags: -C target-cpu=x86-64 -C target-feature=+ssse3
34

45
#![crate_type = "lib"]
56

tests/ui/consts/const-eval/const_fn_target_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/const_fn_target_feature.rs:10:24
2+
--> $DIR/const_fn_target_feature.rs:11:24
33
|
44
LL | const B: () = unsafe { avx2_fn() };
55
| ^^^^^^^^^ calling a function that requires unavailable target features: avx2

tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ only-x86_64
2+
// Set the base cpu explicitly, in case the default has been changed.
3+
//@ compile-flags: -C target-cpu=x86-64
24

35
#![feature(target_feature_11)]
46

tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
2-
--> $DIR/safe-calls.rs:25:5
2+
--> $DIR/safe-calls.rs:27:5
33
|
44
LL | sse2();
55
| ^^^^^^ call to function with `#[target_feature]`
@@ -8,39 +8,39 @@ LL | sse2();
88
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
99

1010
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
11-
--> $DIR/safe-calls.rs:27:5
11+
--> $DIR/safe-calls.rs:29:5
1212
|
1313
LL | avx_bmi2();
1414
| ^^^^^^^^^^ call to function with `#[target_feature]`
1515
|
1616
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
1717

1818
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
19-
--> $DIR/safe-calls.rs:29:5
19+
--> $DIR/safe-calls.rs:31:5
2020
|
2121
LL | Quux.avx_bmi2();
2222
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
2323
|
2424
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
2525

2626
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
27-
--> $DIR/safe-calls.rs:35:5
27+
--> $DIR/safe-calls.rs:37:5
2828
|
2929
LL | avx_bmi2();
3030
| ^^^^^^^^^^ call to function with `#[target_feature]`
3131
|
3232
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
3333

3434
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
35-
--> $DIR/safe-calls.rs:37:5
35+
--> $DIR/safe-calls.rs:39:5
3636
|
3737
LL | Quux.avx_bmi2();
3838
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
3939
|
4040
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
4141

4242
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
43-
--> $DIR/safe-calls.rs:43:5
43+
--> $DIR/safe-calls.rs:45:5
4444
|
4545
LL | sse2();
4646
| ^^^^^^ call to function with `#[target_feature]`
@@ -49,23 +49,23 @@ LL | sse2();
4949
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
5050

5151
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
52-
--> $DIR/safe-calls.rs:45:5
52+
--> $DIR/safe-calls.rs:47:5
5353
|
5454
LL | avx_bmi2();
5555
| ^^^^^^^^^^ call to function with `#[target_feature]`
5656
|
5757
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
5858

5959
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
60-
--> $DIR/safe-calls.rs:47:5
60+
--> $DIR/safe-calls.rs:49:5
6161
|
6262
LL | Quux.avx_bmi2();
6363
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
6464
|
6565
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
6666

6767
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
68-
--> $DIR/safe-calls.rs:54:5
68+
--> $DIR/safe-calls.rs:56:5
6969
|
7070
LL | sse2();
7171
| ^^^^^^ call to function with `#[target_feature]`
@@ -74,7 +74,7 @@ LL | sse2();
7474
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
7575

7676
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
77-
--> $DIR/safe-calls.rs:58:15
77+
--> $DIR/safe-calls.rs:60:15
7878
|
7979
LL | const _: () = sse2();
8080
| ^^^^^^ call to function with `#[target_feature]`
@@ -83,7 +83,7 @@ LL | const _: () = sse2();
8383
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
8484

8585
error[E0133]: call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe and requires unsafe function or block
86-
--> $DIR/safe-calls.rs:61:15
86+
--> $DIR/safe-calls.rs:63:15
8787
|
8888
LL | const _: () = sse2_and_fxsr();
8989
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
@@ -92,7 +92,7 @@ LL | const _: () = sse2_and_fxsr();
9292
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
9393

9494
error: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
95-
--> $DIR/safe-calls.rs:68:5
95+
--> $DIR/safe-calls.rs:70:5
9696
|
9797
LL | sse2();
9898
| ^^^^^^ call to function with `#[target_feature]`
@@ -101,12 +101,12 @@ LL | sse2();
101101
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
102102
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
103103
note: an unsafe function restricts its caller, but its body is safe by default
104-
--> $DIR/safe-calls.rs:67:1
104+
--> $DIR/safe-calls.rs:69:1
105105
|
106106
LL | unsafe fn needs_unsafe_block() {
107107
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108108
note: the lint level is defined here
109-
--> $DIR/safe-calls.rs:64:8
109+
--> $DIR/safe-calls.rs:66:8
110110
|
111111
LL | #[deny(unsafe_op_in_unsafe_fn)]
112112
| ^^^^^^^^^^^^^^^^^^^^^^

tests/ui/sse2.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
assert!(cfg!(target_feature = "sse2"),
2020
"SSE2 was not detected as available on an x86 platform");
2121
}
22-
// check a negative case too -- allowed on x86, but not enabled by default
23-
assert!(cfg!(not(target_feature = "avx2")),
24-
"AVX2 shouldn't be detected as available by default on any platform");
22+
// check a negative case too -- certainly not enabled by default
23+
assert!(cfg!(not(target_feature = "ferris_wheel")),
24+
"🎡 shouldn't be detected as available by default on any platform");
2525
}

0 commit comments

Comments
 (0)