Created
February 25, 2015 18:37
-
-
Save msullivan/3290e688670c54f8d1a2 to your computer and use it in GitHub Desktop.
Hacky wrapper to run make in parallel until linking starts
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/bash | |
# Terrible hack to run a build in parallel until it starts linking | |
# things and then switch to running it in serial to cut down on memory usage. | |
# This could be better and more robust in a *lot* of ways. | |
# I use this for building llvm/clang. | |
# The first argument gets passed to the initial make that runs until | |
# linking starts and should be -j4 or whatever. The rest of the | |
# arguments get passed to both makes. | |
PARALLEL="$1" | |
shift | |
(while ! pgrep -u `whoami` ld.bfd.real; do sleep 1; done; | |
killall make ld.bfd.real) & | |
trap 'kill %1' INT QUIT TERM EXIT | |
make "$PARALLEL" "$@" | |
# Sleep to give the kill a chance to finish so the new make doesn't | |
# get killed. Evade, don't solve, concurrency problems. | |
sleep 2 | |
make "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment