Skip to content

Commit 96283fc

Browse files
committed
test: Add a min-llvm-version directive
We've got tests which require a particular version of LLVM to run as they're testing bug fixes. Our build system, however, supports multiple LLVM versions, so we can't run these tests on all LLVM versions. This adds a new `min-llvm-version` directive for tests so they can opt out of being run on older versions of LLVM. This then namely applies that logic to the `issue-36023.rs` test case and... Closes #36138
1 parent b2799a5 commit 96283fc

File tree

7 files changed

+33
-2
lines changed

7 files changed

+33
-2
lines changed

mk/main.mk

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
348348
LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
349349

350350
LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components)
351+
LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
351352

352353
endef
353354

mk/tests.mk

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
649649
--lldb-python $$(CFG_LLDB_PYTHON) \
650650
--gdb-version="$(CFG_GDB_VERSION)" \
651651
--lldb-version="$(CFG_LLDB_VERSION)" \
652+
--llvm-version="$$(LLVM_VERSION_$(3))" \
652653
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
653654
--adb-path=$(CFG_ADB) \
654655
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

src/bootstrap/check.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ pub fn compiletest(build: &Build,
148148
if let Some(ref dir) = build.lldb_python_dir {
149149
cmd.arg("--lldb-python-dir").arg(dir);
150150
}
151+
let llvm_config = build.llvm_config(target);
152+
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
153+
cmd.arg("--llvm-version").arg(llvm_version);
151154

152155
cmd.args(&build.flags.args);
153156

@@ -158,7 +161,6 @@ pub fn compiletest(build: &Build,
158161
// Only pass correct values for these flags for the `run-make` suite as it
159162
// requires that a C++ compiler was configured which isn't always the case.
160163
if suite == "run-make" {
161-
let llvm_config = build.llvm_config(target);
162164
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
163165
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
164166
cmd.arg("--cc").arg(build.cc(target))

src/test/run-pass/issue-36023.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// min-llvm-version 3.9
12+
1113
use std::ops::Deref;
1214

1315
fn main() {

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ pub struct Config {
152152
// Version of LLDB
153153
pub lldb_version: Option<String>,
154154

155+
// Version of LLVM
156+
pub llvm_version: Option<String>,
157+
155158
// Path to the android tools
156159
pub android_cross_path: PathBuf,
157160

src/tools/compiletest/src/header.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ impl EarlyProps {
4444
(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) ||
4545
(config.target != config.host &&
4646
parse_name_directive(ln, "ignore-cross-compile")) ||
47-
ignore_gdb(config, ln) || ignore_lldb(config, ln);
47+
ignore_gdb(config, ln) ||
48+
ignore_lldb(config, ln) ||
49+
ignore_llvm(config, ln);
4850

4951
props.should_fail = props.should_fail || parse_name_directive(ln, "should-fail");
5052
});
@@ -115,6 +117,24 @@ impl EarlyProps {
115117
false
116118
}
117119
}
120+
121+
fn ignore_llvm(config: &Config, line: &str) -> bool {
122+
if let Some(ref actual_version) = config.llvm_version {
123+
if line.contains("min-llvm-version") {
124+
let min_version = line.trim()
125+
.split(' ')
126+
.last()
127+
.expect("Malformed llvm version directive");
128+
// Ignore if actual version is smaller the minimum required
129+
// version
130+
&actual_version[..] < min_version
131+
} else {
132+
false
133+
}
134+
} else {
135+
false
136+
}
137+
}
118138
}
119139
}
120140

src/tools/compiletest/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
9999
optopt("", "host", "the host to build for", "HOST"),
100100
optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
101101
optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
102+
optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING"),
102103
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
103104
optopt("", "adb-path", "path to the android debugger", "PATH"),
104105
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@@ -170,6 +171,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
170171
host: opt_str2(matches.opt_str("host")),
171172
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
172173
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
174+
llvm_version: matches.opt_str("llvm-version"),
173175
android_cross_path: opt_path(matches, "android-cross-path"),
174176
adb_path: opt_str2(matches.opt_str("adb-path")),
175177
adb_test_dir: format!("{}/{}",

0 commit comments

Comments
 (0)