Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sets AR for Android only if using GCC #207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>().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::<Vec<_>>().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.
Expand Down