Skip to content

Commit 00befe7

Browse files
Jon Gjengsetthomcc
Jon Gjengset
authored andcommitted
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]: alexcrichton/openssl-src-rs#163 (comment) [provides]: https://packages.debian.org/bullseye/amd64/binutils-aarch64-linux-gnu/filelist
1 parent 76c821e commit 00befe7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/lib.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -2605,12 +2605,17 @@ impl Build {
26052605
} else if self.get_host()? != target {
26062606
match self.prefix_for_target(&target) {
26072607
Some(p) => {
2608-
let target_ar = format!("{}-gcc-ar", p);
2609-
if Command::new(&target_ar).output().is_ok() {
2610-
target_ar
2611-
} else {
2612-
default_ar
2608+
// GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both.
2609+
// Prefer -gcc-ar if it exists, since that matches what we'll use for $CC.
2610+
let mut ar = default_ar;
2611+
for &infix in &["-gcc", ""] {
2612+
let target_ar = format!("{}{}-ar", p, infix);
2613+
if Command::new(&target_ar).output().is_ok() {
2614+
ar = target_ar;
2615+
break;
2616+
}
26132617
}
2618+
ar
26142619
}
26152620
None => default_ar,
26162621
}

0 commit comments

Comments
 (0)