From 35d3d1b9d741982184293e6bbdff7017118f4403 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 26 Oct 2022 13:20:33 -0700 Subject: [PATCH] Continue to support binutils ar sfackler [observed] that the `binutils` package [provides] binaries named `$target-ar` (with no `-gcc`). This patch augments the change made in #735 to continue picking those up too. [observed]: https://github.com/alexcrichton/openssl-src-rs/pull/163#issuecomment-1292439189 [provides]: https://packages.debian.org/bullseye/amd64/binutils-aarch64-linux-gnu/filelist --- src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 885589996..920545494 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2605,12 +2605,17 @@ impl Build { } else if self.get_host()? != target { match self.prefix_for_target(&target) { Some(p) => { - let target_ar = format!("{}-gcc-ar", p); - if Command::new(&target_ar).output().is_ok() { - target_ar - } else { - default_ar + // GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both. + // Prefer -gcc-ar if it exists, since that matches what we'll use for $CC. + let mut ar = default_ar; + for &infix in &["-gcc", ""] { + let target_ar = format!("{}{}-ar", p, infix); + if Command::new(&target_ar).output().is_ok() { + ar = target_ar; + break; + } } + ar } None => default_ar, }