From dd5f07afca27571e567cd902c2e64409e4a485be Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Thu, 14 Oct 2021 19:41:32 +0200 Subject: [PATCH] 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. --- pkgs/os-specific/linux/kernel/manual-config.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 5ff9a8be7723..9c67df13d314 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -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