Author: simons
Date: Sun Aug  8 18:51:42 2010
New Revision: 23042
URL: https://svn.nixos.org/websvn/nix/?rev=23042&sc=1

Log:
Enable parallel building of gcc, glibc, gmp, mpfr, ncurses, coreutils, perl, 
python, git, and qt4.

If a build expressions has set "enableParallelBuilding = true", then the
generic builder may utilize more than one CPU core to build that particular
expression. This feature works out of the box for GNU Make. Expressions that
use other build drivers like Boost.Jam or SCons have to specify appropriate
flags such as "-j${NIX_BUILD_CORES}" themselves.

Modified:
   
nixpkgs/trunk/pkgs/applications/version-management/git-and-tools/git/default.nix
   nixpkgs/trunk/pkgs/development/compilers/gcc-4.3/default.nix
   nixpkgs/trunk/pkgs/development/compilers/gcc-4.4/default.nix
   nixpkgs/trunk/pkgs/development/compilers/gcc-4.5/default.nix
   nixpkgs/trunk/pkgs/development/compilers/gcc-apple/default.nix
   nixpkgs/trunk/pkgs/development/compilers/gcc-apple64/default.nix
   nixpkgs/trunk/pkgs/development/interpreters/perl-5.10/default.nix
   nixpkgs/trunk/pkgs/development/interpreters/python/2.6/default.nix
   nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder.sh
   nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder2.sh
   nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/common.nix
   nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/builder.sh
   nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/default.nix
   nixpkgs/trunk/pkgs/development/libraries/gmp/4.3.1.nix
   nixpkgs/trunk/pkgs/development/libraries/gmp/default.nix
   nixpkgs/trunk/pkgs/development/libraries/mpfr/default.nix
   nixpkgs/trunk/pkgs/development/libraries/ncurses/default.nix
   nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.5/default.nix
   nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.6/default.nix
   nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.7/default.nix
   nixpkgs/trunk/pkgs/stdenv/generic/setup.sh
   nixpkgs/trunk/pkgs/tools/misc/coreutils/default.nix

Modified: 
nixpkgs/trunk/pkgs/applications/version-management/git-and-tools/git/default.nix
==============================================================================
--- 
nixpkgs/trunk/pkgs/applications/version-management/git-and-tools/git/default.nix
    Sun Aug  8 18:50:10 2010        (r23041)
+++ 
nixpkgs/trunk/pkgs/applications/version-management/git-and-tools/git/default.nix
    Sun Aug  8 18:51:42 2010        (r23042)
@@ -74,7 +74,7 @@
        '')
 
    + ''# Install man pages and Info manual
-       make PERL_PATH="${perl}/bin/perl" cmd-list.made install install-info \
+       make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES 
PERL_PATH="${perl}/bin/perl" cmd-list.made install install-info \
          -C Documentation ''
 
    + (if guiSupport then ''
@@ -116,6 +116,8 @@
 
      '';
 
+  enableParallelBuilding = true;
+
   meta = {
     license = "GPLv2";
     homepage = http://git-scm.com/;

Modified: nixpkgs/trunk/pkgs/development/compilers/gcc-4.3/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/compilers/gcc-4.3/default.nix        Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/compilers/gcc-4.3/default.nix        Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -127,6 +127,8 @@
   passthru = { inherit langC langCC langFortran langVhdl langTreelang
       enableMultilib; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = "http://gcc.gnu.org/";;
     license = "GPL/LGPL";

Modified: nixpkgs/trunk/pkgs/development/compilers/gcc-4.4/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/compilers/gcc-4.4/default.nix        Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/compilers/gcc-4.4/default.nix        Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -201,6 +201,8 @@
   passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
       enableMultilib version; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://gcc.gnu.org/;
     license = "GPLv3+";  # runtime support libraries are typically LGPLv3+

Modified: nixpkgs/trunk/pkgs/development/compilers/gcc-4.5/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/compilers/gcc-4.5/default.nix        Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/compilers/gcc-4.5/default.nix        Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -289,6 +289,8 @@
   passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
       enableMultilib version; };
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://gcc.gnu.org/;
     license = "GPLv3+";  # runtime support libraries are typically LGPLv3+

Modified: nixpkgs/trunk/pkgs/development/compilers/gcc-apple/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/compilers/gcc-apple/default.nix      Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/compilers/gcc-apple/default.nix      Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -21,6 +21,8 @@
       sha256 = 
"a7d8041e50e110f5a503e188a05cb217f0c99c51f248a0a1387cc07a0b6f167f";
     }) ;
 
