1
Fork 0

fix verbatim with upstream dependencies

https://github.com/rust-lang/rust/issues/99425#issuecomment-1207224161

r? `@petrochenkov`
This commit is contained in:
bors 2022-09-20 07:10:17 +00:00
parent a5b58addae
commit a38a082afb
8 changed files with 75 additions and 19 deletions

View file

@ -33,28 +33,25 @@ pub fn find_native_static_library(
search_paths: &[PathBuf],
sess: &Session,
) -> PathBuf {
let verbatim = verbatim.unwrap_or(false);
// On Windows, static libraries sometimes show up as libfoo.a and other
// times show up as foo.lib
let oslibname = if verbatim {
name.to_string()
let formats = if verbatim.unwrap_or(false) {
vec![("".into(), "".into())]
} else {
format!("{}{}{}", sess.target.staticlib_prefix, name, sess.target.staticlib_suffix)
let os = (sess.target.staticlib_prefix.clone(), sess.target.staticlib_suffix.clone());
// On Windows, static libraries sometimes show up as libfoo.a and other
// times show up as foo.lib
let unix = ("lib".into(), ".a".into());
if os == unix { vec![os] } else { vec![os, unix] }
};
let unixlibname = format!("lib{}.a", name);
for path in search_paths {
let test = path.join(&oslibname);
if test.exists() {
return test;
}
if oslibname != unixlibname {
let test = path.join(&unixlibname);
for (prefix, suffix) in &formats {
let test = path.join(format!("{}{}{}", prefix, name, suffix));
if test.exists() {
return test;
}
}
}
sess.emit_fatal(MissingNativeLibrary { libname: name });
}