From c22fae4a590f4e526fe7985533ba9ec85c931286 Mon Sep 17 00:00:00 2001 From: roblabla Date: Thu, 13 Mar 2025 17:52:29 +0100 Subject: [PATCH] Set AR with the archiver from cc-rs cc-rs offers some variables to set the archiver program (commonly ar) that should be used for a given target. This is commonly used in cross-compilation situations, to use a version of AR compatible with the target linker. Signed-off-by: roblabla --- jemalloc-sys/build.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 3de7437c8..a07a12b8d 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -145,9 +145,11 @@ fn main() { println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]); return; } - - let compiler = cc::Build::new().get_compiler(); + let build = cc::Build::new(); + let compiler = build.get_compiler(); + let archiver = build.get_archiver(); info!("CC={:?}", compiler.path()); + info!("AR={:?}", archiver.get_program()); assert!(out_dir.exists(), "OUT_DIR does not exist"); let jemalloc_repo_dir = PathBuf::from("jemalloc"); @@ -182,6 +184,7 @@ fn main() { ) .current_dir(&build_dir) .env("CC", compiler.path()) + .env("AR", archiver.get_program()) .arg(format!("--with-version={je_version}")) .arg("--disable-cxx") .arg("--enable-doc=no")