summaryrefslogtreecommitdiffstats
path: root/debian/patches/d-0001-pkg-config-no-special-snowflake.patch
blob: db66e2c34bdb93295ff2a23d2fd920a19adb1f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From: Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Date: Sat, 2 Oct 2021 01:08:00 +0100
Subject: d-0001-pkg-config-no-special-snowflake

---
 vendor/pkg-config/src/lib.rs    | 25 ++++++++++---------------
 vendor/pkg-config/tests/test.rs |  2 --
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/vendor/pkg-config/src/lib.rs b/vendor/pkg-config/src/lib.rs
index a28304e..11f9460 100644
--- a/vendor/pkg-config/src/lib.rs
+++ b/vendor/pkg-config/src/lib.rs
@@ -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");
diff --git a/vendor/pkg-config/tests/test.rs b/vendor/pkg-config/tests/test.rs
index 4e04ac0..f884e46 100644
--- a/vendor/pkg-config/tests/test.rs
+++ b/vendor/pkg-config/tests/test.rs
@@ -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();