Skip to content

Commit

Permalink
Don't ignore transitive imports when probing a static library
Browse files Browse the repository at this point in the history
Suppressing cargo_metadata silences libraries with full paths, in turn
causing linking against static libraries to fail utterly on Windows.
  • Loading branch information
amyspark authored and gdesmott committed Mar 14, 2024
1 parent a80ea92 commit 1db7d8b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,19 @@ impl Library {
};

let is_static_available = |name: &String| -> bool {
let libname = format!("lib{}.a", name);
let libnames = {
let mut names = vec![format!("lib{}.a", name)];

if cfg!(target_os = "windows") {
names.push(format!("{}.lib", name));
}

names
};

l.link_paths.iter().any(|dir| {
!system_roots.iter().any(|sys| dir.starts_with(sys)) && dir.join(&libname).exists()
let library_exists = libnames.iter().any(|libname| dir.join(libname).exists());
library_exists && !system_roots.iter().any(|sys| dir.starts_with(sys))
})
};

Expand Down

0 comments on commit 1db7d8b

Please sign in to comment.