Skip to content

Commit c22f6d8

Browse files
committed
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
2 parents 50e9d4f + cb823b0 commit c22f6d8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustc/back/archive.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,25 @@ impl Archive {
119119
}
120120

121121
fn find_library(&self, name: &str) -> Path {
122-
let (prefix, ext) = match self.sess.targ_cfg.os {
122+
let (osprefix, osext) = match self.sess.targ_cfg.os {
123123
abi::OsWin32 => ("", "lib"), _ => ("lib", "a"),
124124
};
125-
let libname = format!("{}{}.{}", prefix, name, ext);
125+
// On windows, static libraries sometimes show up as libfoo.a and other
126+
// times show up as foo.lib
127+
let oslibname = format!("{}{}.{}", osprefix, name, osext);
128+
let unixlibname = format!("lib{}.a", name);
126129

127130
let mut rustpath = filesearch::rust_path();
128131
rustpath.push(self.sess.filesearch.get_target_lib_path());
129132
let path = self.sess.opts.addl_lib_search_paths.iter();
130133
for path in path.chain(rustpath.iter()) {
131134
debug!("looking for {} inside {}", name, path.display());
132-
let test = path.join(libname.clone());
135+
let test = path.join(oslibname.as_slice());
133136
if test.exists() { return test }
137+
if oslibname != unixlibname {
138+
let test = path.join(unixlibname.as_slice());
139+
if test.exists() { return test }
140+
}
134141
}
135142
self.sess.fatal(format!("could not find native static library `{}`, \
136143
perhaps an -L flag is missing?", name));

0 commit comments

Comments
 (0)