Skip to content

Commit

Permalink
Fix cargo_build_script breakage when SYSROOT is specified (#976)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
scentini committed Oct 15, 2021
1 parent 89d207b commit 6f79458
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cargo/cargo_build_script_runner/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 6f79458

Please sign in to comment.