summaryrefslogtreecommitdiffstats
path: root/vendor/pkg-config
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/pkg-config
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/pkg-config')
-rw-r--r--vendor/pkg-config/.cargo-checksum.json2
-rw-r--r--vendor/pkg-config/CHANGELOG.md7
-rw-r--r--vendor/pkg-config/Cargo.toml8
-rw-r--r--vendor/pkg-config/src/lib.rs258
4 files changed, 212 insertions, 63 deletions
diff --git a/vendor/pkg-config/.cargo-checksum.json b/vendor/pkg-config/.cargo-checksum.json
index c711f2e85..c5e73aa5c 100644
--- a/vendor/pkg-config/.cargo-checksum.json
+++ b/vendor/pkg-config/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"6ccf9b41e420b072e46d33a593a8290f232951a3b4d438d306deb16ef5a3d88a","Cargo.toml":"0bd2823eeb00210dcc8e6bd842fe834c5389945726d065fdc9e71794be9df222","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"37f11a56c969237dcfd15368e96bf686ec92b0254e38fb84636e178d632c0492","src/lib.rs":"5dbf70cd40e873df49f573171327c8cf5da50c25f7635aac6ff303016d6faa0c","tests/escape.pc":"00caa4136799dbe5bd504239ba90d1156c12def365c8d761da319fe8a83b398e","tests/foo.pc":"4a1c442c5d1c10761ea1644f8fd58f93cc5a706391bc67b04c243bbd35d70d79","tests/framework.pc":"304fdb6cea92973650e410ab1f70ce1ebeb7718af3f139e806efbf182acd565c","tests/rpath.pc":"424a844e844edfef02692492def9864833391f581338962946646989a69c1180","tests/test.rs":"dc0c27302c599524c06be5b807e8e371f60c8296e9da280677c79db1a3fe146a"},"package":"1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"bc1a9e53c60e64a9f30e81109eeae1273ee1f574291ff712c2cfa0ec78155c82","Cargo.toml":"e2faa7f58ba9688a2f1ab2708632b4f13d0c87e769c5909b7a30facad4d648de","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"37f11a56c969237dcfd15368e96bf686ec92b0254e38fb84636e178d632c0492","src/lib.rs":"04de2653405cdbe3c662fb8e31ea3dcab7431b32dbfbd3243075de6cb5f84588","tests/escape.pc":"00caa4136799dbe5bd504239ba90d1156c12def365c8d761da319fe8a83b398e","tests/foo.pc":"4a1c442c5d1c10761ea1644f8fd58f93cc5a706391bc67b04c243bbd35d70d79","tests/framework.pc":"304fdb6cea92973650e410ab1f70ce1ebeb7718af3f139e806efbf182acd565c","tests/rpath.pc":"424a844e844edfef02692492def9864833391f581338962946646989a69c1180","tests/test.rs":"dc0c27302c599524c06be5b807e8e371f60c8296e9da280677c79db1a3fe146a"},"package":"6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"} \ No newline at end of file
diff --git a/vendor/pkg-config/CHANGELOG.md b/vendor/pkg-config/CHANGELOG.md
index 952fd51ce..3ea463d03 100644
--- a/vendor/pkg-config/CHANGELOG.md
+++ b/vendor/pkg-config/CHANGELOG.md
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.3.26] - 2022-10-26
+
+### Added
+
+- Support for handling full paths to libraries in addition to normal `-l`
+ linker flags (#134).
+
## [0.3.25] - 2022-03-31
### Added
diff --git a/vendor/pkg-config/Cargo.toml b/vendor/pkg-config/Cargo.toml
index 5cc0d32b2..abd63e3d7 100644
--- a/vendor/pkg-config/Cargo.toml
+++ b/vendor/pkg-config/Cargo.toml
@@ -11,13 +11,17 @@
[package]
name = "pkg-config"
-version = "0.3.25"
+version = "0.3.26"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
-description = "A library to run the pkg-config system tool at build time in order to be used in\nCargo build scripts.\n"
+description = """
+A library to run the pkg-config system tool at build time in order to be used in
+Cargo build scripts.
+"""
documentation = "https://docs.rs/pkg-config"
readme = "README.md"
keywords = ["build-dependencies"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/pkg-config-rs"
+
[dev-dependencies.lazy_static]
version = "1"
diff --git a/vendor/pkg-config/src/lib.rs b/vendor/pkg-config/src/lib.rs
index a28304eea..e9395be46 100644
--- a/vendor/pkg-config/src/lib.rs
+++ b/vendor/pkg-config/src/lib.rs
@@ -38,8 +38,6 @@
//! Find the system library named `foo`, with minimum version 1.2.3:
//!
//! ```no_run
-//! extern crate pkg_config;
-//!
//! fn main() {
//! pkg_config::Config::new().atleast_version("1.2.3").probe("foo").unwrap();
//! }
@@ -49,8 +47,6 @@
//! recommended):
//!
//! ```no_run
-//! extern crate pkg_config;
-//!
//! fn main() {
//! pkg_config::probe_library("foo").unwrap();
//! }
@@ -59,8 +55,6 @@
//! Configure how library `foo` is linked to.
//!
//! ```no_run
-//! extern crate pkg_config;
-//!
//! fn main() {
//! pkg_config::Config::new().atleast_version("1.2.3").statik(true).probe("foo").unwrap();
//! }
@@ -93,14 +87,26 @@ pub struct Config {
#[derive(Clone, Debug)]
pub struct Library {
+ /// Libraries specified by -l
pub libs: Vec<String>,
+ /// Library search paths specified by -L
pub link_paths: Vec<PathBuf>,
+ /// Library file paths specified without -l
+ pub link_files: Vec<PathBuf>,
+ /// Darwin frameworks specified by -framework
pub frameworks: Vec<String>,
+ /// Darwin framework search paths specified by -F
pub framework_paths: Vec<PathBuf>,
+ /// C/C++ header include paths specified by -I
pub include_paths: Vec<PathBuf>,
+ /// Linker options specified by -Wl
pub ld_args: Vec<Vec<String>>,
+ /// C/C++ definitions specified by -D
pub defines: HashMap<String, Option<String>>,
+ /// Version specified by .pc file's Version field
pub version: String,
+ /// Ensure that this struct can only be created via its private `[Library::new]` constructor.
+ /// Users of this crate can only access the struct via `[Config::probe]`.
_priv: (),
}
@@ -175,7 +181,8 @@ impl fmt::Display for Error {
"Try `brew install pkg-config` if you have Homebrew.\n"
} else if cfg!(unix) {
"Try `apt install pkg-config`, or `yum install pkg-config`,\n\
- or `pkg install pkg-config` depending on your distribution.\n"
+ or `pkg install pkg-config`, or `apk add pkgconfig` \
+ depending on your distribution.\n"
} else {
"" // There's no easy fix for Windows users
};
@@ -557,6 +564,7 @@ impl Library {
Library {
libs: Vec::new(),
link_paths: Vec::new(),
+ link_files: Vec::new(),
include_paths: Vec::new(),
ld_args: Vec::new(),
frameworks: Vec::new(),
@@ -567,9 +575,67 @@ impl Library {
}
}
+ /// Extract the &str to pass to cargo:rustc-link-lib from a filename (just the file name, not including directories)
+ /// using target-specific logic.
+ fn extract_lib_from_filename<'a>(target: &str, filename: &'a str) -> Option<&'a str> {
+ fn test_suffixes<'b>(filename: &'b str, suffixes: &[&str]) -> Option<&'b str> {
+ for suffix in suffixes {
+ if filename.ends_with(suffix) {
+ return Some(&filename[..filename.len() - suffix.len()]);
+ }
+ }
+ None
+ }
+
+ let prefix = "lib";
+ if target.contains("msvc") {
+ // According to link.exe documentation:
+ // https://learn.microsoft.com/en-us/cpp/build/reference/link-input-files?view=msvc-170
+ //
+ // LINK doesn't use file extensions to make assumptions about the contents of a file.
+ // Instead, LINK examines each input file to determine what kind of file it is.
+ //
+ // However, rustc appends `.lib` to the string it receives from the -l command line argument,
+ // which it receives from Cargo via cargo:rustc-link-lib:
+ // https://github.com/rust-lang/rust/blob/657f246812ab2684e3c3954b1c77f98fd59e0b21/compiler/rustc_codegen_ssa/src/back/linker.rs#L828
+ // https://github.com/rust-lang/rust/blob/657f246812ab2684e3c3954b1c77f98fd59e0b21/compiler/rustc_codegen_ssa/src/back/linker.rs#L843
+ // So the only file extension that works for MSVC targets is `.lib`
+ return test_suffixes(filename, &[".lib"]);
+ } else if target.contains("windows") && target.contains("gnu") {
+ // GNU targets for Windows, including gnullvm, use `LinkerFlavor::Gcc` internally in rustc,
+ // which tells rustc to use the GNU linker. rustc does not prepend/append to the string it
+ // receives via the -l command line argument before passing it to the linker:
+ // https://github.com/rust-lang/rust/blob/657f246812ab2684e3c3954b1c77f98fd59e0b21/compiler/rustc_codegen_ssa/src/back/linker.rs#L446
+ // https://github.com/rust-lang/rust/blob/657f246812ab2684e3c3954b1c77f98fd59e0b21/compiler/rustc_codegen_ssa/src/back/linker.rs#L457
+ // GNU ld can work with more types of files than just the .lib files that MSVC's link.exe needs.
+ // GNU ld will prepend the `lib` prefix to the filename if necessary, so it is okay to remove
+ // the `lib` prefix from the filename. The `.a` suffix *requires* the `lib` prefix.
+ // https://sourceware.org/binutils/docs-2.39/ld.html#index-direct-linking-to-a-dll
+ if filename.starts_with(prefix) {
+ let filename = &filename[prefix.len()..];
+ return test_suffixes(filename, &[".dll.a", ".dll", ".lib", ".a"]);
+ } else {
+ return test_suffixes(filename, &[".dll.a", ".dll", ".lib"]);
+ }
+ } else if target.contains("apple") {
+ if filename.starts_with(prefix) {
+ let filename = &filename[prefix.len()..];
+ return test_suffixes(filename, &[".a", ".so", ".dylib"]);
+ }
+ return None;
+ } else {
+ if filename.starts_with(prefix) {
+ let filename = &filename[prefix.len()..];
+ return test_suffixes(filename, &[".a", ".so"]);
+ }
+ return None;
+ }
+ }
+
fn parse_libs_cflags(&mut self, name: &str, output: &[u8], config: &Config) {
let mut is_msvc = false;
- if let Ok(target) = env::var("TARGET") {
+ let target = env::var("TARGET");
+ if let Ok(target) = &target {
if target.contains("msvc") {
is_msvc = true;
}
@@ -669,7 +735,36 @@ impl Library {
self.include_paths.push(PathBuf::from(inc));
}
}
- _ => (),
+ _ => {
+ let path = std::path::Path::new(part);
+ if path.is_file() {
+ // Cargo doesn't have a means to directly specify a file path to link,
+ // so split up the path into the parent directory and library name.
+ // TODO: pass file path directly when link-arg library type is stabilized
+ // https://github.com/rust-lang/rust/issues/99427
+ if let (Some(dir), Some(file_name), Ok(target)) =
+ (path.parent(), path.file_name(), &target)
+ {
+ match Self::extract_lib_from_filename(
+ target,
+ &file_name.to_string_lossy(),
+ ) {
+ Some(lib_basename) => {
+ let link_search =
+ format!("rustc-link-search={}", dir.display());
+ config.print_metadata(&link_search);
+
+ let link_lib = format!("rustc-link-lib={}", lib_basename);
+ config.print_metadata(&link_lib);
+ self.link_files.push(PathBuf::from(path));
+ }
+ None => {
+ println!("cargo:warning=File path {} found in pkg-config file for {}, but could not extract library base name to pass to linker command line", path.display(), name);
+ }
+ }
+ }
+ }
+ }
}
}
@@ -775,60 +870,103 @@ fn split_flags(output: &[u8]) -> Vec<String> {
words
}
-#[test]
-#[cfg(target_os = "macos")]
-fn system_library_mac_test() {
- use std::path::Path;
-
- let system_roots = vec![PathBuf::from("/Library"), PathBuf::from("/System")];
-
- assert!(!is_static_available(
- "PluginManager",
- &system_roots,
- &[PathBuf::from("/Library/Frameworks")]
- ));
- assert!(!is_static_available(
- "python2.7",
- &system_roots,
- &[PathBuf::from(
- "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"
- )]
- ));
- assert!(!is_static_available(
- "ffi_convenience",
- &system_roots,
- &[PathBuf::from(
- "/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.10/ext/ffi_c/libffi-x86_64/.libs"
- )]
- ));
-
- // Homebrew is in /usr/local, and it's not a part of the OS
- if Path::new("/usr/local/lib/libpng16.a").exists() {
- assert!(is_static_available(
- "png16",
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ #[cfg(target_os = "macos")]
+ fn system_library_mac_test() {
+ use std::path::Path;
+
+ let system_roots = vec![PathBuf::from("/Library"), PathBuf::from("/System")];
+
+ assert!(!is_static_available(
+ "PluginManager",
&system_roots,
- &[PathBuf::from("/usr/local/lib")]
+ &[PathBuf::from("/Library/Frameworks")]
));
+ assert!(!is_static_available(
+ "python2.7",
+ &system_roots,
+ &[PathBuf::from(
+ "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config"
+ )]
+ ));
+ assert!(!is_static_available(
+ "ffi_convenience",
+ &system_roots,
+ &[PathBuf::from(
+ "/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.10/ext/ffi_c/libffi-x86_64/.libs"
+ )]
+ ));
+
+ // Homebrew is in /usr/local, and it's not a part of the OS
+ if Path::new("/usr/local/lib/libpng16.a").exists() {
+ assert!(is_static_available(
+ "png16",
+ &system_roots,
+ &[PathBuf::from("/usr/local/lib")]
+ ));
+
+ let libpng = Config::new()
+ .range_version("1".."99")
+ .probe("libpng16")
+ .unwrap();
+ assert!(libpng.version.find('\n').is_none());
+ }
+ }
- let libpng = Config::new()
- .range_version("1".."99")
- .probe("libpng16")
- .unwrap();
- assert!(libpng.version.find('\n').is_none());
+ #[test]
+ #[cfg(target_os = "linux")]
+ fn system_library_linux_test() {
+ assert!(!is_static_available(
+ "util",
+ &[PathBuf::from("/usr")],
+ &[PathBuf::from("/usr/lib/x86_64-linux-gnu")]
+ ));
+ assert!(!is_static_available(
+ "dialog",
+ &[PathBuf::from("/usr")],
+ &[PathBuf::from("/usr/lib")]
+ ));
}
-}
-#[test]
-#[cfg(target_os = "linux")]
-fn system_library_linux_test() {
- assert!(!is_static_available(
- "util",
- &[PathBuf::from("/usr")],
- &[PathBuf::from("/usr/lib/x86_64-linux-gnu")]
- ));
- assert!(!is_static_available(
- "dialog",
- &[PathBuf::from("/usr")],
- &[PathBuf::from("/usr/lib")]
- ));
+ fn test_library_filename(target: &str, filename: &str) {
+ assert_eq!(
+ Library::extract_lib_from_filename(target, filename),
+ Some("foo")
+ );
+ }
+
+ #[test]
+ fn link_filename_linux() {
+ let target = "x86_64-unknown-linux-gnu";
+ test_library_filename(target, "libfoo.a");
+ test_library_filename(target, "libfoo.so");
+ }
+
+ #[test]
+ fn link_filename_apple() {
+ let target = "x86_64-apple-darwin";
+ test_library_filename(target, "libfoo.a");
+ test_library_filename(target, "libfoo.so");
+ test_library_filename(target, "libfoo.dylib");
+ }
+
+ #[test]
+ fn link_filename_msvc() {
+ let target = "x86_64-pc-windows-msvc";
+ // static and dynamic libraries have the same .lib suffix
+ test_library_filename(target, "foo.lib");
+ }
+
+ #[test]
+ fn link_filename_mingw() {
+ let target = "x86_64-pc-windows-gnu";
+ test_library_filename(target, "foo.lib");
+ test_library_filename(target, "libfoo.a");
+ test_library_filename(target, "foo.dll");
+ test_library_filename(target, "foo.dll.a");
+ }
}