From 33c83c99f228849912aa3baea7a62ce266387094 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Mon, 11 Sep 2023 16:53:01 +0300 Subject: [PATCH] fix: Sets AR for Android only if using GCC Signed-off-by: Lachezar Lechev --- src/lib.rs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 72939e29..d6b9f571 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -353,22 +353,27 @@ impl Build { // prefix, we unset `CROSS_COMPILE` for `./Configure`. configure.env_remove("CROSS_COMPILE"); - let ar = cc.get_archiver(); - configure.env("AR", ar.get_program()); - if ar.get_args().count() != 0 { - // On some platforms (like emscripten on windows), the ar to use may not be a - // single binary, but instead a multi-argument command like `cmd /c emar.bar`. - // We can't convey that through `AR` alone, and so also need to set ARFLAGS. - configure.env( - "ARFLAGS", - ar.get_args().collect::>().join(OsStr::new(" ")), - ); + // We don't have GCC in newer NDK versions. + if !target.contains("android") || (target.contains("android") && path.contains("-gcc")) + { + let ar = cc.get_archiver(); + configure.env("AR", ar.get_program()); + if ar.get_args().count() != 0 { + // On some platforms (like emscripten on windows), the ar to use may not be a + // single binary, but instead a multi-argument command like `cmd /c emar.bar`. + // We can't convey that through `AR` alone, and so also need to set ARFLAGS. + configure.env( + "ARFLAGS", + ar.get_args().collect::>().join(OsStr::new(" ")), + ); + } + + let ranlib = cc.get_ranlib(); + // OpenSSL does not support RANLIBFLAGS. Jam the flags in RANLIB. + let mut args = vec![ranlib.get_program()]; + args.extend(ranlib.get_args()); + configure.env("RANLIB", args.join(OsStr::new(" "))); } - let ranlib = cc.get_ranlib(); - // OpenSSL does not support RANLIBFLAGS. Jam the flags in RANLIB. - let mut args = vec![ranlib.get_program()]; - args.extend(ranlib.get_args()); - configure.env("RANLIB", args.join(OsStr::new(" "))); // Make sure we pass extra flags like `-ffunction-sections` and // other things like ARM codegen flags.