Message ID | 20240610154422.2013777-1-stefan-koch@siemens.com |
---|---|
State | Accepted, archived |
Headers | show |
Series | [v3] linux-custom: Speedup build of target specific linux-kbuild package | expand |
On Mon, 2024-06-10 at 17:44 +0200, Stefan Koch wrote: > Avoids time expensive QEMU-emulated merging of kernel config by using > the existing kernel config for the target specific linux-kbuild. > The host specific linux-kbuild package > uses the existing kernel config, too. > > Using DEPENDS instead of RDEPENDS ensures creation of > kernel (including config) before build of > target and host specific linux-kbuild packages. > > Signed-off-by: Stefan Koch <stefan-koch@siemens.com> > --- > .../linux/files/debian/isar/configure.tmpl | 22 +++++++++++++++-- > -- > meta/recipes-kernel/linux/linux-custom.inc | 11 +++++++--- > 2 files changed, 26 insertions(+), 7 deletions(-) > > diff --git a/meta/recipes- > kernel/linux/files/debian/isar/configure.tmpl b/meta/recipes- > kernel/linux/files/debian/isar/configure.tmpl > index 389c9a85..73f554ed 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > @@ -10,10 +10,24 @@ do_configure() { > # Trace what we do here > set -x > > - # Process kernel config target and fragments > - ${MAKE} O=${KERNEL_BUILD_DIR} ${KERNEL_CONFIG_TARGET} > - ./scripts/kconfig/merge_config.sh -O ${KERNEL_BUILD_DIR}/ \ > - ${KERNEL_BUILD_DIR}/.config ${KERNEL_CONFIG_FRAGMENTS} > + kernelconfig="$(find /boot -maxdepth 1 -name "config-${PV}*" - > print -quit)" > + if echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild" && \ > + ! echo "${DEB_BUILD_PROFILES}" | grep -q "kernel" && \ > + [ -e "${kernelconfig}" ]; then > + # Prefer existing kernel config > + # So, very expensive QEMU-emulated merge_config.sh > + # can be skipped for target specific linux-kbuild package > + # The host specific linux-kbuild package > + # uses the existing kernel config, too. > + mkdir -p ${KERNEL_BUILD_DIR} > + cp "${kernelconfig}" ${KERNEL_BUILD_DIR}/.config > + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig > + else > + # Process kernel config target and fragments > + ${MAKE} O=${KERNEL_BUILD_DIR} ${KERNEL_CONFIG_TARGET} > + ./scripts/kconfig/merge_config.sh -O ${KERNEL_BUILD_DIR}/ \ > + ${KERNEL_BUILD_DIR}/.config ${KERNEL_CONFIG_FRAGMENTS} > + fi > > # Stop tracing > set +x > diff --git a/meta/recipes-kernel/linux/linux-custom.inc > b/meta/recipes-kernel/linux/linux-custom.inc > index 647f09dd..6aa70fd3 100644 > --- a/meta/recipes-kernel/linux/linux-custom.inc > +++ b/meta/recipes-kernel/linux/linux-custom.inc > @@ -25,6 +25,7 @@ KBUILD_DEPENDS ?= "build-essential:native, \ > flex, \ > git, \ > kmod, \ > + linux-image- > ${KERNEL_NAME_PROVIDED}:${DISTRO_ARCH} <kbuild !kernel>, \ > rsync," > > KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ > @@ -112,7 +113,7 @@ BUILD_PROFILES = "kernel kbuild" > BBCLASSEXTEND:append:cross-profile = " kbuildtarget" > > # When cross-profile is active: > -# build only kernel with the default variant of the recipe > +# build only kernel (including config) with the default variant of > the recipe > BUILD_PROFILES:cross-profile = "kernel" > > # -native: kbuild package for host > @@ -122,14 +123,18 @@ RECIPE_PROVIDES:class-native = " \ > linux-kbuild-${KERNEL_NAME_PROVIDED}" > # Use pseudo target to pull in the base variant of the recipe. > # Will be auto-extended with -native by multiarch.bbclass. > -RDEPENDS:class-native += "${BPN}-pseudo" > +# Using DEPENDS instead of RDEPENDS to ensure creation of kernel > including > +# pregenerated kernel config before host specific linux-kbuild > package build > +DEPENDS:class-native += "${BPN}-pseudo" > > # -kbuildtarget: kbuild package for target, enforcing non-cross- > build > BUILD_PROFILES:class-kbuildtarget = "kbuild" > RECIPE_PROVIDES:class-kbuildtarget = " \ > linux-headers-${KERNEL_NAME_PROVIDED} \ > linux-kbuild-${KERNEL_NAME_PROVIDED}" > -RDEPENDS:class-kbuildtarget = "${BPN}" > +# Using DEPENDS instead of RDEPENDS to ensure creation of kernel > including > +# pregenerated kernel config before target specific linux-kbuild > package build > +DEPENDS:class-kbuildtarget = "${BPN}" > ISAR_CROSS_COMPILE:class-kbuildtarget = "0" > > # Make bitbake know we will be producing linux-image and linux- > headers packages Applied to next, thanks.
diff --git a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl index 389c9a85..73f554ed 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl @@ -10,10 +10,24 @@ do_configure() { # Trace what we do here set -x - # Process kernel config target and fragments - ${MAKE} O=${KERNEL_BUILD_DIR} ${KERNEL_CONFIG_TARGET} - ./scripts/kconfig/merge_config.sh -O ${KERNEL_BUILD_DIR}/ \ - ${KERNEL_BUILD_DIR}/.config ${KERNEL_CONFIG_FRAGMENTS} + kernelconfig="$(find /boot -maxdepth 1 -name "config-${PV}*" -print -quit)" + if echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild" && \ + ! echo "${DEB_BUILD_PROFILES}" | grep -q "kernel" && \ + [ -e "${kernelconfig}" ]; then + # Prefer existing kernel config + # So, very expensive QEMU-emulated merge_config.sh + # can be skipped for target specific linux-kbuild package + # The host specific linux-kbuild package + # uses the existing kernel config, too. + mkdir -p ${KERNEL_BUILD_DIR} + cp "${kernelconfig}" ${KERNEL_BUILD_DIR}/.config + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig + else + # Process kernel config target and fragments + ${MAKE} O=${KERNEL_BUILD_DIR} ${KERNEL_CONFIG_TARGET} + ./scripts/kconfig/merge_config.sh -O ${KERNEL_BUILD_DIR}/ \ + ${KERNEL_BUILD_DIR}/.config ${KERNEL_CONFIG_FRAGMENTS} + fi # Stop tracing set +x diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc index 647f09dd..6aa70fd3 100644 --- a/meta/recipes-kernel/linux/linux-custom.inc +++ b/meta/recipes-kernel/linux/linux-custom.inc @@ -25,6 +25,7 @@ KBUILD_DEPENDS ?= "build-essential:native, \ flex, \ git, \ kmod, \ + linux-image-${KERNEL_NAME_PROVIDED}:${DISTRO_ARCH} <kbuild !kernel>, \ rsync," KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ @@ -112,7 +113,7 @@ BUILD_PROFILES = "kernel kbuild" BBCLASSEXTEND:append:cross-profile = " kbuildtarget" # When cross-profile is active: -# build only kernel with the default variant of the recipe +# build only kernel (including config) with the default variant of the recipe BUILD_PROFILES:cross-profile = "kernel" # -native: kbuild package for host @@ -122,14 +123,18 @@ RECIPE_PROVIDES:class-native = " \ linux-kbuild-${KERNEL_NAME_PROVIDED}" # Use pseudo target to pull in the base variant of the recipe. # Will be auto-extended with -native by multiarch.bbclass. -RDEPENDS:class-native += "${BPN}-pseudo" +# Using DEPENDS instead of RDEPENDS to ensure creation of kernel including +# pregenerated kernel config before host specific linux-kbuild package build +DEPENDS:class-native += "${BPN}-pseudo" # -kbuildtarget: kbuild package for target, enforcing non-cross-build BUILD_PROFILES:class-kbuildtarget = "kbuild" RECIPE_PROVIDES:class-kbuildtarget = " \ linux-headers-${KERNEL_NAME_PROVIDED} \ linux-kbuild-${KERNEL_NAME_PROVIDED}" -RDEPENDS:class-kbuildtarget = "${BPN}" +# Using DEPENDS instead of RDEPENDS to ensure creation of kernel including +# pregenerated kernel config before target specific linux-kbuild package build +DEPENDS:class-kbuildtarget = "${BPN}" ISAR_CROSS_COMPILE:class-kbuildtarget = "0" # Make bitbake know we will be producing linux-image and linux-headers packages
Avoids time expensive QEMU-emulated merging of kernel config by using the existing kernel config for the target specific linux-kbuild. The host specific linux-kbuild package uses the existing kernel config, too. Using DEPENDS instead of RDEPENDS ensures creation of kernel (including config) before build of target and host specific linux-kbuild packages. Signed-off-by: Stefan Koch <stefan-koch@siemens.com> --- .../linux/files/debian/isar/configure.tmpl | 22 +++++++++++++++---- meta/recipes-kernel/linux/linux-custom.inc | 11 +++++++--- 2 files changed, 26 insertions(+), 7 deletions(-)