Skip to content

Commit 1e39182

Browse files
author
Jon Gjengset
authored
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 lubcurl in if it is in one of those system paths. rust-lang/libz-sys#50
1 parent 0985c30 commit 1e39182

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

curl-sys/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ fn try_vcpkg() -> bool {
477477

478478
fn try_pkg_config() -> bool {
479479
let mut cfg = pkg_config::Config::new();
480+
cfg.print_system_libs(false);
480481
cfg.cargo_metadata(false);
482+
481483
let lib = match cfg.probe("libcurl") {
482484
Ok(lib) => lib,
483485
Err(e) => {

0 commit comments

Comments
 (0)