about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-12-03 21:11:26 -0800
committerbors <bors@rust-lang.org>2013-12-03 21:11:26 -0800
commitc22f6d8d44d6ccd40acec67b8446711859be8467 (patch)
treec9ee5c141e9c9a7b185285381f48d91a8ce4c0e5
parent50e9d4f8899ab2c783e2889a019c5a9f8f95f2f9 (diff)
parentcb823b09dfc2ca71bda66e874c5e450038fbec1d (diff)
downloadrust-c22f6d8d44d6ccd40acec67b8446711859be8467.tar.gz
rust-c22f6d8d44d6ccd40acec67b8446711859be8467.zip
auto merge of #10785 : alexcrichton/rust/omg-i-hate-windows, r=pcwalton
Turns out LLVM only builds libfoo.a libraries, so we're going to need this logic
to statically link librustc
-rw-r--r--src/librustc/back/archive.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs
index 9f5aaf3a426..4711381a7b8 100644
--- a/src/librustc/back/archive.rs
+++ b/src/librustc/back/archive.rs
@@ -119,18 +119,25 @@ impl Archive {
     }
 
     fn find_library(&self, name: &str) -> Path {
-        let (prefix, ext) = match self.sess.targ_cfg.os {
+        let (osprefix, osext) = match self.sess.targ_cfg.os {
             abi::OsWin32 => ("", "lib"), _ => ("lib", "a"),
         };
-        let libname = format!("{}{}.{}", prefix, name, ext);
+        // On windows, static libraries sometimes show up as libfoo.a and other
+        // times show up as foo.lib
+        let oslibname = format!("{}{}.{}", osprefix, name, osext);
+        let unixlibname = format!("lib{}.a", name);
 
         let mut rustpath = filesearch::rust_path();
         rustpath.push(self.sess.filesearch.get_target_lib_path());
         let path = self.sess.opts.addl_lib_search_paths.iter();
         for path in path.chain(rustpath.iter()) {
             debug!("looking for {} inside {}", name, path.display());
-            let test = path.join(libname.clone());
+            let test = path.join(oslibname.as_slice());
             if test.exists() { return test }
+            if oslibname != unixlibname {
+                let test = path.join(unixlibname.as_slice());
+                if test.exists() { return test }
+            }
         }
         self.sess.fatal(format!("could not find native static library `{}`, \
                                  perhaps an -L flag is missing?", name));