Created
February 25, 2015 19:15
-
-
Save msullivan/d33029fcda6889b7d097 to your computer and use it in GitHub Desktop.
Wrapper script to make commands that look like linking run in serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 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++' | |
LOCKFILE="$1" | |
shift | |
for I in "$@"; do | |
if [ $I = "-c" ]; then | |
# Not a linker command, just run it | |
exec "$@" | |
fi | |
done | |
# 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