Skip to content

Commit 441a0fc

Browse files
committed
Absolutify CXX as well as CC
Also add the `--sysroot` flag if needed
1 parent 51bdb08 commit 441a0fc

File tree

1 file changed

+8
-6
lines changed
  • cargo/cargo_build_script_runner

1 file changed

+8
-6
lines changed

cargo/cargo_build_script_runner/bin.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ fn run_buildrs() -> Result<(), String> {
8888
}
8989
}
9090

91-
if let Some(cc_path) = env::var_os("CC") {
92-
let mut cc_path = exec_root.join(cc_path);
93-
if let Some(sysroot_path) = env::var_os("SYSROOT") {
94-
cc_path.push(" --sysroot=");
95-
cc_path.push(&exec_root.join(sysroot_path));
91+
for compiler_env_var in &["CC", "CXX"] {
92+
if let Some(compiler_path) = env::var_os(compiler_env_var) {
93+
let mut compiler_path = exec_root.join(compiler_path);
94+
if let Some(sysroot_path) = env::var_os("SYSROOT") {
95+
compiler_path.push(" --sysroot=");
96+
compiler_path.push(&exec_root.join(sysroot_path));
97+
}
98+
command.env(compiler_env_var, compiler_path);
9699
}
97-
command.env("CC", cc_path);
98100
}
99101

100102
if let Some(ar_path) = env::var_os("AR") {

0 commit comments

Comments
 (0)