Skip to content

Commit cacd0f6

Browse files
author
Shikhar Bhushan
committed
Revert "Absolutify CXX as well as CC (bazelbuild#969)"
This reverts commit b3e26e0.
1 parent 23a4631 commit cacd0f6

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

cargo/cargo_build_script_runner/bin.rs

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

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).into_os_string();
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);
91+
if let Some(cc_path) = env::var_os("CC") {
92+
let mut cc_path = exec_root.join(cc_path).into_os_string();
93+
if let Some(sysroot_path) = env::var_os("SYSROOT") {
94+
cc_path.push(" --sysroot=");
95+
cc_path.push(&exec_root.join(sysroot_path));
9996
}
97+
command.env("CC", cc_path);
10098
}
10199

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

test/cargo_build_script/build.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,4 @@ fn main() {
44
"cargo:rustc-env=TOOL_PATH={}",
55
std::env::var("TOOL").unwrap()
66
);
7-
8-
// Assert that the CC and CXX env vars existed and were executable.
9-
// We don't assert what happens when they're executed (in particular, we don't check for a
10-
// non-zero exit code), but this asserts that it's an existing file which is executable.
11-
//
12-
// Unfortunately we need to shlex the path, because we add a `--sysroot=...` arg to the env var.
13-
for env_var in &["CC", "CXX"] {
14-
let v = std::env::var(env_var)
15-
.unwrap_or_else(|err| panic!("Error getting {}: {}", env_var, err));
16-
let (path, args) = if let Some(index) = v.find("--sysroot") {
17-
let (path, args) = v.split_at(index);
18-
(path, Some(args))
19-
} else {
20-
(v.as_str(), None)
21-
};
22-
std::process::Command::new(path)
23-
.args(args.into_iter())
24-
.status()
25-
.unwrap();
26-
}
277
}

0 commit comments

Comments
 (0)