From a2d5fb0b06874ac48e6e5f37e2421cfc9f7fcee2 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 Signed-off-by: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> --- jemalloc-sys/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 3fc5b9fe4..88c04546e 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -147,7 +147,9 @@ fn main() { } // Disable -Wextra warnings - jemalloc doesn't compile free of warnings with // it enabled: https://github.com/jemalloc/jemalloc/issues/1196 - let compiler = cc::Build::new().extra_warnings(false).get_compiler(); + let mut build = cc::Build::new(); + let build = build.extra_warnings(false); + let (compiler, archiver) = (build.get_compiler(), build.get_archiver()); let cflags = compiler .args() .iter() @@ -155,6 +157,7 @@ fn main() { .collect::>() .join(" "); info!("CC={:?}", compiler.path()); + info!("AR={:?}", archiver.get_program()); info!("CFLAGS={:?}", cflags); assert!(out_dir.exists(), "OUT_DIR does not exist"); @@ -190,6 +193,7 @@ fn main() { ) .current_dir(&build_dir) .env("CC", compiler.path()) + .env("AR", archiver.get_program()) .env("CFLAGS", cflags.clone()) .env("LDFLAGS", cflags.clone()) .env("CPPFLAGS", cflags)