Skip to content

Commit fabd9f3

Browse files
committed
passthrough cc env/args using native cc features
Signed-off-by: Dylan Abraham <dylan@momentohq.com>
1 parent baae33d commit fabd9f3

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

jemalloc-sys/build.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,21 @@ fn main() {
154154
// Disable -Wextra warnings - jemalloc doesn't compile free of warnings with
155155
// it enabled: https://github.com/jemalloc/jemalloc/issues/1196
156156
let compiler = cc::Build::new().extra_warnings(false).get_compiler();
157-
let cflags = compiler
158-
.args()
159-
.iter()
160-
.map(|s| s.to_str().unwrap())
161-
.collect::<Vec<_>>()
162-
.join(" ");
163-
let ldflags = read_and_watch_env("LDFLAGS").unwrap_or_else(|_| cflags.clone());
164-
info!("CC={:?}", compiler.path());
157+
let cflags = compiler.cflags_env();
158+
let ldflags = read_and_watch_env("LDFLAGS")
159+
.map(OsString::from)
160+
.unwrap_or_else(|_| cflags.clone());
161+
162+
// Use cc_env() to get the full CC value including any wrapper (e.g. sccache).
163+
// cc_env() returns empty when no wrapper is configured, so fall back to path().
164+
let cc = compiler.cc_env();
165+
let cc = if cc.is_empty() {
166+
compiler.path().as_os_str().to_owned()
167+
} else {
168+
cc
169+
};
170+
171+
info!("CC={:?}", cc);
165172
info!("CFLAGS={:?}", cflags);
166173
info!("LDFLAGS={:?}", ldflags);
167174

@@ -197,10 +204,10 @@ fn main() {
197204
.replace('\\', "/"),
198205
)
199206
.current_dir(&build_dir)
200-
.env("CC", compiler.path())
201-
.env("CFLAGS", cflags.clone())
202-
.env("LDFLAGS", ldflags.clone())
203-
.env("CPPFLAGS", cflags)
207+
.env("CC", &cc)
208+
.env("CFLAGS", &cflags)
209+
.env("LDFLAGS", &ldflags)
210+
.env("CPPFLAGS", &cflags)
204211
.arg(format!("--with-version={je_version}"))
205212
.arg("--disable-cxx")
206213
.arg("--enable-doc=no")

0 commit comments

Comments
 (0)