From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7163980406052618240 X-Received: by 2002:a05:6512:3414:b0:4a2:2b23:f17f with SMTP id i20-20020a056512341400b004a22b23f17fmr491534lfr.688.1668163838263; Fri, 11 Nov 2022 02:50:38 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:36c7:b0:4a2:3951:eac8 with SMTP id e7-20020a05651236c700b004a23951eac8ls503272lfs.0.-pod-prod-gmail; Fri, 11 Nov 2022 02:50:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mGQAbkpFeGPNLdp0EdLVvsHmoSVNkBi2QqQDslpYxkei8Dn3UzXTMMxte8lp22FvxLXY3 X-Received: by 2002:ac2:5de1:0:b0:4a2:2701:7d29 with SMTP id z1-20020ac25de1000000b004a227017d29mr575926lfq.322.1668163836576; Fri, 11 Nov 2022 02:50:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668163836; cv=none; d=google.com; s=arc-20160816; b=G+H9A6QGo0xOQyUTI3cR1k5JsKkNCBl3UamobV99zQt3P5N+wRfcIFqgHKYx/0oG7p HBwxyDepyTdLz/BxGnRfCTN82IOAYbI1TO/wHMZjeldgNjL6PwznfwQXGaJUIHit5XDc pbX7XWFpemgp58zbCG7B8iaCC59m3s6y03DbvJFQYV0xbU0tQxl25dG3QucZ5o+YzViy wSV+zXReoRk6zmi1b3TdVYux78MBpKtL7nnc2vG3yIGRPaTczVtunrcnqK8hicQCBLoG lnbBRxKTUkw3XgD51aEBSWtXTB89O5fzUqSyGrr/XJPHEaP/HBmpjwLgiumLj/OZJ5Oe ibfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Dcfxct6UF5pKbTLOp8hmIwp72I2JAQLEZYNfh/iztG0=; b=fKrObqZHzjcSS5Tgb5HAymHNkABH9dPpgDgBuLLJ82TMetQraaRGVSo+ErC0etNttp OXBz0HpnwVE+b0UAgqSLOQvAjGTsk2TM1zd6ilnZu3IRtFiObLLNW2r7paNlAZPzMiGs QpAe8uQ/KFplxhhHXsPm7683FLHnk4eYIWeh78wr/MMyMVXVjD/95DXya+ZSzh0Z7R/E 1Qde2GZyK2Rhh6bL/t2/INNYlQ+DcqrohCvMpHMK0rPNYNf6v7TchkEK2U5MhwYP99MF IuA6EikqruYvpGQsimwScZ9NRbMZ9HdiTu0JIVNlyzUT63hAzJVFUYm1eDvKj2iRtqKa WXiA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id h23-20020a05651c125700b002776daa0487si76068ljh.2.2022.11.11.02.50.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 02:50:36 -0800 (PST) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from hp.localnet (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 2ABAoXgo008654 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 11:50:34 +0100 From: Uladzimir Bely To: "Koch, Stefan" Cc: isar-users@googlegroups.com Subject: Re: [PATCH 2/3] linux-custom: Split up binaries from kernel headers to kbuild packages Date: Fri, 11 Nov 2022 13:50:30 +0300 Message-ID: <2590195.fDdHjke4Dd@hp> In-Reply-To: <8b563ab8b719adc330b9ce738a4817a2acb2e284.camel@siemens.com> References: <20221109103238.1520091-1-stefan-koch@siemens.com> <4749412.OV4Wx5bFTl@hp> <8b563ab8b719adc330b9ce738a4817a2acb2e284.camel@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: hcWYyfK0SizL In mail from =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 11 =D0=BD=D0=BE=D1= =8F=D0=B1=D1=80=D1=8F 2022 =D0=B3. 12:03:40 +03 You wrote: > On Fri, 2022-11-11 at 08:34 +0300, Uladzimir Bely wrote: >=20 > > In mail from =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BD=D0=BE=D1=8F=D0=B1= =D1=80=D1=8F 2022 =D0=B3. 13:32:48 +03 user Koch, Stefan > > wrote: > >=20 > > > When using a cross build this patch does introduce > > > host and target specific kernel kbuild packages that > > > ship the "scripts" and "tools" binaries. > > > The kernel headers fulfill this using symlinks to point > > > to the "scripts" and "tools" of the respective kernel kbuild > > > package. > > >=20 > > > Known from doc/custom_kernel.inc: > > > - The kernel headers package has not supported both native > > > and cross compilation of kernel modules when itself was cross > > > built > > > - Future roadmap: Generate kernel headers package for both host > > > and target when using a cross build > > >=20 > > > Known from debian kernel packages structure: > > > - Generate a kernel headers package without binaries > > > - Create specific kernel kbuild packages that > > > ship the "scripts" and "tools" binaries > > > - Using symlinks to point to the "scripts" > > > and "tools" binaries > > >=20 > > > Signed-off-by: Stefan Koch > > > --- > > > .../linux/files/debian/control.tmpl | 18 ++- > > > .../linux/files/debian/isar/build.tmpl | 9 +- > > > .../linux/files/debian/isar/common.tmpl | 7 +- > > > .../linux/files/debian/isar/install.tmpl | 64 +++++++++-- > > > .../linux/files/debian/rules.tmpl | 5 +- > > > meta/recipes-kernel/linux/linux-custom.inc | 104 > > > ++++++++++++++++-- > > > 6 files changed, 178 insertions(+), 29 deletions(-) > > >=20 > > > diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl > > > b/meta/recipes-kernel/linux/files/debian/control.tmpl index > > > dd0b624..adac4ef 100644 > > > --- a/meta/recipes-kernel/linux/files/debian/control.tmpl > > > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > > > @@ -26,7 +26,7 @@ Section: devel > > > Provides: linux-kernel-headers > > > Architecture: any > > > Description: Linux support headers for userspace development > > > - This package provides userspaces headers from the Linux kernel.=20 > > > These > > > headers + This package provides userspaces headers from the Linux > > > kernel. > > > These headers are used by the installed headers for GNU glibc and > > > other > > > system libraries. > > >=20 > > > Package: linux-image-${KERNEL_NAME_PROVIDED}-dbg > > > @@ -35,3 +35,19 @@ Architecture: any > > > 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-kbuild-${KERNEL_NAME_PROVIDED} > > > +Architecture: any > > > +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, > > > ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild > > > scripts > > > and tools for @KR@ + This package provides kernel kbuild scripts > > > and tools > > > for @KR@ > > > + This is useful for people who need to build external modules > > > + > > > +Package: linux-kbuild-${KERNEL_NAME_PROVIDED}-cross > > > +Architecture: ${CONTROL_TARGET_ARCH} > >=20 > >=20 > > Is this architecture correct? Below, it's set to target_arch =3D > > distro_arch for=20 > > cross-compile case. > >=20 > > I looked into `linux-kbuild-mainline-cross_5.4.203+r0_armhf.deb` and > > there are=20 > > some binaries inside, "ELF 64-bit LSB pie executable, x86-64", so it > > looks for=20 > > me that the package is supposed to be installed on host machine and > > to have=20 > > the host architecture instead. >=20 >=20 > I think your `linux-headers-mainline_5.4.203+r0_armhf.deb` is also > armhf? Without the patch there are the same x86-64 binaries... They > have moved from linux-headers:armhf to linux-kbuild-cross:armhf. >=20 Yes, you are right. If we compile current `next` natively, we have `linux-headers- mainline_5.4.203+r0_armhf.deb` package with 32-bit ARM binaries inside the= =20 package (in `scripts` dir). Buf if we crosscompile it, we have 64-bit x86-6= 4=20 binaries in the package with the same name. You patches fix this by generating `linux-kbuild- mainline_5.4.203+r0_armhf.deb` (with 32-bit ARM binaries) and `linux-kbuild- mainline-cross_5.4.203+r0_armhf.deb` (with 64-bit x86-64 binaries). I'm just not sure that this "-cross" package should be with `armhf` prefix= =20 (e.g., now it has control file with "Architecture: armhf" field). > Might it be better to have linux-headers:all instead of :armhf? > Since the binaries are out? But debian uses for their header packages > not :all even if they have split out the binaries... >=20 > I would be appreciative for a tip to getting the dpkg build not to > complain, when we would change it to linux-kbuild-cross:amd64 >=20 > Keeping and not fixing the existing limitations was the goal here... > See comment below, too. >=20 >=20 > >=20 > >=20 > > > +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, > > > ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild > > > scripts > > > and tools for @KR@ + This package provides kernel kbuild scripts > > > and tools > > > + as ${HOST_ARCH} cross binaries for @KR@ > > > + This is useful for those who need to cross build > > > + external modules using ISAR's sbuild-chroot-host > > > diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > > > b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl index > > > 94cfbe0..7e2daad 100644 > > > --- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > > > +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > > > @@ -13,16 +13,19 @@ do_build() { > > > # Trace what we do here > > > set -x > > >=20 > > > + # Set correct build directory for kernel or kbuild (kernel > > > scripts and > > > tools) cases + build_dir=3D${KERNEL_BUILD_DIR} > > > + > > > # Process existing kernel configuration to make sure it is > > > complete > > > # (use defaults for options that were not specified) > > > - ${MAKE} O=3D${KERNEL_BUILD_DIR} olddefconfig prepare > > > + ${MAKE} O=3D${build_dir} olddefconfig prepare > > >=20 > > > # Transfer effective kernel version into control file and > > > scripts > > > - KR=3D$(${MAKE} O=3D${KERNEL_BUILD_DIR} -s --no-print-directory > > > kernelrelease) + KR=3D$(${MAKE} O=3D${build_dir} -s --no-print- > > > directory > > > kernelrelease) sed -i "s/@KR@/${KR}/g" ${S}/debian/control > > > ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.* > > >=20 > > > # Build the Linux kernel > > > - ${MAKE} O=3D${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} > > > KCFLAGS=3D"${KCFLAGS}" > > > + ${MAKE} O=3D${build_dir} ${PARALLEL_MAKE} KCFLAGS=3D"${KCFLAGS}" > > >=20 > > > # Stop tracing > > > set +x > > > diff --git a/meta/recipes- > > > kernel/linux/files/debian/isar/common.tmpl > > > b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl index > > > 52ebebb..55d6123 100644 > > > --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > > @@ -5,10 +5,14 @@ > > > set -e > > >=20 > > > # Isar settings > > > -ARCH=3D${KERNEL_ARCH} > > > KERNEL_PKG_IMAGE=3Dlinux-image-${KERNEL_NAME_PROVIDED} > > > KERNEL_PKG_KERN_HEADERS=3Dlinux-headers-${KERNEL_NAME_PROVIDED} > > > KERNEL_PKG_LIBC_HEADERS=3Dlinux-libc-dev > > > +KERNEL_PKG_KERN_KBUILD=3Dlinux-kbuild-${KERNEL_NAME_PROVIDED} > > > + > > > +if [ -z "${ARCH}" ]; then > > > + ARCH=3D${KERNEL_ARCH} > > > +fi > > >=20 > > > # Constants > > > KCONF=3D.config > > > @@ -19,6 +23,7 @@ deb_img_dir=3D${deb_top_dir}/${KERNEL_PKG_IMAGE} > > > deb_dbg_dir=3D${deb_img_dir}-dbg > > > deb_kern_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} > > > deb_libc_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} > > > +deb_kern_kbuild_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} > > >=20 > > > # Array of packages to be generated > > > declare -A kern_pkgs > > > diff --git a/meta/recipes- > > > kernel/linux/files/debian/isar/install.tmpl > > > b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl index > > > 0a8645d..890a996 100644 > > > --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > > @@ -33,6 +33,7 @@ do_install() { > > > # Trace what we do here > > > set -x > > >=20 > > > + # Run the install steps > > > install_image > > > if [ "${ARCH}" !=3D "um" ]; then > > > install_config > > > @@ -43,6 +44,19 @@ do_install() { > > > install_kmods > > > install_headers > > >=20 > > > + if [ -d "$(dirname ${O})/build-full-kbuild-target" ]; then > > > + # Install cross kernel scripts and tools > > > + install_kbuild ${deb_kern_kbuild_dir}-cross build-full > > > + > > > + # Cleanup and install kernel scripts and tools for target > > > arch > > > + rm -rf ${deb_kern_kbuild_dir} > > > + install_kbuild ${deb_kern_kbuild_dir} build-full-kbuild- > > > target > > > + else > > > + # Cleanup and install kernel scripts and tools > > > + rm -rf ${deb_kern_kbuild_dir} > > > + install_kbuild ${deb_kern_kbuild_dir} build-full > > > + fi > > > + > > > # Stop tracing > > > set +x > > > } > > > @@ -168,21 +182,15 @@ kernel_headers() { > > > mkdir -p ${destdir} > > > mkdir -p ${deb_kern_hdr_dir}/lib/modules/${krel} > > >=20 > > > - (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o - > > > name '*.pl') > > >=20 > > > > > ${src_hdr_files} - (cd ${S}; find arch/*/include include > > > > > scripts -type > > >=20 > > > f -o -type l) >>${src_hdr_files} + (cd ${S}; find . -not -path > > > './scripts/*' -a -not -path './tools/*' -a \( -name 'Makefile*' -o > > > -name > > > 'Kconfig*' -o -name '*.pl' \)) >>${src_hdr_files} + (cd ${S}; > > > find > > > arch/*/include include -type f -o -type l) >>${src_hdr_files} (cd > > > ${S}; > > > find arch/${ARCH} -name module.lds -o -name Kbuild.platforms -o - > > > name > > > Platform) >>${src_hdr_files} (cd ${S}; find $(find arch/${ARCH} - > > > name > > > include -o -name scripts -type d) -type f) >>${src_hdr_files} > > >=20 > > > if [ -n "${CONFIG_MODULES}" ]; then > > > echo Module.symvers >> ${obj_hdr_files} > > > fi > > > - (cd ${O}; find arch/${ARCH}/include include scripts -type f) > > >=20 > > > > > ${obj_hdr_files} - if [ -n "${CONFIG_STACK_VALIDATION}" ]; > > > > > then > > >=20 > > > - (cd ${O}; find tools/objtool -type f -executable) > > >=20 > > > > > ${obj_hdr_files} - fi > > >=20 > > > - if [ -n "${CONFIG_GCC_PLUGINS}" ]; then > > > - (cd ${O}; find scripts/gcc-plugins -name *.so -o -name > > > gcc-common.h) >>${obj_hdr_files} - fi > > > + (cd ${O}; find arch/${ARCH}/include include -type f) > > >=20 > > > >>${obj_hdr_files} > > >=20 > > >=20 > > > # deploy files that were matched above > > > tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} - > > > xf - > > > @@ -191,8 +199,11 @@ kernel_headers() { > > > # add the kernel config > > > cp ${O}/${KCONF} ${destdir}/.config > > >=20 > > > - # handle kernel development tools > > > - kernel_tools > > > + # add symlink to scripts and tools directories > > > + ln -sf ../../lib/linux-kbuild-${krel}/scripts > > > ${destdir}/scripts > > > + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > > > + ln -sf ../../lib/linux-kbuild-${krel}/tools > > > ${destdir}/tools > > > + fi > > >=20 > > > # create symlinks > > > ln -sf /${kernel_headers_dir} > > > ${deb_kern_hdr_dir}/lib/modules/${krel}/build @@ -206,4 +217,35 @@ > > > install_headers() { > > > kernel_headers > > > } > > >=20 > > > +install_kbuild() { > > > + kernel_kbuild_dir=3Dusr/lib/linux-kbuild-${krel} > > > + destdir=3D${1}/${kernel_kbuild_dir} > > > + src_kbuild_files=3D$(mktemp) > > > + obj_kbuild_files=3D$(mktemp) > > > + > > > + if [ -n "${2}" ]; then > > > + O=3D$(dirname ${O})/${2} > > > + fi > > > + > > > + mkdir -p ${destdir} > > > + > > > + (cd ${S}; find . -path './scripts/*' -a -path './tools/*' -a > > > \( -name > > > 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl' \)) > > >=20 > > > >>${src_kbuild_files} + > > >=20 > > > (cd ${S}; find scripts -type f -o -type l) >>${src_kbuild_files} > > > + > > > + (cd ${O}; find scripts -type f) >>${obj_kbuild_files} > > > + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > > > + (cd ${O}; find tools/objtool -type f -executable) > > >=20 > > > > > ${obj_kbuild_files} + fi > > >=20 > > > + if [ -n "${CONFIG_GCC_PLUGINS}" ]; then > > > + (cd ${O}; find scripts/gcc-plugins -name *.so -o -name > > > gcc-common.h) >>${obj_kbuild_files} + fi > > > + > > > + # deploy files that were matched above > > > + tar -C ${S} -cf - -T - <${src_kbuild_files} | tar -C > > > ${destdir} -xf - > > > + tar -C ${O} -cf - -T - <${obj_kbuild_files} | tar -C > > > ${destdir} -xf - > > > + > > > + # handle kernel development tools > > > + kernel_tools > > > +} > > > + > > > main install ${*} > > > diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl > > > b/meta/recipes-kernel/linux/files/debian/rules.tmpl index > > > 8063c49..e131288 > > > 100755 > > > --- a/meta/recipes-kernel/linux/files/debian/rules.tmpl > > > +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl > > > @@ -36,4 +36,7 @@ override_dh_auto_test: > > > true > > >=20 > > > override_dh_strip: > > > - unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu >=20 >=20 > That line was because `linux-headers-mainline_5.4.203+r0_armhf.deb` is > also armhf and contained x86-64 binaries... >=20 >=20 > > > --no-automatic-dbgsym > > > + dh_strip -Xvmlinu -Xlinux-kbuild-${KERNEL_NAME_PROVIDED}- > > > cross > > > --no-automatic-dbgsym + > > > +override_dh_shlibdeps: > > > + dh_shlibdeps -Xlinux-kbuild-${KERNEL_NAME_PROVIDED} > > > diff --git a/meta/recipes-kernel/linux/linux-custom.inc > > > b/meta/recipes-kernel/linux/linux-custom.inc index 96f0afc..0f8ba50 > > > 100644 > > > --- a/meta/recipes-kernel/linux/linux-custom.inc > > > +++ b/meta/recipes-kernel/linux/linux-custom.inc > > > @@ -74,12 +74,14 @@ TEMPLATE_VARS +=3D " \ > > > KERNEL_ARCH \ > > > KERNEL_DEBIAN_DEPENDS \ > > > KERNEL_BUILD_DIR \ > > > + KERNEL_KBUILD_DIR \ > > > KERNEL_FILE \ > > > KERNEL_HEADERS_DEBIAN_DEPENDS \ > > > LINUX_VERSION_EXTENSION \ > > > KERNEL_NAME_PROVIDED \ > > > KERNEL_CONFIG_FRAGMENTS \ > > > KCFLAGS \ > > > + CONTROL_TARGET_ARCH \ > > > " > > >=20 > > > inherit dpkg > > > @@ -91,30 +93,54 @@ KCFLAGS ?=3D "-fdebug-prefix-map=3D${CURDIR}=3D." > > > # Derive name of the kernel packages from the name of this recipe > > > KERNEL_NAME_PROVIDED ?=3D "${@ d.getVar('PN', > > > True).partition('linux-')[2]}" > > >=20 > > > -# Make bitbake know we will be producing linux-image and linux- > > > headers > > > packages python() { > > > kernel_name =3D d.getVar("KERNEL_NAME_PROVIDED", True) > > > - d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \ > > > - 'linux-headers-' + kernel_name) > > > + distro_arch =3D d.getVar("DISTRO_ARCH", True) > > > + host_arch =3D d.getVar("HOST_ARCH", True) > > > + target_arch =3D "" > > > + kbuild_depends =3D "linux-kbuild-" + kernel_name > > > + > > > + # For different distro and host archs > > > + # - Set target arch (empty string disables package build) > > > + # - Add dependency for sbuild-chroot-target > > > + # to allow building arch specific kbuild scripts and tools > > > + # - Set correct name of kbuild package dependency > > > + if distro_arch !=3D host_arch: > > > + d.appendVar("SCHROOT_DEP", " sbuild-chroot- > > > target:do_build") > > > + if d.getVar("ISAR_CROSS_COMPILE", True) =3D=3D "1": > > > + target_arch =3D distro_arch > > > + kbuild_depends =3D kbuild_depends + "-cross | " + > > > kbuild_depends > > > + > > > + # Set CONTROL_TARGET_ARCH > > > + d.setVar("CONTROL_TARGET_ARCH", target_arch) > > > + > > > + # Make bitbake know we will be producing > > > + # linux-image and linux-headers packages > > > + d.setVar("PROVIDES", "linux-image-" + kernel_name + " " + \ > > > + "linux-headers-" + kernel_name) > > > + > > > + # Set dependency for kbuild package > > > + d.appendVar("KERNEL_HEADERS_DEBIAN_DEPENDS", kbuild_depends) > > > } > > >=20 > > > -def get_kernel_arch(d): > > > - distro_arch =3D d.getVar("DISTRO_ARCH") > > > - if distro_arch in ["amd64", "i386"]: > > > +def get_kernel_arch(d, arch=3D"DISTRO_ARCH"): > > > + arch =3D d.getVar(arch) > > > + if arch in ["amd64", "i386"]: > > > kernel_arch =3D "x86" > > > - elif distro_arch =3D=3D "arm64": > > > + elif arch =3D=3D "arm64": > > > kernel_arch =3D "arm64" > > > - elif distro_arch =3D=3D "armhf": > > > + elif arch =3D=3D "armhf": > > > kernel_arch =3D "arm" > > > - elif distro_arch =3D=3D "mipsel": > > > + elif arch =3D=3D "mipsel": > > > kernel_arch =3D "mips" > > > - elif distro_arch =3D=3D "riscv64": > > > + elif arch =3D=3D "riscv64": > > > kernel_arch =3D "riscv" > > > else: > > > kernel_arch =3D "" > > > return kernel_arch > > >=20 > > > KERNEL_ARCH ??=3D "${@get_kernel_arch(d)}" > > > +KERNEL_HOST_ARCH ??=3D "${@get_kernel_arch(d, 'HOST_ARCH')}" > > >=20 > > > def config_fragments(d): > > > fragments =3D [] > > > @@ -157,6 +183,7 @@ do_prepare_build_prepend() { > > >=20 > > > # build directory for our "full" kernel build > > > KERNEL_BUILD_DIR =3D "build-full" > > > +KERNEL_KBUILD_DIR =3D "${KERNEL_BUILD_DIR}-kbuild" > > >=20 > > > def get_kernel_config_target(d): > > > kernel_defconfig =3D d.getVar('KERNEL_DEFCONFIG', True) > > > @@ -187,15 +214,19 @@ def get_kernel_config_fragments(d): > > > KERNEL_CONFIG_FRAGMENTS =3D "${@get_kernel_config_fragments(d)}" > > >=20 > > > dpkg_configure_kernel() { > > > + build_dir=3D"${KERNEL_BUILD_DIR}" > > > + if [ -n "${1}" ]; then > > > + build_dir=3D"${1}" > > > + fi > > > grep -q "KERNEL_CONFIG_TARGET=3D" ${S}/debian/isar/configure > > >=20 > > > || > > >=20 > > > cat << EOF | sed -i '/^do_configure() {/ r > > > /dev/stdin' > > > ${S}/debian/isar/configure > > > KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d)}" > > > EOF > > >=20 > > > - rm -rf ${S}/${KERNEL_BUILD_DIR} && mkdir -p ${S}/$ > >=20 > > {KERNEL_BUILD_DIR} > >=20 > > > + rm -rf ${S}/${build_dir} && mkdir -p ${S}/${build_dir} > > > if [ -n "${KERNEL_DEFCONFIG}" ]; then > > > if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then > > > - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/$ > >=20 > > {KERNEL_BUILD_DIR}/.config > >=20 > > > + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/$ > >=20 > > {build_dir}/.config > >=20 > > > fi > > > fi > > >=20 > > > @@ -210,4 +241,53 @@ EOF > > >=20 > > > dpkg_runbuild_prepend() { > > > dpkg_configure_kernel > > > + > > > + if [ "${ISAR_CROSS_COMPILE}" =3D "1" ] && [ "${HOST_ARCH}" != =3D > > > "${DISTRO_ARCH}" ]; then + # Create temporarily kernel > >=20 > > schroot-target > >=20 > > > configuration > > > + schroot_create_configs ${SCHROOT_TARGET_DIR} > > > + > > > + # Begin kernel schroot-target session > > > + schroot_session=3D$(schroot -b -c ${SBUILD_CHROOT}) > > > + > > > + # Install build deps for schroot session > > > + schroot -u root -r -c $schroot_session -- sh -c " \ > > > + cd ${PP}/${PPS}; \ > > > + mk-build-deps -i -r --host-arch $ > >=20 > > {DISTRO_ARCH} -t \"apt-get -y > >=20 > > > --no-install-recommends --allow-downgrades -o > > > Debug::pkgProblemResolver=3Dyes\" debian/control; \ + " > > > + > > > + # Create kernel configuration for kbuild > > > + dpkg_configure_kernel ${KERNEL_KBUILD_DIR}-target > > > + KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d > > > )}" > > > + > > > + schroot -r -c $schroot_session -- sh -c " \ > > > + cd ${PP}/${PPS}; \ > > > + ARCH=3D${KERNEL_ARCH} make O=3D$ > >=20 > > {KERNEL_KBUILD_DIR}-target > >=20 > > > ${KERNEL_CONFIG_TARGET}; \ + " > > > + > > > + cd ${S} > > > + ARCH=3D${KERNEL_ARCH} > > > ./scripts/kconfig/merge_config.sh -m=20 > >=20 > > -O > >=20 > > > ${KERNEL_KBUILD_DIR}-target/ ${KERNEL_KBUILD_DIR}-target/.config > > > ${KERNEL_CONFIG_FRAGMENTS} + cd - > > > + > > > + # Build kernel scripts and tools for target arch in > > > a non- > >=20 > > cross > >=20 > > > way + # Cross building kernel scripts and tools would not > > > provide > > > them in target architecture + schroot -r -c=20 > >=20 > > $schroot_session -- sh -c " \ > >=20 > > > + cd ${PP}/${PPS}; \ > > > + ARCH=3D${KERNEL_ARCH} make O=3D$ > >=20 > > {KERNEL_KBUILD_DIR}-target olddefconfig; \ > >=20 > > > + ARCH=3D${KERNEL_ARCH} make O=3D$ > >=20 > > {KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} > >=20 > > > scripts; \ + if [ -d "tools/objtool" ]; then \ > > > + echo ARCH=3D${KERNEL_ARCH} make O=3D$ > >=20 > > {KERNEL_KBUILD_DIR}-target > >=20 > > > ${PARALLEL_MAKE} tools/objtool; \ > > > + ARCH=3D$ > >=20 > > {KERNEL_ARCH} make > >=20 > > > O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} tools/objtool; \ > > > + =20 > >=20 > > fi; \ > >=20 > > > + if grep -q "CONFIG_MODULES=3Dy" $ > >=20 > > {KERNEL_KBUILD_DIR}-target/.config; then > >=20 > > > \ + echo ARCH=3D${KERNEL_ARCH} make O=3D$ > >=20 > > {KERNEL_KBUILD_DIR}-target > >=20 > > > ${PARALLEL_MAKE} modules_prepare; \ + =20 > >=20 > > ARCH=3D${KERNEL_ARCH} make > >=20 > > > O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} modules_prepare; \ > > > + =20 > >=20 > > fi; \ > >=20 > > > + " > > > + > > > + # End kernel schroot-target session > > > + schroot -e -c $schroot_session > > > + > > > + # Restore kernel schroot-host configuration > > > + schroot_create_configs > > > + fi > > > } > >=20 > >=20 > >=20 > >=20 > >=20 >=20 >=20 > --=20 > Stefan Koch > Siemens AG > www.siemens.com