Skip to content

Commit e37f666

Browse files
committed
is_static_available: Also consider Windows MSVC libraries for dynamic linkage
1 parent 73d776d commit e37f666

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,10 +1004,19 @@ fn envify(name: &str) -> String {
10041004

10051005
/// System libraries should only be linked dynamically
10061006
fn is_static_available(name: &str, system_roots: &[PathBuf], dirs: &[PathBuf]) -> bool {
1007-
let libname = format!("lib{}.a", name);
1007+
let libnames = {
1008+
let mut names = vec![format!("lib{}.a", name)];
1009+
1010+
if cfg!(target_os = "windows") {
1011+
names.push(format!("{}.lib", name));
1012+
}
1013+
1014+
names
1015+
};
10081016

10091017
dirs.iter().any(|dir| {
1010-
!system_roots.iter().any(|sys| dir.starts_with(sys)) && dir.join(&libname).exists()
1018+
let library_exists = libnames.iter().any(|libname| dir.join(&libname).exists());
1019+
library_exists && !system_roots.iter().any(|sys| dir.starts_with(sys))
10111020
})
10121021
}
10131022

0 commit comments

Comments
 (0)