Skip to content

Commit 6271b7b

Browse files
authored
Unrolled build for rust-lang#132310
Rollup merge of rust-lang#132310 - jieyouxu:max-llvm-version, r=onur-ozkan compiletest: add `max-llvm-major-version` directive To complement existing `min-llvm-version` so contributors don't have to use `ignore-llvm-version: 20 - 99` to emulate `max-llvm-major-version: 19`. Closes rust-lang#132305. cc `@workingjubilee` who suggested this. ### Implementation steps - [x] 1. Implement the directive (this PR) - [x] 2. Open an accompanying dev-guide PR to describe the directive (rust-lang/rustc-dev-guide#2129) r? bootstrap
2 parents dae7ac1 + 91fa16b commit 6271b7b

File tree

8 files changed

+29
-5
lines changed

8 files changed

+29
-5
lines changed

src/tools/compiletest/src/directive-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
120120
"incremental",
121121
"known-bug",
122122
"llvm-cov-flags",
123+
"max-llvm-major-version",
123124
"min-cdb-version",
124125
"min-gdb-version",
125126
"min-lldb-version",

src/tools/compiletest/src/header.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,20 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
15461546
),
15471547
};
15481548
}
1549+
} else if let Some(version_string) =
1550+
config.parse_name_value_directive(line, "max-llvm-major-version")
1551+
{
1552+
let max_version = extract_llvm_version(&version_string);
1553+
// Ignore if actual major version is larger than the maximum required major version.
1554+
if actual_version.major > max_version.major {
1555+
return IgnoreDecision::Ignore {
1556+
reason: format!(
1557+
"ignored when the LLVM version ({actual_version}) is newer than major\
1558+
version {}",
1559+
max_version.major
1560+
),
1561+
};
1562+
}
15491563
} else if let Some(version_string) =
15501564
config.parse_name_value_directive(line, "min-system-llvm-version")
15511565
{

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

+9
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ fn llvm_version() {
299299

300300
let config: Config = cfg().llvm_version("10.6.2").build();
301301
assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10"));
302+
303+
let config: Config = cfg().llvm_version("19.0.0").build();
304+
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));
305+
306+
let config: Config = cfg().llvm_version("19.1.2").build();
307+
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));
308+
309+
let config: Config = cfg().llvm_version("20.0.0").build();
310+
assert!(check_ignore(&config, "//@ max-llvm-major-version: 19"));
302311
}
303312

304313
#[test]

tests/assembly/riscv-soft-abi-with-float-features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d
33
//@ needs-llvm-components: riscv
44
//@ revisions: LLVM-PRE-20 LLVM-POST-20
5-
//@ [LLVM-PRE-20] ignore-llvm-version: 20 - 99
5+
//@ [LLVM-PRE-20] max-llvm-major-version: 19
66
//@ [LLVM-POST-20] min-llvm-version: 20
77

88
#![feature(no_core, lang_items, f16)]

tests/assembly/x86_64-cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: DEBUG LLVM-PRE-20-OPTIM LLVM-20-OPTIM
22
//@ [DEBUG] compile-flags: -C opt-level=0
33
//@ [LLVM-PRE-20-OPTIM] compile-flags: -C opt-level=3
4-
//@ [LLVM-PRE-20-OPTIM] ignore-llvm-version: 20 - 99
4+
//@ [LLVM-PRE-20-OPTIM] max-llvm-major-version: 19
55
//@ [LLVM-20-OPTIM] compile-flags: -C opt-level=3
66
//@ [LLVM-20-OPTIM] min-llvm-version: 20
77
//@ assembly-output: emit-asm

tests/codegen/branch-protection-old-llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@ [LEAF] compile-flags: -Z branch-protection=pac-ret,leaf
88
//@ [BKEY] compile-flags: -Z branch-protection=pac-ret,b-key
99
//@ compile-flags: --target aarch64-unknown-linux-gnu
10-
//@ ignore-llvm-version: 19 - 99
10+
//@ max-llvm-major-version: 18
1111

1212
#![crate_type = "lib"]
1313
#![feature(no_core, lang_items)]

tests/codegen/call-metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// scalar value.
33

44
//@ compile-flags: -O -C no-prepopulate-passes
5-
//@ ignore-llvm-version: 19 - 99
5+
//@ max-llvm-major-version: 18
66

77
#![crate_type = "lib"]
88

tests/codegen/integer-cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
//@ revisions: llvm-pre-20 llvm-20
55
//@ [llvm-20] min-llvm-version: 20
6-
//@ [llvm-pre-20] ignore-llvm-version: 20 - 99
6+
//@ [llvm-pre-20] max-llvm-major-version: 19
77
//@ compile-flags: -C opt-level=3
88

99
#![crate_type = "lib"]

0 commit comments

Comments
 (0)