Skip to content

Commit 3cc5a85

Browse files
committed
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.
1 parent 3b21b21 commit 3cc5a85

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jemalloc-sys/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,19 @@ fn main() {
124124
}
125125
// Disable -Wextra warnings - jemalloc doesn't compile free of warnings with
126126
// it enabled: https://github.com/jemalloc/jemalloc/issues/1196
127-
let compiler = cc::Build::new().extra_warnings(false).get_compiler();
127+
let mut build = cc::Build::new();
128+
build.extra_warnings(false);
129+
let compiler = build.get_compiler();
128130
let cflags = compiler
129131
.args()
130132
.iter()
131133
.map(|s| s.to_str().unwrap())
132134
.collect::<Vec<_>>()
133135
.join(" ");
136+
let archiver = build.get_archiver();
134137
info!("CC={:?}", compiler.path());
135138
info!("CFLAGS={:?}", cflags);
139+
info!("AR={:?}", archiver.get_program());
136140

137141
assert!(out_dir.exists(), "OUT_DIR does not exist");
138142
let jemalloc_repo_dir = PathBuf::from("jemalloc");
@@ -168,6 +172,7 @@ fn main() {
168172
.current_dir(&build_dir)
169173
.env("CC", compiler.path())
170174
.env("CFLAGS", cflags.clone())
175+
.env("AR", archiver.get_program())
171176
.env("LDFLAGS", cflags.clone())
172177
.env("CPPFLAGS", cflags)
173178
.arg("--disable-cxx")

0 commit comments

Comments
 (0)