Skip to content

Warn on invalid jobserver file descriptors#16843

Merged
weihanglo merged 2 commits intorust-lang:masterfrom
arlosi:jobserver
Apr 7, 2026
Merged

Warn on invalid jobserver file descriptors#16843
weihanglo merged 2 commits intorust-lang:masterfrom
arlosi:jobserver

Conversation

@arlosi
Copy link
Copy Markdown
Contributor

@arlosi arlosi commented Apr 6, 2026

What does this PR try to resolve?

Cargo will currently load a jobserver from file descriptors if MAKEFLAGS, MFLAGS, RUST_MAKEFLAGS environment variables contain --jobserver-auth=N,N.

The jobserver crate provides a method to attempt to validate whether these descriptors are actually pipes, which cargo was not using. This change enables the validation, and emits a warning if the file descriptors appear to be incorrect.

This helps avoid hard-to-debug problems where cargo interprets FDs as jobserver FDs, when they are actually not. This can occur when a process in between make and cargo forwards the environment variables, but not the FDs.

How to test and review this PR?

This change is based on what rustc does.

First commit shows issue,
Second commit contains fix with warning showing.

r? @weihanglo

@rustbot rustbot added A-configuration Area: cargo config files and env vars S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 6, 2026
Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows jobserver crate uses named semaphore so the error message is a bit different:

[99](https://github.com/rust-lang/cargo/actions/runs/24051846505/job/70149149235?pr=16843#step:15:5100)
---- expected: tests\testsuite\jobserver.rs:424:27
++++ actual:   stderr
Warning: [0m      - [WARNING] failed to connect to jobserver from environment variable `MAKEFLAGS="--jobserver-auth=200001,200002"`: cannot open file descriptor 200001 from the jobserver environment variable value: [..]
        1 + [WARNING] failed to connect to jobserver from environment variable `MAKEFLAGS="--jobserver-auth=200001,200002"`: cannot open path or name 200001,200002 from the jobserver environment variable value: [NOT_FOUND]
   2    2 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   3    3 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

View changes since this review

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weihanglo weihanglo enabled auto-merge April 6, 2026 23:21
@weihanglo weihanglo added this pull request to the merge queue Apr 7, 2026
Merged via the queue into rust-lang:master with commit 1ad92f7 Apr 7, 2026
56 of 58 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 7, 2026
@arlosi arlosi deleted the jobserver branch April 7, 2026 02:52
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Apr 8, 2026
Cargo submodule update

11 commits in a357df4c26fc14514e66aae2a269456b5545c7db..101549dddbd2b08e806f50154e3aa4cb3374cc21
2026-04-03 16:47:15 +0000 to 2026-04-08 12:51:20 +0000
- Never include use extra-filename in build scripts (rust-lang/cargo#16855)
- fix(toml): Force script edition warnings on quiet  (rust-lang/cargo#16848)
- GitHub fast path uses `http_async` (rust-lang/cargo#16847)
- feat(manifest): allow git dependency alongside alternate registry (rust-lang/cargo#16810)
- fix(auth): add auth scheme hint to token rejected error for alt registries (rust-lang/cargo#16794)
- Warn on invalid jobserver file descriptors (rust-lang/cargo#16843)
- docs(unstable): List the minimum required MSRV for 'public' field (rust-lang/cargo#16841)
- feat(lints): Emit unused_dependencies lint (rust-lang/cargo#16600)
- fix(tree): clarify error message when `-i` is used without a package name (rust-lang/cargo#16818)
- fix: Typo in target.<cfg>.linker (rust-lang/cargo#16839)
- Send Content-Type header with cargo publish requests (rust-lang/cargo#16832)

r? ghost
@rustbot rustbot added this to the 1.96.0 milestone Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-configuration Area: cargo config files and env vars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants