Skip to content

Commit

Permalink
Auto merge of #12447 - belovdv:jobserver-remove-env-var, r=weihanglo
Browse files Browse the repository at this point in the history
fix: preserve jobserver file descriptors on rustc invocation to get `TargetInfo`

Then cargo asks rustc for `TargetInfo`, cargo passes environment variables that describe jobserver file descriptors, but doesn't actually passed them, because `jobserver-rs` sets `FD_CLOEXEC` by default and expects users to explicitly call `Client::configure` to pass them further. Rustc respects make jobserver, so this causes error - env vars refers to nonexistent file descriptors, which is ignored now.

This PR makes cargo compatible with rust-lang/rust#113730, which attempts to catch such situations.
  • Loading branch information
bors committed Aug 8, 2023
2 parents 211fd7e + 1e12538 commit a07a12a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cargo/core/compiler/build_context/target_info.rs
Expand Up @@ -185,6 +185,12 @@ impl TargetInfo {
.args(&rustflags)
.env_remove("RUSTC_LOG");

// Removes `FD_CLOEXEC` set by `jobserver::Client` to pass jobserver
// as environment variables specify.
if let Some(client) = config.jobserver_from_env() {
process.inherit_jobserver(client);
}

if let CompileKind::Target(target) = kind {
process.arg("--target").arg(target.rustc_target());
}
Expand Down

0 comments on commit a07a12a

Please sign in to comment.