Message ID | 20240604153918.3788602-1-stefan-koch@siemens.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | linux-custom: Speedup build of target specific linux-kbuild package | expand |
On 04.06.24 17:39, Stefan Koch wrote: > Avoids time expensive QEMU-emulated merging of kernel config > by using a pregenerated kernel config for target specific linux-kbuild > Hmm, it's a bit heavier to install, but we already have the config packaged: in linux-image under /boot/config-*. Or is this not always the case? Jan > Using DEPENDS instead of RDEPENDS ensures creation of > pregenerated kernel config before build of target specific linux-kbuild > > Signed-off-by: Stefan Koch <stefan-koch@siemens.com> > --- > .../linux/files/debian/control.tmpl | 8 ++++++++ > .../linux/files/debian/isar/common.tmpl | 2 ++ > .../linux/files/debian/isar/configure.tmpl | 18 ++++++++++++++---- > .../linux/files/debian/isar/install.tmpl | 15 +++++++++++++++ > meta/recipes-kernel/linux/linux-custom.inc | 14 +++++++++----- > 5 files changed, 48 insertions(+), 9 deletions(-) > > diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl > index e0e932a0..fa2b4e12 100644 > --- a/meta/recipes-kernel/linux/files/debian/control.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > @@ -50,6 +50,14 @@ Description: Linux kernel debugging symbols for @KR@ > This package will come in handy if you need to debug the kernel. It provides > all the necessary debug symbols for the kernel and its modules. > > +Package: linux-config-${KERNEL_NAME_PROVIDED} > +Build-Profiles: <kconfig> > +Architecture: all > +Depends: ${perl:Depends}, ${shlib:Depends} > +Description: ${KERNEL_NAME_PROVIDED} Linux kernel config for @KR@ > + This package provides the kernel config for @KR@ > + The target specific linux-kbuild package benefits from a reduced build time. > + > Package: linux-kbuild-${KERNEL_NAME_PROVIDED} > Build-Profiles: <kbuild !cross> > Architecture: any > diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > index 86af70c5..6666c414 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > @@ -10,6 +10,7 @@ KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_LIBC_HEADERS=linux-libc-dev > KERNEL_PKG_LIBC_HEADERS_CROSS=linux-libc-dev-${DISTRO_ARCH}-cross > +KERNEL_PKG_KERN_CONFIG=linux-config-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_KERN_KBUILD=linux-kbuild-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_KERN_KBUILD_CROSS=${KERNEL_PKG_KERN_KBUILD}-${DISTRO_ARCH}-cross > > @@ -32,6 +33,7 @@ deb_dbg_dir=${deb_img_dir}-dbg > deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} > deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} > deb_libc_hdr_cross_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS_CROSS} > +deb_kern_config_dir=${deb_top_dir}/${KERNEL_PKG_KERN_CONFIG} > deb_kern_kbuild_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} > deb_kern_kbuild_cross_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD_CROSS} > > diff --git a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > index 389c9a85..19797b84 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > @@ -10,10 +10,20 @@ 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} > + configdir=/usr/lib/linux-config-${PV} > + if [ -e ${configdir}/kernelconfig ]; then > + # Prefer pregenerated kernel config > + # So, very expensive QEMU-emulated merge_config.sh > + # can be skipped for target specific linux-kbuild package > + mkdir -p ${KERNEL_BUILD_DIR} > + cp ${configdir}/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/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > index 00011517..3387671c 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > @@ -33,6 +33,13 @@ do_install() { > # Trace what we do here > set -x > > + if echo "${DEB_BUILD_PROFILES}" | grep -q "kconfig"; then > + # Install kernel config > + # The target specific linux-kbuild package can speedup > + # the build using this pregenerated kernel config > + install_kconf ${deb_kern_config_dir} > + fi > + > if echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild"; then > # Install kernel scripts and tools > if echo "${DEB_BUILD_PROFILES}" | grep -q "cross"; then > @@ -223,6 +230,14 @@ install_headers() { > kernel_headers > } > > +install_kconf() { > + kernel_kconf_dir=usr/lib/linux-config-${PV} > + destdir=${1}/${kernel_kconf_dir} > + > + mkdir -p ${destdir} > + cp ${O}/${KCONF} ${destdir}/kernelconfig > +} > + > install_kbuild() { > kernel_kbuild_dir=usr/lib/linux-kbuild-${krel} > destdir=${1}/${kernel_kbuild_dir} > diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc > index 647f09dd..b21a90f3 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-config-${KERNEL_NAME_PROVIDED} <kbuild !kconfig>, \ > rsync," > > KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ > @@ -106,14 +107,14 @@ python() { > } > > # Default profiles and provides > -BUILD_PROFILES = "kernel kbuild" > +BUILD_PROFILES = "kernel kconfig kbuild" > > # We only offer the -kbuildtarget variant when actually cross compiling > BBCLASSEXTEND:append:cross-profile = " kbuildtarget" > > # When cross-profile is active: > -# build only kernel with the default variant of the recipe > -BUILD_PROFILES:cross-profile = "kernel" > +# build only kernel and package config with the default variant of the recipe > +BUILD_PROFILES:cross-profile = "kernel kconfig" > > # -native: kbuild package for host > BUILD_PROFILES:class-native = "kbuild" > @@ -122,14 +123,17 @@ 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, see below > +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 pregenerated > +# kernel config before build of target specific linux-kbuild package > +DEPENDS:class-kbuildtarget = "${BPN}" > ISAR_CROSS_COMPILE:class-kbuildtarget = "0" > > # Make bitbake know we will be producing linux-image and linux-headers packages
On Tue, 2024-06-04 at 18:18 +0200, Jan Kiszka wrote: > > On 04.06.24 17:39, Stefan Koch wrote: > > > > Avoids time expensive QEMU-emulated merging of kernel config > > > > by using a pregenerated kernel config for target specific > > > > linux-kbuild > > > > > > > > Hmm, it's a bit heavier to install, but we already have the config > > packaged: in linux-image under /boot/config-*. Or is this not > > always > > the > > case? Yes, that's right. I'll send an updated patch. It will copy the config from linux-image while build time is the same as with separate linux-config package. > > > > Jan > > > > > > Using DEPENDS instead of RDEPENDS ensures creation of > > > > pregenerated kernel config before build of target specific > > > > linux-kbuild > > > > > > > > Signed-off-by: Stefan Koch <stefan-koch@siemens.com> > > > > --- > > > > .../linux/files/debian/control.tmpl | 8 ++++++++ > > > > .../linux/files/debian/isar/common.tmpl | 2 ++ > > > > .../linux/files/debian/isar/configure.tmpl | 18 > > > > ++++++++++++++---- > > > > .../linux/files/debian/isar/install.tmpl | 15 > > > > +++++++++++++++ > > > > meta/recipes-kernel/linux/linux-custom.inc | 14 +++++++++- > > > > ---- > > > > 5 files changed, 48 insertions(+), 9 deletions(-) > > > > > > > > diff --git a/meta/recipes- > > > > kernel/linux/files/debian/control.tmpl > > > > b/meta/recipes-kernel/linux/files/debian/control.tmpl > > > > index e0e932a0..fa2b4e12 100644 > > > > --- a/meta/recipes-kernel/linux/files/debian/control.tmpl > > > > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > > > > @@ -50,6 +50,14 @@ Description: Linux kernel debugging symbols > > > > for > > > > @KR@ > > > > This package will come in handy if you need to debug the > > > > kernel. > > > > It provides > > > > all the necessary debug symbols for the kernel and its > > > > modules. > > > > > > > > +Package: linux-config-${KERNEL_NAME_PROVIDED} > > > > +Build-Profiles: <kconfig> > > > > +Architecture: all > > > > +Depends: ${perl:Depends}, ${shlib:Depends} > > > > +Description: ${KERNEL_NAME_PROVIDED} Linux kernel config for > > > > @KR@ > > > > + This package provides the kernel config for @KR@ > > > > + The target specific linux-kbuild package benefits from a > > > > reduced > > > > build time. > > > > + > > > > Package: linux-kbuild-${KERNEL_NAME_PROVIDED} > > > > Build-Profiles: <kbuild !cross> > > > > Architecture: any > > > > diff --git > > > > a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > > b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > > index 86af70c5..6666c414 100644 > > > > --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > > @@ -10,6 +10,7 @@ > > > > KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} > > > > KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} > > > > KERNEL_PKG_LIBC_HEADERS=linux-libc-dev > > > > KERNEL_PKG_LIBC_HEADERS_CROSS=linux-libc-dev-${DISTRO_ARCH}- > > > > cross > > > > +KERNEL_PKG_KERN_CONFIG=linux-config-${KERNEL_NAME_PROVIDED} > > > > KERNEL_PKG_KERN_KBUILD=linux-kbuild-${KERNEL_NAME_PROVIDED} > > > > KERNEL_PKG_KERN_KBUILD_CROSS=${KERNEL_PKG_KERN_KBUILD}- > > > > ${DISTRO_AR > > > > CH}-cross > > > > > > > > @@ -32,6 +33,7 @@ deb_dbg_dir=${deb_img_dir}-dbg > > > > deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} > > > > deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} > > > > deb_libc_hdr_cross_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADER > > > > S_CR > > > > OSS} > > > > +deb_kern_config_dir=${deb_top_dir}/${KERNEL_PKG_KERN_CONFIG} > > > > deb_kern_kbuild_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} > > > > deb_kern_kbuild_cross_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBU > > > > ILD_ > > > > CROSS} > > > > > > > > diff --git > > > > a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > > > > b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl > > > > index 389c9a85..19797b84 100644 > > > > --- a/meta/recipes- > > > > kernel/linux/files/debian/isar/configure.tmpl > > > > +++ b/meta/recipes- > > > > kernel/linux/files/debian/isar/configure.tmpl > > > > @@ -10,10 +10,20 @@ 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} > > > > + configdir=/usr/lib/linux-config-${PV} > > > > + if [ -e ${configdir}/kernelconfig ]; then > > > > + # Prefer pregenerated kernel config > > > > + # So, very expensive QEMU-emulated merge_config.sh > > > > + # can be skipped for target specific linux-kbuild > > > > package > > > > + mkdir -p ${KERNEL_BUILD_DIR} > > > > + cp ${configdir}/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/files/debian/isar/install.tmpl > > > > b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > > > index 00011517..3387671c 100644 > > > > --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > > > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > > > @@ -33,6 +33,13 @@ do_install() { > > > > # Trace what we do here > > > > set -x > > > > > > > > + if echo "${DEB_BUILD_PROFILES}" | grep -q "kconfig"; then > > > > + # Install kernel config > > > > + # The target specific linux-kbuild package can speedup > > > > + # the build using this pregenerated kernel config > > > > + install_kconf ${deb_kern_config_dir} > > > > + fi > > > > + > > > > if echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild"; then > > > > # Install kernel scripts and tools > > > > if echo "${DEB_BUILD_PROFILES}" | grep -q "cross"; > > > > then > > > > @@ -223,6 +230,14 @@ install_headers() { > > > > kernel_headers > > > > } > > > > > > > > +install_kconf() { > > > > + kernel_kconf_dir=usr/lib/linux-config-${PV} > > > > + destdir=${1}/${kernel_kconf_dir} > > > > + > > > > + mkdir -p ${destdir} > > > > + cp ${O}/${KCONF} ${destdir}/kernelconfig > > > > +} > > > > + > > > > install_kbuild() { > > > > kernel_kbuild_dir=usr/lib/linux-kbuild-${krel} > > > > destdir=${1}/${kernel_kbuild_dir} > > > > diff --git a/meta/recipes-kernel/linux/linux-custom.inc > > > > b/meta/recipes-kernel/linux/linux-custom.inc > > > > index 647f09dd..b21a90f3 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-config-${KERNEL_NAME_PROVIDED} > > > > <kbuild > > > > !kconfig>, \ > > > > rsync," > > > > > > > > KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs- > > > > tool, > > > > \ > > > > @@ -106,14 +107,14 @@ python() { > > > > } > > > > > > > > # Default profiles and provides > > > > -BUILD_PROFILES = "kernel kbuild" > > > > +BUILD_PROFILES = "kernel kconfig kbuild" > > > > > > > > # We only offer the -kbuildtarget variant when actually cross > > > > compiling > > > > BBCLASSEXTEND:append:cross-profile = " kbuildtarget" > > > > > > > > # When cross-profile is active: > > > > -# build only kernel with the default variant of the recipe > > > > -BUILD_PROFILES:cross-profile = "kernel" > > > > +# build only kernel and package config with the default > > > > variant of > > > > the recipe > > > > +BUILD_PROFILES:cross-profile = "kernel kconfig" > > > > > > > > # -native: kbuild package for host > > > > BUILD_PROFILES:class-native = "kbuild" > > > > @@ -122,14 +123,17 @@ 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, see below > > > > +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 > > > > pregenerated > > > > +# kernel config before build of target specific linux-kbuild > > > > package > > > > +DEPENDS:class-kbuildtarget = "${BPN}" > > > > ISAR_CROSS_COMPILE:class-kbuildtarget = "0" > > > > > > > > # Make bitbake know we will be producing linux-image and > > > > linux-headers packages > >
diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl index e0e932a0..fa2b4e12 100644 --- a/meta/recipes-kernel/linux/files/debian/control.tmpl +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl @@ -50,6 +50,14 @@ Description: Linux kernel debugging symbols for @KR@ This package will come in handy if you need to debug the kernel. It provides all the necessary debug symbols for the kernel and its modules. +Package: linux-config-${KERNEL_NAME_PROVIDED} +Build-Profiles: <kconfig> +Architecture: all +Depends: ${perl:Depends}, ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kernel config for @KR@ + This package provides the kernel config for @KR@ + The target specific linux-kbuild package benefits from a reduced build time. + Package: linux-kbuild-${KERNEL_NAME_PROVIDED} Build-Profiles: <kbuild !cross> Architecture: any diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl index 86af70c5..6666c414 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl @@ -10,6 +10,7 @@ KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} KERNEL_PKG_LIBC_HEADERS=linux-libc-dev KERNEL_PKG_LIBC_HEADERS_CROSS=linux-libc-dev-${DISTRO_ARCH}-cross +KERNEL_PKG_KERN_CONFIG=linux-config-${KERNEL_NAME_PROVIDED} KERNEL_PKG_KERN_KBUILD=linux-kbuild-${KERNEL_NAME_PROVIDED} KERNEL_PKG_KERN_KBUILD_CROSS=${KERNEL_PKG_KERN_KBUILD}-${DISTRO_ARCH}-cross @@ -32,6 +33,7 @@ deb_dbg_dir=${deb_img_dir}-dbg deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} deb_libc_hdr_cross_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS_CROSS} +deb_kern_config_dir=${deb_top_dir}/${KERNEL_PKG_KERN_CONFIG} deb_kern_kbuild_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} deb_kern_kbuild_cross_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD_CROSS} diff --git a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl index 389c9a85..19797b84 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl @@ -10,10 +10,20 @@ 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} + configdir=/usr/lib/linux-config-${PV} + if [ -e ${configdir}/kernelconfig ]; then + # Prefer pregenerated kernel config + # So, very expensive QEMU-emulated merge_config.sh + # can be skipped for target specific linux-kbuild package + mkdir -p ${KERNEL_BUILD_DIR} + cp ${configdir}/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/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl index 00011517..3387671c 100644 --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl @@ -33,6 +33,13 @@ do_install() { # Trace what we do here set -x + if echo "${DEB_BUILD_PROFILES}" | grep -q "kconfig"; then + # Install kernel config + # The target specific linux-kbuild package can speedup + # the build using this pregenerated kernel config + install_kconf ${deb_kern_config_dir} + fi + if echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild"; then # Install kernel scripts and tools if echo "${DEB_BUILD_PROFILES}" | grep -q "cross"; then @@ -223,6 +230,14 @@ install_headers() { kernel_headers } +install_kconf() { + kernel_kconf_dir=usr/lib/linux-config-${PV} + destdir=${1}/${kernel_kconf_dir} + + mkdir -p ${destdir} + cp ${O}/${KCONF} ${destdir}/kernelconfig +} + install_kbuild() { kernel_kbuild_dir=usr/lib/linux-kbuild-${krel} destdir=${1}/${kernel_kbuild_dir} diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc index 647f09dd..b21a90f3 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-config-${KERNEL_NAME_PROVIDED} <kbuild !kconfig>, \ rsync," KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ @@ -106,14 +107,14 @@ python() { } # Default profiles and provides -BUILD_PROFILES = "kernel kbuild" +BUILD_PROFILES = "kernel kconfig kbuild" # We only offer the -kbuildtarget variant when actually cross compiling BBCLASSEXTEND:append:cross-profile = " kbuildtarget" # When cross-profile is active: -# build only kernel with the default variant of the recipe -BUILD_PROFILES:cross-profile = "kernel" +# build only kernel and package config with the default variant of the recipe +BUILD_PROFILES:cross-profile = "kernel kconfig" # -native: kbuild package for host BUILD_PROFILES:class-native = "kbuild" @@ -122,14 +123,17 @@ 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, see below +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 pregenerated +# kernel config before build of target specific linux-kbuild package +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 a pregenerated kernel config for target specific linux-kbuild Using DEPENDS instead of RDEPENDS ensures creation of pregenerated kernel config before build of target specific linux-kbuild Signed-off-by: Stefan Koch <stefan-koch@siemens.com> --- .../linux/files/debian/control.tmpl | 8 ++++++++ .../linux/files/debian/isar/common.tmpl | 2 ++ .../linux/files/debian/isar/configure.tmpl | 18 ++++++++++++++---- .../linux/files/debian/isar/install.tmpl | 15 +++++++++++++++ meta/recipes-kernel/linux/linux-custom.inc | 14 +++++++++----- 5 files changed, 48 insertions(+), 9 deletions(-)