]> git.lizzy.rs Git - rust.git/commitdiff
test: Add a min-llvm-version directive
authorAlex Crichton <alex@alexcrichton.com>
Thu, 1 Sep 2016 17:52:44 +0000 (10:52 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 1 Sep 2016 23:14:17 +0000 (16:14 -0700)
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

mk/main.mk
mk/tests.mk
src/bootstrap/check.rs
src/test/run-pass/issue-36023.rs
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/main.rs

index 5a849af9856f1dd348259cfb0338532133ce31f9..6130b581387515af42c59a2ca4f8d31302b1c016 100644 (file)
@@ -348,6 +348,7 @@ LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
 
 LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components)
+LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
 
 endef
 
index 201e4cae51d6d9a4e293d2eedfa276f477991cd3..c135aa9b8fb956cd9b186af8736ff1d83597ac72 100644 (file)
@@ -649,6 +649,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
        --lldb-python $$(CFG_LLDB_PYTHON) \
         --gdb-version="$(CFG_GDB_VERSION)" \
         --lldb-version="$(CFG_LLDB_VERSION)" \
+        --llvm-version="$$(LLVM_VERSION_$(3))" \
         --android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
         --adb-path=$(CFG_ADB) \
         --adb-test-dir=$(CFG_ADB_TEST_DIR) \
index 3d8b1438125e6fda3aa20aea8bdfb6ca1a70f79b..2b9d717cbd48dbaa3365257cb80916b32a10c393 100644 (file)
@@ -148,6 +148,9 @@ pub fn compiletest(build: &Build,
     if let Some(ref dir) = build.lldb_python_dir {
         cmd.arg("--lldb-python-dir").arg(dir);
     }
+    let llvm_config = build.llvm_config(target);
+    let llvm_version = output(Command::new(&llvm_config).arg("--version"));
+    cmd.arg("--llvm-version").arg(llvm_version);
 
     cmd.args(&build.flags.args);
 
@@ -158,7 +161,6 @@ pub fn compiletest(build: &Build,
     // Only pass correct values for these flags for the `run-make` suite as it
     // requires that a C++ compiler was configured which isn't always the case.
     if suite == "run-make" {
-        let llvm_config = build.llvm_config(target);
         let llvm_components = output(Command::new(&llvm_config).arg("--components"));
         let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
         cmd.arg("--cc").arg(build.cc(target))
index f6c03b384f23db86416efe87d2436f628bdabea6..53a8a403b6410167cd5611c4c69a3d7760aa9372 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// min-llvm-version 3.9
+
 use std::ops::Deref;
 
 fn main() {
index 6090cb4f52725784789fb5904c7ffc850e334ef1..5d522736089ea4d2acf1340b99bf5a6cd6c23583 100644 (file)
@@ -152,6 +152,9 @@ pub struct Config {
     // Version of LLDB
     pub lldb_version: Option<String>,
 
+    // Version of LLVM
+    pub llvm_version: Option<String>,
+
     // Path to the android tools
     pub android_cross_path: PathBuf,
 
index af33d76be1b0db0f430b4dcc5a4ee774a2c0d08d..899a366a4bb7412b42ae3a09b1a69197c53ab410 100644 (file)
@@ -44,7 +44,9 @@ pub fn from_file(config: &Config, testfile: &Path) -> Self {
                 (config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) ||
                 (config.target != config.host &&
                  parse_name_directive(ln, "ignore-cross-compile")) ||
-                ignore_gdb(config, ln) || ignore_lldb(config, ln);
+                ignore_gdb(config, ln) ||
+                ignore_lldb(config, ln) ||
+                ignore_llvm(config, ln);
 
             props.should_fail = props.should_fail || parse_name_directive(ln, "should-fail");
         });
@@ -115,6 +117,24 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
                 false
             }
         }
+
+        fn ignore_llvm(config: &Config, line: &str) -> bool {
+            if let Some(ref actual_version) = config.llvm_version {
+                if line.contains("min-llvm-version") {
+                    let min_version = line.trim()
+                        .split(' ')
+                        .last()
+                        .expect("Malformed llvm version directive");
+                    // Ignore if actual version is smaller the minimum required
+                    // version
+                    &actual_version[..] < min_version
+                } else {
+                    false
+                }
+            } else {
+                false
+            }
+        }
     }
 }
 
index 90641b5c476d7bbd93412d4eeb878fa0f7295e52..4afeb3613319b025bb8291e5d03ce4cf622a8a7c 100644 (file)
@@ -99,6 +99,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
           optopt("", "host", "the host to build for", "HOST"),
           optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
           optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
+          optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING"),
           optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
           optopt("", "adb-path", "path to the android debugger", "PATH"),
           optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@@ -170,6 +171,7 @@ fn make_absolute(path: PathBuf) -> PathBuf {
         host: opt_str2(matches.opt_str("host")),
         gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
         lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
+        llvm_version: matches.opt_str("llvm-version"),
         android_cross_path: opt_path(matches, "android-cross-path"),
         adb_path: opt_str2(matches.opt_str("adb-path")),
         adb_test_dir: format!("{}/{}",