]> git.lizzy.rs Git - rust.git/commitdiff
bootstrap: update and enable the LLVM version-check
authorJosh Stone <jistone@redhat.com>
Mon, 16 Oct 2017 19:57:37 +0000 (12:57 -0700)
committerJosh Stone <jistone@redhat.com>
Mon, 16 Oct 2017 20:10:16 +0000 (13:10 -0700)
While the `config.toml.example` comments say "we automatically check the
version by default," we actually didn't.  That check was badly out of
date, only allowing 3.5, 3.6, or 3.7.  This it now updated to the new
3.9 minimum requirement, and truly enabled by default.

config.toml.example
src/bootstrap/config.rs
src/bootstrap/native.rs

index f50543e18a764845d76fab7ef6eb990d850f1fb1..261fe2053879f004fd2ffeecc23d49c43ceb8467 100644 (file)
@@ -35,7 +35,7 @@
 # If an external LLVM root is specified, we automatically check the version by
 # default to make sure it's within the range that we're expecting, but setting
 # this flag will indicate that this version check should not be done.
-#version-check = false
+#version-check = true
 
 # Link libstdc++ statically into the librustc_llvm instead of relying on a
 # dynamic version to be available.
index 69e0f58f1cd068f8639cb4737bdf6ae73461cd79..d6c83e3acfc8ab3d844535644e4310aab3bb950b 100644 (file)
@@ -299,6 +299,7 @@ pub fn parse(args: &[String]) -> Config {
         let mut config = Config::default();
         config.llvm_enabled = true;
         config.llvm_optimize = true;
+        config.llvm_version_check = true;
         config.use_jemalloc = true;
         config.backtrace = true;
         config.rust_optimize = true;
index 941ea96bbec23c8b327acf9a6a3471a11c6c21fe..c37b1dad4c687cd9698543861ec74433206c3ab0 100644 (file)
@@ -259,11 +259,14 @@ fn check_llvm_version(build: &Build, llvm_config: &Path) {
 
     let mut cmd = Command::new(llvm_config);
     let version = output(cmd.arg("--version"));
-    if version.starts_with("3.5") || version.starts_with("3.6") ||
-       version.starts_with("3.7") {
-        return
+    let mut parts = version.split('.').take(2)
+        .filter_map(|s| s.parse::<u32>().ok());
+    if let (Some(major), Some(minor)) = (parts.next(), parts.next()) {
+        if major > 3 || (major == 3 && minor >= 9) {
+            return
+        }
     }
-    panic!("\n\nbad LLVM version: {}, need >=3.5\n\n", version)
+    panic!("\n\nbad LLVM version: {}, need >=3.9\n\n", version)
 }
 
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]