stdenv/generic/setup.sh: enable parallel installs by default
The primary motivating example is openssl: Before the change full package build took 1m54s minutes. After the change full package build takes 59s. About a 2x speedup. The difference is visible because openssl builds hundreds of manpages spawning a perl process per manual in `install` phase. Such a workload is very easy to parallelize. Another example would be `autotools`+`libtool` based build system where install step requires relinking. The more binaries there are to relink the more gain it will be to do it in parallel. The change enables parallel installs by default only for buiilds that already have parallel builds enabled. There is a high chance those build systems already handle parallelism well but some packages will fail. Consistently propagated the enableParallelBuilding to: - cmake (enabled by default, similar to builds) - ninja (set parallelism explicitly, don't rely on default) - bmake (enable when requested) - scons (enable when requested) - meson (set parallelism explicitly, don't rely on default) - waf (set parallelism explicitly, don't rely on default) - qmake-4/5/6 (enable by default, similar to builds) - xorg (always enable, similar to builds)
This commit is contained in:
parent
203e1cb499
commit
69cf5181c3
@ -8,6 +8,11 @@ qmakeConfigurePhase() {
|
|||||||
echo "qmake4Hook: enabled parallel building"
|
echo "qmake4Hook: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "qmake: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ qmakeConfigurePhase() {
|
|||||||
echo "qmake: enabled parallel building"
|
echo "qmake: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "qmake: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,11 @@ qmakeConfigurePhase() {
|
|||||||
echo "qmake: enabled parallel building"
|
echo "qmake: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "qmake: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ bmakeInstallPhase() {
|
|||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
local flagsArray=(
|
local flagsArray=(
|
||||||
|
${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
|
||||||
SHELL=$SHELL
|
SHELL=$SHELL
|
||||||
# Old bash empty array hack
|
# Old bash empty array hack
|
||||||
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
||||||
|
@ -130,6 +130,11 @@ cmakeConfigurePhase() {
|
|||||||
echo "cmake: enabled parallel building"
|
echo "cmake: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "cmake: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ mesonConfigurePhase() {
|
|||||||
echo "meson: enabled parallel building"
|
echo "meson: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "meson: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,16 @@ ninjaCheckPhase() {
|
|||||||
ninjaInstallPhase() {
|
ninjaInstallPhase() {
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
|
local buildCores=1
|
||||||
|
|
||||||
|
# Parallel building is enabled by default.
|
||||||
|
if [ "${enableParallelInstalling-1}" ]; then
|
||||||
|
buildCores="$NIX_BUILD_CORES"
|
||||||
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
local flagsArray=(
|
local flagsArray=(
|
||||||
|
-j$buildCores
|
||||||
$ninjaFlags "${ninjaFlagsArray[@]}"
|
$ninjaFlags "${ninjaFlagsArray[@]}"
|
||||||
${installTargets:-install}
|
${installTargets:-install}
|
||||||
)
|
)
|
||||||
|
@ -33,6 +33,7 @@ sconsInstallPhase() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local flagsArray=(
|
local flagsArray=(
|
||||||
|
${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
|
||||||
$sconsFlags ${sconsFlagsArray[@]}
|
$sconsFlags ${sconsFlagsArray[@]}
|
||||||
$installFlags ${installFlagsArray[@]}
|
$installFlags ${installFlagsArray[@]}
|
||||||
${installTargets:-install}
|
${installTargets:-install}
|
||||||
|
@ -30,6 +30,11 @@ wafConfigurePhase() {
|
|||||||
echo "waf: enabled parallel building"
|
echo "waf: enabled parallel building"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! [[ -v enableParallelInstalling ]]; then
|
||||||
|
enableParallelInstalling=1
|
||||||
|
echo "waf: enabled parallel installing"
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +73,7 @@ wafInstallPhase() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local flagsArray=(
|
local flagsArray=(
|
||||||
|
${enableParallelInstalling:+-j ${NIX_BUILD_CORES}}
|
||||||
$wafFlags ${wafFlagsArray[@]}
|
$wafFlags ${wafFlagsArray[@]}
|
||||||
$installFlags ${installFlagsArray[@]}
|
$installFlags ${installFlagsArray[@]}
|
||||||
${installTargets:-install}
|
${installTargets:-install}
|
||||||
|
@ -37,5 +37,6 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
enableParallelBuilding=1
|
enableParallelBuilding=1
|
||||||
|
enableParallelInstalling=1
|
||||||
|
|
||||||
genericBuild
|
genericBuild
|
||||||
|
@ -433,6 +433,7 @@ else let
|
|||||||
} // lib.optionalAttrs (enableParallelBuilding) {
|
} // lib.optionalAttrs (enableParallelBuilding) {
|
||||||
inherit enableParallelBuilding;
|
inherit enableParallelBuilding;
|
||||||
enableParallelChecking = attrs.enableParallelChecking or true;
|
enableParallelChecking = attrs.enableParallelChecking or true;
|
||||||
|
enableParallelInstalling = attrs.enableParallelInstalling or true;
|
||||||
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != [] || stdenv.hostPlatform.isMusl) {
|
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != [] || stdenv.hostPlatform.isMusl) {
|
||||||
NIX_HARDENING_ENABLE = enabledHardeningOptions;
|
NIX_HARDENING_ENABLE = enabledHardeningOptions;
|
||||||
} // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch) {
|
} // lib.optionalAttrs (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform ? gcc.arch) {
|
||||||
|
@ -1376,6 +1376,7 @@ installPhase() {
|
|||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
local flagsArray=(
|
local flagsArray=(
|
||||||
|
${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
|
||||||
SHELL=$SHELL
|
SHELL=$SHELL
|
||||||
)
|
)
|
||||||
_accumFlagsArray makeFlags makeFlagsArray installFlags installFlagsArray
|
_accumFlagsArray makeFlags makeFlagsArray installFlags installFlagsArray
|
||||||
|
Loading…
Reference in New Issue
Block a user