d-0001-pkg-config-no-special-snowflake
authorDebian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Sat, 2 Oct 2021 00:08:00 +0000 (01:08 +0100)
committerJeremy Bícha <jbicha@ubuntu.com>
Mon, 26 Jun 2023 21:16:27 +0000 (22:16 +0100)
Gbp-Pq: Name d-0001-pkg-config-no-special-snowflake.patch

vendor/pkg-config/src/lib.rs
vendor/pkg-config/tests/test.rs

index a28304eeaa590ae1d526e0224fe22a007408258d..11f94604502c42e9f19c8c3f4c36d0eebf9df5f9 100644 (file)
@@ -111,11 +111,8 @@ pub enum Error {
     /// Contains the name of the responsible environment variable.
     EnvNoPkgConfig(String),
 
-    /// Detected cross compilation without a custom sysroot.
-    ///
-    /// Ignore the error with `PKG_CONFIG_ALLOW_CROSS=1`,
-    /// which may let `pkg-config` select libraries
-    /// for the host's architecture instead of the target's.
+    /// Cross compilation detected. Kept for compatibility;
+    /// the Debian package never emits this.
     CrossCompilation,
 
     /// Failed to run `pkg-config`.
@@ -155,14 +152,6 @@ impl fmt::Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
         match *self {
             Error::EnvNoPkgConfig(ref name) => write!(f, "Aborted because {} is set", name),
-            Error::CrossCompilation => f.write_str(
-                "pkg-config has not been configured to support cross-compilation.\n\
-                \n\
-                Install a sysroot for the target platform and configure it via\n\
-                PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\n\
-                cross-compiling wrapper for pkg-config and set it via\n\
-                PKG_CONFIG environment variable.",
-            ),
             Error::Command {
                 ref command,
                 ref cause,
@@ -219,7 +208,7 @@ impl fmt::Display for Error {
                 )?;
                 format_output(output, f)
             }
-            Error::__Nonexhaustive => panic!(),
+            Error::CrossCompilation | Error::__Nonexhaustive => panic!(),
         }
     }
 }
@@ -411,6 +400,8 @@ impl Config {
         if host == target {
             return true;
         }
+        // always enable PKG_CONFIG_ALLOW_CROSS override in Debian
+        return true;
 
         // pkg-config may not be aware of cross-compilation, and require
         // a wrapper script that sets up platform-specific prefixes.
@@ -470,7 +461,11 @@ impl Config {
     fn command(&self, name: &str, args: &[&str]) -> Command {
         let exe = self
             .targetted_env_var("PKG_CONFIG")
-            .unwrap_or_else(|| OsString::from("pkg-config"));
+            .unwrap_or_else(|| {
+                self.env_var_os("DEB_HOST_GNU_TYPE")
+                    .map(|mut t| { t.push(OsString::from("-pkg-config")); t })
+                    .unwrap_or_else(|| OsString::from("pkg-config"))
+            });
         let mut cmd = Command::new(exe);
         if self.is_static(name) {
             cmd.arg("--static");
index 4e04ac071224f503ae444641a1e118ed326f56be..f884e46c9e2a36101f9b279d01b1529754d11c05 100644 (file)
@@ -34,7 +34,6 @@ fn find(name: &str) -> Result<pkg_config::Library, Error> {
     pkg_config::probe_library(name)
 }
 
-#[test]
 fn cross_disabled() {
     let _g = LOCK.lock();
     reset();
@@ -46,7 +45,6 @@ fn cross_disabled() {
     }
 }
 
-#[test]
 fn cross_enabled() {
     let _g = LOCK.lock();
     reset();