+  enableParallelBuilding = true;
+
   sourceRoot = "gcc_42-5574/";
   patches =
     [./pass-cxxcpp.patch ./debug_list.patch]

Modified: nixpkgs/trunk/pkgs/development/compilers/gcc-apple64/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/compilers/gcc-apple64/default.nix    Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/compilers/gcc-apple64/default.nix    Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -21,6 +21,8 @@
       sha256 = "1fy6j41rhxdsm19sib9wygjl5l54g8pm13c6y5x13f40mavw1mma";
     }) ;
 
+  enableParallelBuilding = true;
+
   libstdcxx = "libstdcxx-39";
   sourceRoot = "gcc-5646/";
   patches =

Modified: nixpkgs/trunk/pkgs/development/interpreters/perl-5.10/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/interpreters/perl-5.10/default.nix   Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/interpreters/perl-5.10/default.nix   Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -39,6 +39,8 @@
 
   dontAddPrefix = true;
 
+  enableParallelBuilding = true;
+
   preConfigure =
     ''
       configureFlags="$configureFlags -Dprefix=$out 
-Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"

Modified: nixpkgs/trunk/pkgs/development/interpreters/python/2.6/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/interpreters/python/2.6/default.nix  Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/interpreters/python/2.6/default.nix  Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -88,6 +88,8 @@
     libPrefix = "python${majorVersion}";
   };
 
+  enableParallelBuilding = true;
+
   meta = {
     platforms = stdenv.lib.platforms.all;
   };

Modified: nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder.sh
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder.sh      Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder.sh      Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -17,7 +17,7 @@
 
 postInstall() {
     if test -n "$installLocales"; then
-        make localedata/install-locales
+        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} 
localedata/install-locales
     fi
     
     test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache

Modified: nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder2.sh
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder2.sh     Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/builder2.sh     Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -20,7 +20,7 @@
 
 postInstall() {
     if test -n "$installLocales"; then
-        make localedata/install-locales
+        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} 
localedata/install-locales
     fi
     
     test -f $out/etc/ld.so.cache && rm $out/etc/ld.so.cache

Modified: nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/common.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/common.nix      Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/glibc-2.11/common.nix      Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -30,6 +30,8 @@
 
   inherit (stdenv) is64bit;
 
+  enableParallelBuilding = true;
+
   patches =
     stdenv.lib.optional (fetchgit == null)
     /* Fix for NIXPKGS-79: when doing host name lookups, when

Modified: nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/builder.sh
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/builder.sh       Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/builder.sh       Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -38,7 +38,7 @@
 
 postInstall() {
     if test -n "$installLocales"; then
-        make localedata/install-locales
+        make -j${NIX_BUILD_CORES:-1} -l${NIX_BUILD_CORES:-1} 
localedata/install-locales
     fi
     rm $out/etc/ld.so.cache
     (cd $out/include && ln -s $kernelHeaders/include/* .) || exit 1

Modified: nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/default.nix      Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/glibc-2.5/default.nix      Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -30,6 +30,8 @@
   # the symbol __i686.get_pc_thunk.dx to be mangled.
   NIX_CFLAGS_COMPILE = "-U__i686";
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.gnu.org/software/libc/;
     description = "The GNU C Library";

Modified: nixpkgs/trunk/pkgs/development/libraries/gmp/4.3.1.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/gmp/4.3.1.nix      Sun Aug  8 
18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/gmp/4.3.1.nix      Sun Aug  8 
18:51:42 2010        (r23042)
@@ -16,6 +16,8 @@
 
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     description = "A free library for arbitrary precision arithmetic, 
operating on signed integers, rational numbers, and floating point numbers";
     homepage = http://gmplib.org/;

Modified: nixpkgs/trunk/pkgs/development/libraries/gmp/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/gmp/default.nix    Sun Aug  8 
18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/gmp/default.nix    Sun Aug  8 
18:51:42 2010        (r23042)
@@ -16,6 +16,8 @@
 
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     description = "A free library for arbitrary precision arithmetic, 
operating on signed integers, rational numbers, and floating point numbers";
     homepage = http://gmplib.org/;

Modified: nixpkgs/trunk/pkgs/development/libraries/mpfr/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/mpfr/default.nix   Sun Aug  8 
18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/mpfr/default.nix   Sun Aug  8 
18:51:42 2010        (r23042)
@@ -12,6 +12,8 @@
 
   doCheck = true;
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.mpfr.org/;
     description = "GNU MPFR, a library for multiple-precision floating-point 
arithmetic";

Modified: nixpkgs/trunk/pkgs/development/libraries/ncurses/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/ncurses/default.nix        Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/ncurses/default.nix        Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -14,7 +14,9 @@
   '';
 
   selfBuildNativeInput = true;
-    
+
+  enableParallelBuilding = true;
+
   preBuild = ''sed -e "s...@\([[:space:]]\)sh @\1''${SHELL} @" -i */Makefile 
