Skip to content

Commit 6f79458

Browse files
authored
Fix cargo_build_script breakage when SYSROOT is specified (#976)
#973 changed the type of `cc_path` from `std::ffi::OsString` to `std::path::PathBuf`, which breaks builds that specify `SYSROOT`. As `std::path::PathBuf::push(x)` replaces the current path when x is absolute, the [`cc_path.push(&exec_root.join(sysroot_path));`](https://github.com/bazelbuild/rules_rust/blob/89d207bae700497dc37b2a66a8f338b88c83ddaa/cargo/cargo_build_script_runner/bin.rs#L95) line ends up dropping everything that was previously added to `cc_path`. This PR fixes the issue.
1 parent 89d207b commit 6f79458

File tree

1 file changed

+1
-1
lines changed
  • cargo/cargo_build_script_runner

1 file changed

+1
-1
lines changed

cargo/cargo_build_script_runner/bin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn run_buildrs() -> Result<(), String> {
8989
}
9090

9191
if let Some(cc_path) = env::var_os("CC") {
92-
let mut cc_path = exec_root.join(cc_path);
92+
let mut cc_path = exec_root.join(cc_path).into_os_string();
9393
if let Some(sysroot_path) = env::var_os("SYSROOT") {
9494
cc_path.push(" --sysroot=");
9595
cc_path.push(&exec_root.join(sysroot_path));

0 commit comments

Comments
 (0)