Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2015 19:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Wrapper script to make commands that look like linking run in serial
# Run a command with a lock if it looks like it is a linker command: that is,
# if none of its arguments are -c.
# Then you can do a build where compilation is parallel but linking is serial
# by doing something like (for llvm/clang):
# make -j4 'CXX=lock-linking /tmp/llvm-build-lock clang++'
for I in "$@"; do
if [ $I = "-c" ]; then
# Not a linker command, just run it
exec "$@"
# Run the linker command under the lock
flock "$LOCKFILE" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment