Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GNU make jobserver implementation to Cargo #4110

Merged
merged 1 commit into from
Jun 2, 2017

Commits on Jun 2, 2017

  1. 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 rust-lang#1744
    alexcrichton committed Jun 2, 2017
    Configuration menu
    Copy the full SHA
    cbf25a9 View commit details
    Browse the repository at this point in the history