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)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Thu, 27 Jun 2024 12:30:53 +0000 (14:30 +0200)
Description: always enable cross compilation via pkgconf, and set the right binary name.

Forwarded: not-needed

Gbp-Pq: Topic prune
Gbp-Pq: Name d-0001-pkg-config-no-special-snowflake.patch

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

index b4254046b079c2941cada27bcf7478b010586312..b8800794260a2830a3387650dc29bfe7fbf82271 100644 (file)
@@ -150,11 +150,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`.
@@ -269,14 +266,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,
@@ -402,7 +391,7 @@ impl fmt::Display for Error {
                 )?;
                 format_output(output, f)
             }
-            Error::__Nonexhaustive => panic!(),
+            Error::CrossCompilation | Error::__Nonexhaustive => panic!(),
         }
     }
 }
@@ -596,6 +585,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.
@@ -653,7 +644,12 @@ impl Config {
     }
 
     fn run(&self, name: &str, args: &[&str]) -> Result<Vec<u8>, Error> {
-        let pkg_config_exe = self.targeted_env_var("PKG_CONFIG");
+        let pkg_config_exe = self.targeted_env_var("PKG_CONFIG").or_else(|| {
+            self.env_var_os("DEB_HOST_GNU_TYPE").map(|mut t| {
+                t.push(OsString::from("-pkgconf"));
+                t
+            })
+        });
         let fallback_exe = if pkg_config_exe.is_none() {
             Some(OsString::from("pkgconf"))
         } else {
index 0f37c7224d68613ee48f8652c3745c5026ab25ee..f70e8b711b63546c724648534e762d47ece50526 100644 (file)
@@ -31,7 +31,6 @@ fn find(name: &str) -> Result<pkg_config::Library, Error> {
     pkg_config::probe_library(name)
 }
 
-#[test]
 fn cross_disabled() {
     let _g = LOCK.lock();
     reset();
@@ -43,7 +42,6 @@ fn cross_disabled() {
     }
 }
 
-#[test]
 fn cross_enabled() {
     let _g = LOCK.lock();
     reset();