/// 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`.
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,
)?;
format_output(output, f)
}
- Error::__Nonexhaustive => panic!(),
+ Error::CrossCompilation | Error::__Nonexhaustive => panic!(),
}
}
}
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.
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");