Auto merge of #12951 - belovdv:jobserver-preserver-fd, r=weihanglo

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 https://github.com/rust-lang/rust/pull/113730.

It should be enough to have tests in rustc. It seems to be good to have more centralized way to pass jobserver.
This commit is contained in:
bors 2023-11-10 13:53:09 +00:00
commit 57880c222b
1 changed files with 5 additions and 0 deletions

View File

@ -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()?);
}