Skip to content

Commit a07a12a

Browse files
committed
Auto merge of #12447 - belovdv:jobserver-remove-env-var, r=weihanglo
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.
2 parents 211fd7e + 1e12538 commit a07a12a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cargo/core/compiler/build_context/target_info.rs

+6
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ impl TargetInfo {
185185
.args(&rustflags)
186186
.env_remove("RUSTC_LOG");
187187

188+
// Removes `FD_CLOEXEC` set by `jobserver::Client` to pass jobserver
189+
// as environment variables specify.
190+
if let Some(client) = config.jobserver_from_env() {
191+
process.inherit_jobserver(client);
192+
}
193+
188194
if let CompileKind::Target(target) = kind {
189195
process.arg("--target").arg(target.rustc_target());
190196
}

0 commit comments

Comments
 (0)