Makefile'';
 
   # When building a wide-character (Unicode) build, create backward

Modified: nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.5/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.5/default.nix     Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.5/default.nix     Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -74,6 +74,8 @@
     ${if keepDocumentation == false then "rm -rf $out/doc" else ""}
   '';
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = 
http://www.qtsoftware.com/downloads/opensource/appdev/linux-x11-cpp;
     description = "A cross-platform application framework for C++";

Modified: nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.6/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.6/default.nix     Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.6/default.nix     Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -89,6 +89,8 @@
 
   postInstall = if useDocs then "rm -rf $out/share/doc/${name}/{html,src}" 
else "";
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://qt.nokia.com/products;
     description = "A cross-platform application framework for C++";

Modified: nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.7/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.7/default.nix     Sun Aug 
 8 18:50:10 2010        (r23041)
+++ nixpkgs/trunk/pkgs/development/libraries/qt-4.x/4.7/default.nix     Sun Aug 
 8 18:51:42 2010        (r23042)
@@ -99,6 +99,8 @@
 
   postInstall = if useDocs then "rm -rf $out/share/doc/${name}/{html,src}" 
else "";
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     homepage = http://qt.nokia.com/products;
     description = "A cross-platform application framework for C++";

Modified: nixpkgs/trunk/pkgs/stdenv/generic/setup.sh
==============================================================================
--- nixpkgs/trunk/pkgs/stdenv/generic/setup.sh  Sun Aug  8 18:50:10 2010        
(r23041)
+++ nixpkgs/trunk/pkgs/stdenv/generic/setup.sh  Sun Aug  8 18:51:42 2010        
(r23042)
@@ -269,6 +269,23 @@
 export NIX_INDENT_MAKE=1
 
 
+# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
+# means that we're supposed to try and auto-detect the number of
+# available CPU cores at run-time.
+
+if test -z "${NIX_BUILD_CORES:-}"; then
+  NIX_BUILD_CORES="1"
+elif test "$NIX_BUILD_CORES" -le 0; then
+  NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
+  if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
+    :
+  else
+    NIX_BUILD_CORES="1"
+  fi
+fi
+export NIX_BUILD_CORES
+
+
 ######################################################################
 # Misc. helper functions.
 
@@ -603,6 +620,7 @@
 
     echo "make flags: $makeFlags ${makeflagsarr...@]} $buildFlags 
${buildflagsarr...@]}"
     make ${makefile:+-f $makefile} \
+        ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
         $makeFlags "${makeflagsarr...@]}" \
         $buildFlags "${buildflagsarr...@]}"
 
@@ -615,6 +633,7 @@
 
     echo "check flags: $makeFlags ${makeflagsarr...@]} $checkFlags 
${checkflagsarr...@]}"
     make ${makefile:+-f $makefile} \
+        ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
         $makeFlags "${makeflagsarr...@]}" \
         $checkFlags "${checkflagsarr...@]}" ${checkTarget:-check}
 

Modified: nixpkgs/trunk/pkgs/tools/misc/coreutils/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/tools/misc/coreutils/default.nix Sun Aug  8 18:50:10 
2010        (r23041)
+++ nixpkgs/trunk/pkgs/tools/misc/coreutils/default.nix Sun Aug  8 18:51:42 
2010        (r23042)
@@ -24,6 +24,8 @@
   # and {Open,Free}BSD.
   doCheck = (stdenv ? glibc) && (cross == null);
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://www.gnu.org/software/coreutils/;
     description = "The basic file, shell and text manipulation utilities of 
the GNU operating system";
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to