]> git.proxmox.com Git - cargo.git/commit
Auto merge of #4110 - alexcrichton:jobserver, r=matklad
authorbors <bors@rust-lang.org>
Fri, 2 Jun 2017 22:53:36 +0000 (22:53 +0000)
committerbors <bors@rust-lang.org>
Fri, 2 Jun 2017 22:53:36 +0000 (22:53 +0000)
commit8fb6e7c15788b6ec36a9735f551089cf89c12185
treefd3b7a0528354f500da27b4b5ec68c5540deeece
parent618a02926ae4f550f95608a01270c512f8a198e0
parentcbf25a9b0ae5ac6f5b6da96e645b7fa6a75dc245
Auto merge of #4110 - alexcrichton:jobserver, r=matklad

Add a GNU make jobserver implementation to Cargo

This commit adds a GNU make jobserver implementation to Cargo, both as a client
of existing jobservers and also a creator of new jobservers. The jobserver is
actually just an IPC semaphore which manifests itself as a pipe with N bytes
of tokens on Unix and a literal IPC semaphore on Windows. The rough protocol
is then if you want to run a job you read acquire the semaphore (read a byte on
Unix or wait on the semaphore on Windows) and then you release it when you're
done.

All the hairy details of the jobserver implementation are housed in the
`jobserver` crate on crates.io instead of Cargo. This should hopefully make it
much easier for the compiler to also share a jobserver implementation
eventually.

The main tricky bit here is that on Unix and Windows acquiring a jobserver token
will block the calling thread. We need to either way for a running job to exit
or to acquire a new token when we want to spawn a new job. To handle this the
current implementation spawns a helper thread that does the blocking and sends a
message back to Cargo when it receives a token. It's a little trickier with
shutting down this thread gracefully as well but more details can be found in
the `jobserver` crate.

Unfortunately crates are unlikely to see an immediate benefit of this once
implemented. Most crates are run with a manual `make -jN` and this overrides the
jobserver in the environment, creating a new jobserver in the sub-make. If the
`-jN` argument is removed, however, then `make` will share Cargo's jobserver and
properly limit parallelism.

Closes #1744
Cargo.lock