From 6f79458dee68d691d6a5aee67b06a620bdf9293f Mon Sep 17 00:00:00 2001 From: scentini Date: Fri, 15 Oct 2021 13:06:32 +0200 Subject: [PATCH] Fix `cargo_build_script` breakage when `SYSROOT` is specified (#976) https://github.com/bazelbuild/rules_rust/pull/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. --- cargo/cargo_build_script_runner/bin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo/cargo_build_script_runner/bin.rs b/cargo/cargo_build_script_runner/bin.rs index 04d89a34d9..baee4ff724 100644 --- a/cargo/cargo_build_script_runner/bin.rs +++ b/cargo/cargo_build_script_runner/bin.rs @@ -89,7 +89,7 @@ fn run_buildrs() -> Result<(), String> { } if let Some(cc_path) = env::var_os("CC") { - let mut cc_path = exec_root.join(cc_path); + let mut cc_path = exec_root.join(cc_path).into_os_string(); if let Some(sysroot_path) = env::var_os("SYSROOT") { cc_path.push(" --sysroot="); cc_path.push(&exec_root.join(sysroot_path));