Skip to content

Commit

Permalink
Don't let pkg-config add system lib dirs to the search path
Browse files Browse the repository at this point in the history
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.

See rust-lang/libz-sys#50 for the same fix to libz that landed a while back.
  • Loading branch information
Jon Gjengset authored Apr 12, 2022
1 parent 0985c30 commit 850ea81
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions curl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ fn try_vcpkg() -> bool {

fn try_pkg_config() -> bool {
let mut cfg = pkg_config::Config::new();
cfg.print_system_libs(false);
cfg.cargo_metadata(false);
let lib = match cfg.probe("libcurl") {
Ok(lib) => lib,
Expand Down

0 comments on commit 850ea81

Please sign in to comment.