linux: build dtbs in parallel (#106846)

linux: build DTBs in buildPhase, install with everything else

This improves build speed, especially on machines with lots of cores
such as the aarch64 community box and hydra builders.
This commit is contained in:
Linus Heckemann 2021-10-14 19:41:32 +02:00 committed by GitHub
parent 4f292fe210
commit dd5f07afca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,6 +56,7 @@ let
# Dependencies that are required to build kernel modules
moduleBuildDependencies = optional (lib.versionAtLeast version "4.14") libelf;
installkernel = writeTextFile { name = "installkernel"; executable=true; text = ''
#!${stdenv.shell} -e
mkdir -p $4
@ -88,6 +89,8 @@ let
isModular = config.isYes "MODULES";
buildDTBs = kernelConf.DTB or false;
installsFirmware = (config.isEnabled "FW_LOADER") &&
(isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")) &&
(lib.versionOlder version "4.14");
@ -175,15 +178,16 @@ let
"KBUILD_BUILD_VERSION=1-NixOS"
kernelConf.target
"vmlinux" # for "perf" and things like that
]
++ optional isModular "modules"
] ++ optional isModular "modules"
++ optional buildDTBs "dtbs"
++ extraMakeFlags;
installFlags = [
"INSTALLKERNEL=${installkernel}"
"INSTALL_PATH=$(out)"
] ++ (optional isModular "INSTALL_MOD_PATH=$(out)")
++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";
++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware"
++ optionals buildDTBs ["dtbs_install" "INSTALL_DTBS_PATH=$(out)/dtbs"];
preInstall = ''
installFlagsArray+=("-j$NIX_BUILD_CORES")
@ -199,9 +203,7 @@ let
postInstall = (optionalString installsFirmware ''
mkdir -p $out/lib/firmware
'') + (if (kernelConf.DTB or false) then ''
make $makeFlags "''${makeFlagsArray[@]}" dtbs dtbs_install INSTALL_DTBS_PATH=$out/dtbs
'' else "") + (if isModular then ''
'') + (if isModular then ''
mkdir -p $dev
cp vmlinux $dev/
if [ -z "''${dontStrip-}" ]; then