Skip to content

Commit be64fc8

Browse files
committed
Propagate LDFLAGS, if present
Ensures that when a toolchain is configured with `-fuse-ld` in its `LDFLAGS`, then `jemalloc-sys` selects the right linker. Behaviour was observed when using Bazel with an LLVM toolchain. Signed-off-by: Titouan Bion <titouan.bion@jetbrains.com>
1 parent df5934f commit be64fc8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

jemalloc-sys/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ fn main() {
160160
.map(|s| s.to_str().unwrap())
161161
.collect::<Vec<_>>()
162162
.join(" ");
163+
let ldflags = read_and_watch_env("LDFLAGS").unwrap_or_else(|_| cflags.clone());
163164
info!("CC={:?}", compiler.path());
164165
info!("CFLAGS={:?}", cflags);
166+
info!("LDFLAGS={:?}", ldflags);
165167

166168
assert!(out_dir.exists(), "OUT_DIR does not exist");
167169
let jemalloc_repo_dir = PathBuf::from("jemalloc");
@@ -197,7 +199,7 @@ fn main() {
197199
.current_dir(&build_dir)
198200
.env("CC", compiler.path())
199201
.env("CFLAGS", cflags.clone())
200-
.env("LDFLAGS", cflags.clone())
202+
.env("LDFLAGS", ldflags.clone())
201203
.env("CPPFLAGS", cflags)
202204
.arg(format!("--with-version={je_version}"))
203205
.arg("--disable-cxx")

0 commit comments

Comments
 (0)