Skip to content

Commit

Permalink
Auto merge of #12951 - belovdv:jobserver-preserver-fd, r=weihanglo
Browse files Browse the repository at this point in the history
fix: preserve jobserver file descriptors on rustc invocation in `fix_exec_rustc`

Similar to #12447

Command `cargo fix` invokes `cargo rustc`. It sends environment variable which points to closed file descriptors.

This PR makes cargo compatible with rust-lang/rust#113730.

It should be enough to have tests in rustc. It seems to be good to have more centralized way to pass jobserver.
  • Loading branch information
bors committed Nov 10, 2023
2 parents 19a0404 + e84fd16 commit 57880c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ pub fn fix_exec_rustc(config: &Config, lock_addr: &str) -> CargoResult<()> {
// things like colored output to work correctly.
rustc.arg(arg);
}
// Removes `FD_CLOEXEC` set by `jobserver::Client` to pass jobserver
// as environment variables specify.
if let Some(client) = config.jobserver_from_env() {
rustc.inherit_jobserver(client);
}
debug!("calling rustc to display remaining diagnostics: {rustc}");
exit_with(rustc.status()?);
}
Expand Down

0 comments on commit 57880c2

Please sign in to comment.