nixpkgs/pkgs/tools/package-management/nix/num-cores.patch
Marc Weber 7db7857d15 nix num-cores.patch
pass MAX_PARALLELIZATION and TARGET_LOAD to the builder. See comments

svn path=/nixpkgs/branches/stdenv-updates/; revision=22284
2010-06-15 19:00:54 +00:00

32 lines
1 KiB
Diff

commit b77e3721f19b4e5084125eb8dc7186117004dd4b
Author: Marc Weber <marco-oweber@gmx.de>
Date: Sun Jun 13 23:53:46 2010 +0200
generic/setup.sh: add -j (+1) -l (*2) options to make depending on $NUM_CORES
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index a9f4d4d..685c0ec 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -79,9 +79,19 @@ cmd(){
}
runMake(){
- cmd make ${makefile:+-f $makefile} "$@"
+ local optout=NO_PARALLEL_BUILD_${curPhase}
+ [ -n "${!optout}" ] || \
+ local j="$makeFlagsParallelBuild"
+ cmd make ${makefile:+-f $makefile} "$@" $j
}
+######################################################################
+# parallel builds: opt-out
+# - in a phase: set NO_PARALLEL_BUILD_${PHASE_NAME}
+# - for this build: pass NUM_CORES=1 to the builder
+if [ "$NUM_CORES" -gt 1 ]; then
+ makeFlagsParallelBuild="-j $(( $NUM_CORES + 1 )) -l $(( 2 * $NUM_CORES ))"
+fi
######################################################################
# Initialisation.