about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2017-11-30 17:54:02 -0800
committerJosh Stone <jistone@redhat.com>2017-12-01 14:37:23 -0800
commit5c4452aaaf339fa4e4188f2e156af7251eed4119 (patch)
tree73e92e000135bcc2fdcb57b455844a192323e329
parent51342f1fd7f38153003f9780d83babc222139bb1 (diff)
downloadrust-5c4452aaaf339fa4e4188f2e156af7251eed4119.tar.gz
rust-5c4452aaaf339fa4e4188f2e156af7251eed4119.zip
rustc_llvm: Assume at least LLVM 3.9 in build.rs
-rw-r--r--src/librustc_llvm/build.rs44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index 141a9a8d704..10b0ec67370 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -17,27 +17,14 @@ use std::path::{PathBuf, Path};
 
 use build_helper::output;
 
-fn detect_llvm_link(major: u32, minor: u32, llvm_config: &Path)
-    -> (&'static str, Option<&'static str>) {
-    if major > 3 || (major == 3 && minor >= 9) {
-        // Force the link mode we want, preferring static by default, but
-        // possibly overridden by `configure --enable-llvm-link-shared`.
-        if env::var_os("LLVM_LINK_SHARED").is_some() {
-            return ("dylib", Some("--link-shared"));
-        } else {
-            return ("static", Some("--link-static"));
-        }
-    } else if major == 3 && minor == 8 {
-        // Find out LLVM's default linking mode.
-        let mut mode_cmd = Command::new(llvm_config);
-        mode_cmd.arg("--shared-mode");
-        if output(&mut mode_cmd).trim() == "shared" {
-            return ("dylib", None);
-        } else {
-            return ("static", None);
-        }
+fn detect_llvm_link() -> (&'static str, &'static str) {
+    // Force the link mode we want, preferring static by default, but
+    // possibly overridden by `configure --enable-llvm-link-shared`.
+    if env::var_os("LLVM_LINK_SHARED").is_some() {
+        ("dylib", "--link-shared")
+    } else {
+        ("static", "--link-static")
     }
-    ("static", None)
 }
 
 fn main() {
@@ -96,11 +83,11 @@ fn main() {
     let version_output = output(&mut version_cmd);
     let mut parts = version_output.split('.').take(2)
         .filter_map(|s| s.parse::<u32>().ok());
-    let (major, minor) =
+    let (major, _minor) =
         if let (Some(major), Some(minor)) = (parts.next(), parts.next()) {
             (major, minor)
         } else {
-            (3, 7)
+            (3, 9)
         };
 
     if major > 3 {
@@ -171,17 +158,13 @@ fn main() {
        .cpp_link_stdlib(None) // we handle this below
        .compile("librustllvm.a");
 
-    let (llvm_kind, llvm_link_arg) = detect_llvm_link(major, minor, &llvm_config);
+    let (llvm_kind, llvm_link_arg) = detect_llvm_link();
 
     // Link in all LLVM libraries, if we're uwring the "wrong" llvm-config then
     // we don't pick up system libs because unfortunately they're for the host
     // of llvm-config, not the target that we're attempting to link.
     let mut cmd = Command::new(&llvm_config);
-    cmd.arg("--libs");
-
-    if let Some(link_arg) = llvm_link_arg {
-        cmd.arg(link_arg);
-    }
+    cmd.arg(llvm_link_arg).arg("--libs");
 
     if !is_crossed {
         cmd.arg("--system-libs");
@@ -230,10 +213,7 @@ fn main() {
     // hack around this by replacing the host triple with the target and pray
     // that those -L directories are the same!
     let mut cmd = Command::new(&llvm_config);
-    if let Some(link_arg) = llvm_link_arg {
-        cmd.arg(link_arg);
-    }
-    cmd.arg("--ldflags");
+    cmd.arg(llvm_link_arg).arg("--ldflags");
     for lib in output(&mut cmd).split_whitespace() {
         if lib.starts_with("-LIBPATH:") {
             println!("cargo:rustc-link-search=native={}", &lib[9..]);