From 0e383bf77501676f048f97fea921e2976291c880 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 13 Apr 2022 09:44:04 -0700 Subject: [PATCH 1/2] Don't let pkg-config add system lib dirs to the search path In its default configuration, pkg-config adds system-wide library directories to the linker search path (rust-lang/pkg-config-rs#11). This causes these directories to be searched before other paths added by later crates or by -Clink-arg in rustflags. If a library is present in the system-wide directory and a later build step wants to specifically link against a different version of that library in another path, the linker will choose the library from the first search directory it finds. If the linker doesn't find a library in any of the specified search directories, it falls back on system-wide paths, so we don't need to print the path we found libssh2 in if it is in one of those system paths. See rust-lang/libz-sys#50 for the same fix to libz that landed a while back. See also alexcrichton/curl-rust#441 for the same fix to libcurl-sys. --- libgit2-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgit2-sys/build.rs b/libgit2-sys/build.rs index cb30721e2b..26e3026cb2 100644 --- a/libgit2-sys/build.rs +++ b/libgit2-sys/build.rs @@ -14,7 +14,7 @@ fn main() { let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat; if try_to_use_system_libgit2 { let mut cfg = pkg_config::Config::new(); - if let Ok(lib) = cfg.range_version("1.4.0".."1.5.0").probe("libgit2") { + if let Ok(lib) = cfg.range_version("1.4.0".."1.5.0").print_system_libs(false).probe("libgit2") { for include in &lib.include_paths { println!("cargo:root={}", include.display()); } From 3b0a12bdd25a71d6aef23f7018f4ce6f96bbbdd1 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 13 Apr 2022 09:45:49 -0700 Subject: [PATCH 2/2] rustfmt --- libgit2-sys/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libgit2-sys/build.rs b/libgit2-sys/build.rs index 26e3026cb2..ef0468b40e 100644 --- a/libgit2-sys/build.rs +++ b/libgit2-sys/build.rs @@ -14,7 +14,11 @@ fn main() { let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat; if try_to_use_system_libgit2 { let mut cfg = pkg_config::Config::new(); - if let Ok(lib) = cfg.range_version("1.4.0".."1.5.0").print_system_libs(false).probe("libgit2") { + if let Ok(lib) = cfg + .range_version("1.4.0".."1.5.0") + .print_system_libs(false) + .probe("libgit2") + { for include in &lib.include_paths { println!("cargo:root={}", include.display()); }