mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-18 11:44:07 +00:00
69cf5181c3
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)
87 lines
1.8 KiB
Bash
87 lines
1.8 KiB
Bash
ninjaBuildPhase() {
|
|
runHook preBuild
|
|
|
|
local buildCores=1
|
|
|
|
# Parallel building is enabled by default.
|
|
if [ "${enableParallelBuilding-1}" ]; then
|
|
buildCores="$NIX_BUILD_CORES"
|
|
fi
|
|
|
|
local flagsArray=(
|
|
-j$buildCores
|
|
$ninjaFlags "${ninjaFlagsArray[@]}"
|
|
)
|
|
|
|
echoCmd 'build flags' "${flagsArray[@]}"
|
|
TERM=dumb ninja "${flagsArray[@]}"
|
|
|
|
runHook postBuild
|
|
}
|
|
|
|
ninjaCheckPhase() {
|
|
runHook preCheck
|
|
|
|
if [ -z "${checkTarget:-}" ]; then
|
|
if ninja -t query test >/dev/null 2>&1; then
|
|
checkTarget=test
|
|
fi
|
|
fi
|
|
|
|
if [ -z "${checkTarget:-}" ]; then
|
|
echo "no test target found in ninja, doing nothing"
|
|
else
|
|
local buildCores=1
|
|
|
|
if [ "${enableParallelChecking-1}" ]; then
|
|
buildCores="$NIX_BUILD_CORES"
|
|
fi
|
|
|
|
local flagsArray=(
|
|
-j$buildCores
|
|
$ninjaFlags "${ninjaFlagsArray[@]}"
|
|
$checkTarget
|
|
)
|
|
|
|
echoCmd 'check flags' "${flagsArray[@]}"
|
|
TERM=dumb ninja "${flagsArray[@]}"
|
|
fi
|
|
|
|
runHook postCheck
|
|
}
|
|
|
|
ninjaInstallPhase() {
|
|
runHook preInstall
|
|
|
|
local buildCores=1
|
|
|
|
# Parallel building is enabled by default.
|
|
if [ "${enableParallelInstalling-1}" ]; then
|
|
buildCores="$NIX_BUILD_CORES"
|
|
fi
|
|
|
|
# shellcheck disable=SC2086
|
|
local flagsArray=(
|
|
-j$buildCores
|
|
$ninjaFlags "${ninjaFlagsArray[@]}"
|
|
${installTargets:-install}
|
|
)
|
|
|
|
echoCmd 'install flags' "${flagsArray[@]}"
|
|
TERM=dumb ninja "${flagsArray[@]}"
|
|
|
|
runHook postInstall
|
|
}
|
|
|
|
if [ -z "${dontUseNinjaBuild-}" -a -z "${buildPhase-}" ]; then
|
|
buildPhase=ninjaBuildPhase
|
|
fi
|
|
|
|
if [ -z "${dontUseNinjaCheck-}" -a -z "${checkPhase-}" ]; then
|
|
checkPhase=ninjaCheckPhase
|
|
fi
|
|
|
|
if [ -z "${dontUseNinjaInstall-}" -a -z "${installPhase-}" ]; then
|
|
installPhase=ninjaInstallPhase
|
|
fi
|