Commit Graph

358 Commits

Author SHA1 Message Date
Martin Jansa
2ace04c8f3 kernel.bbclass: pass LD also in savedefconfig
* similar to:
  https://git.openembedded.org/openembedded-core/commit/?id=66c1f4b0abd3483759f9e4141a80f982eaf8ccfd
  https://git.openembedded.org/openembedded-core/commit/?id=36fe2efc91fec5a52374a2dc4814a69076a2d28e
  but for savedefconfig task
* otherwise with ld-is-gold it will fail with:
  gold linker is not supported as it is not capable of linking the kernel proper.

(From OE-Core rev: f0c9e1bf35289afa63f040bbc13ca1755e4db0f9)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-07-25 22:59:01 +01:00
Raphael Teller
7b7dbdd48b kernel.bbclass: Do not overwrite recipe's custom postinst
Allow recipe to set a custom postinst for kernel image.
Use prependVar in order to allow custom postinst to be
ran after default postinst, potentially modifying the
installed file/symlink.

(From OE-Core rev: 579906b9f4ea32c8d4e0e11a87ee6c9e27cdf0dc)

Signed-off-by: Raphael Teller <raphael.teller@se.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-05-23 21:31:31 +01:00
Andrej Valek
8252367023 kernel: add missing path to search for debug files
Since explicit debug package creation via ${KERNEL_PACKAGE_NAME}-dbg has
been added to kernel, it has to cover all PACKAGE_DEBUG_SPLIT_STYLE
options. For ex. when the variable "debug-file-directory" package search
path has to be set explicitly, otherwise it will not find any files.

(From OE-Core rev: 9c39da147683dcaaa244b3ddc4531c4408ad5c9e)

Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-05-15 08:57:15 +01:00
Alex Kiernan
7973b38018 kernel: Delete unused KERNEL_LOCALVERSION variable
This has been unused since:

  commit fb61dc1430
  Author: Richard Purdie <richard@openedhand.com>
  Date:   Mon Jan 8 21:05:18 2007 +0000

      kernel.bbclass: Drop KERNEL_RELEASE variable

      git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1123 311d38ba-8fff-0310-9ca6-ca027cbcb966

(From OE-Core rev: 320da1c2b9add9fecd74e7f33ddc5418b326c786)

Signed-off-by: Alex Kiernan <alexk@zuma.ai>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-14 09:47:00 +01:00
Kevin Hao
d429e927d8 kernel.bbclass: Fix the do_strip() malfunction
The BB variable can't be referenced directly in a python function,
this misusage of the variable reference causes strip function to be
always skipped.

Fixed: b9c3db4953e4 ("kernel.bbclass: Use KERNEL_IMAGEDEST instead of hardcoded boot path")
(From OE-Core rev: c405cb4f421a8c964fa59123ee41879ebd5f829c)

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-12 09:43:43 +01:00
Alessio Igor Bogani
fb1291ea5f kernel.bbclass: Use KERNEL_IMAGEDEST instead of hardcoded boot path
The behaviour doesn't change because KERNEL_IMAGEDEST is defined as
'boot' in the same file (line 215).

(From OE-Core rev: b9c3db4953e4e7b423ba9ec5b618fd990c378bc1)

Signed-off-by: Alessio Igor Bogani <alessio.bogani@elettra.eu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-03 10:40:31 +01:00
Michael Olbrich
aceec5ee12 kernel.bbclass: avoid config changes based on the availability of pahole
CONFIG_PAHOLE_HAS_SPLIT_BTF shows up in the config only when pahole is
installed on the host system. As a result, the config changes depending on
whether pahole is installed or not.

Set PAHOLE=false to ensure that it is never found.

If this is actually needed in the future, then we can add an option for
it and create a host package for pahole.

(From OE-Core rev: 43b0eca2f3fc41a0d2ba7c7679687a3e0eb54b45)

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
[afa: ported from PTXdist 0c0cec2288 to OE-core]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-03-26 09:33:32 +00:00
Ross Burton
f6d963fa6d kernel: make kernel-base recommend kernel-image, not depend
As kernel modules depend on the base kernel package, and the base kernel
recipe depends on the kernel image, it's impossible to build file system
images which contain kernel modules but not the kernel itself, such as
an initramfs.

Change the RDEPENDS to RRECOMMENDS so that the disk images can set
PACKAGE_EXCLUDE = "kernel-image-*" to remove the kernel.

(From OE-Core rev: 1c90b27d2c65cfb4f9debf0272820b6a95942f76)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-02-21 21:53:52 +00:00
Alejandro Hernandez Samaniego
bedb3444e1 kernel.bbclass: Allow initramfs to be built from a separate multiconfig
There may be a case where we want to build an initramfs image
that doesnt inherit the same DISTRO_FEATURES (or others) from
the main image being built.

For example we may want our initramfs not to inherit a certain
conf or feature, say we want to use musl for a smaller footprint,
but if we are using TCLIBC=glibc for our DISTRO (and inherently
our main image), the initramfs image would inherit that conf and
be forced to use glibc, growing in size as a side effect, currently
avoiding this is not supported.

Allow the kernel class to create a multiconfig dependency
(mcdepends) vs depends for do_bundle_initramfs and define
our INITRAMFS_IMAGE from a separate multiconfig via two
new variables:
INITRAMFS_MULTICONFIG and INITRAMFS_DEPLOY_DIR_IMAGE which
define the multiconfig where the initramfs image should be
coming from and its deploy directory respectively, these two
keep a default definition which preserves current behavior
(do_bundle_initramfs uses depends).

Example usage:
- Create and use multiconfig initramfscfg.conf and set
  TCLIBC=musl there, along with its TMPDIR.
- Add the following to our DISTRO.conf:
  INITRAMFS_MULTICONFIG = "initramfscfg"

  and set
  INITRAMFS_DEPLOY_DIR_IMAGE to the DEPLOY_DIR_IMAGE of the
  initramfscfg multiconfig (hence our main kernel will be
  able to grab it from there and bundle it).

This will result in our musl based initramfs bundled in our
main kernel and our main image to be glibc based.

(From OE-Core rev: 2d317b2685211f1b0d102705a63c0000df96f45f)

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alhe@linux.microsoft.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-01-26 06:27:00 +00:00
Saul Wold
987d30df5b kernel.bbclass: use common strip()
Re-use the runstrip() code from oe.packaging, for the kernel
stripping process. Since runstrip() is python the kernel do_strip()
need to be converted to Python also. The stripped kernel image
will be used for deployment in do_deploy(). This will allow the
package.bbclass to split an unstripped kernel binary for the debug
information and extended packagedata. The extended package data is
used by create-spdx.

(From OE-Core rev: e8d9caede5f08154ca615fdaba676b7a4ae05b01)

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-01-13 13:57:26 +00:00
Saul Wold
32db0d80d7 kernel: add -dbg package
Adding the dbg package allows the package bbclass to parse the
debug information which can then be used by the create_spdx bbclass

(From OE-Core rev: b35b68e4ec4a82ada20ab861d29f96cdcb21dec2)

Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-12-22 23:11:45 +00:00
Paul Eggleton
65e8df66d9 classes/kernel*: add variables to allow changing artifact extension
Allow .bin suffix to be removed (or changed) in the various artifact
filenames. Removing this extension is useful when trying to remove
symlinks and present only unversioned image files (especially for the
FIT image).

(From OE-Core rev: cbecc3cf06eb7359fedf3c6af281cc72178cad18)

Signed-off-by: Paul Eggleton <paul.eggleton@microsoft.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-12-22 23:11:45 +00:00
Paul Eggleton
a2eb528b63 classes/kernel*: allow disabling symlink creation
Allow setting any of the *_LINK_NAME variables to empty string in order
to disable creating symlinks for kernel artifacts, as you can already
for filesystem images with IMAGE_LINK_NAME. Additionally, for the image
type named symlinks, add a KERNEL_IMAGETYPE_SYMLINK boolean variable
which you can set to 0 to disable those symlinks as well.

(From OE-Core rev: d7341f1f22c32ff6cc95d7127f26f87d7fc9c6bd)

Signed-off-by: Paul Eggleton <paul.eggleton@microsoft.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-12-22 23:11:45 +00:00
Mike Crowe
37b0f34817 kernel: improve transformation from KERNEL_IMAGETYPE_FOR_MAKE
In 526bdd88ccd758204452579333ba188e29270bde the imageType loop in
kernel_do_deploy was changed to use KERNEL_IMAGETYPE_FOR_MAKE rather
than KERNEL_IMAGETYPES. This broke the special handling for fitImage
immediately below because KERNEL_IMAGETYPE_FOR_MAKE never contains
fitImage.

It has always been my understanding that KERNEL_IMAGETYPE_FOR_MAKE
controlled what was passed to make, but KERNEL_IMAGETYPE controlled what
was installed/deployed. When the two are different then it's the
responsibility of whoever set KERNEL_IMAGETYPE_FOR_MAKE to ensure that
whatever comes out of the kernel build system has been transformed in to
the requested form by the time of installation. This is what happens for
kernel.bbclass's own support for vmlinux.gz.

I think this means that for KERNEL_IMAGETYPE vmlinux.gz, kernel.bbclass
is responsible for generating vmlinux.gz.initramfs[1] so that
kernel_do_deploy can deploy it. This means that the change in
526bdd88ccd758204452579333ba188e29270bde can be reverted, fixing
KERNEL_IMAGETYPE = "fitImage".

In addition, it ought to be possible for recipes and other classes that
use kernel.bbclass to hook into this mechanism by setting
KERNEL_IMAGETYPE_FOR_MAKE and performing their own transformations.

do_bundle_initramfs calls kernel_do_compile and we don't want it to
transform vmlinux to vmlinux.gz at that point, since it will fight
against the careful renaming and preserving that do_bundle_initramfs
does. Let's separate the transformation out of kernel_do_compile to a
new do_transform_kernel task that can be run at the right time. This
means that it's also logical to perform the equivalent translation for
the kernel with the initramfs in a separate
do_transform_bundled_initramfs task too.

This leaves two clear customisation points for recipes and other classes
to hook into the process and perform their transformations:
do_transform_kernel and do_transform_bundled_initramfs.

(I care about this because our recipes that use kernel.bbclass also set
KERNEL_IMAGETYPE_FOR_MAKE and transform vmlinux into a form suitable for
our bootloader after do_compile and do_bundle_initramfs into the format
matching KERNEL_IMAGETYPE. I'm unable to successfully bundle an
initramfs after 526bdd88ccd758204452579333ba188e29270bde, but I didn't
want to just revert that change to reintroduce the bug that it was
fixing.)

I can't say that I'm entirely happy with this change, but I'm unsure
what to do to improve it. I find the way that both the bare kernel and
the one with the initramfs both get deployed to be confusing, and a
waste of build time. I would like to not actually generate a publishable
kernel image at all during do_compile when an initramfs is in use, but I
suspect that this would affect valid use cases that I'm not aware of.

(From OE-Core rev: 10a4a132e87e835726bf5da81a60f6f509b90765)

Signed-off-by: Mike Crowe <mac@mcrowe.com>

[1] It could be argued that this should be vmlinux.initramfs.gz, but
that would require another special case in kernel_do_deploy and the
filename is only visible within this class and the recipes that use it
anyway.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-12-09 13:49:51 +00:00
Bruce Ashfield
ace63e94e3 kernel: export native PKGCONFIG variables
In a similar manner to cml1.bbclass, we export the pkg-config
variables to allow a direct call to pkg-config access to the
native sysroot versus the target sysroot.

The kernel doesn't use pkg-config for target configuration,
and has many explicit calls to pkg-config, without the
possibility of easy override to pkg-config-native.

The calls to pkg-config could be made cross friendly via
replacement with make variables, but until that effort is
undertaken upstream, we need a bridge approach.

In particular, this is required for dtschema validation,
which is a requirement in kernel 5.16+

(From OE-Core rev: 9172d61c57e23682c3d2c25701cbd53c84d01a27)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-11-26 17:01:08 +00:00
Bruce Ashfield
f748564653 kernel: provide virtual/kernel for all kernels
Since we allow the kernel package name to be varied, we should
allow those packages to provide virtua/kernel, which allows them
to be used as primary kernels.

This change drops the use of regex, since any regex would enforce
naming (and limit what can be a provider) and add complexity./

There are currently no recipes that I found, that inherit kernel
that are not kernel recipes (kernel-base, etc, provide other
facilities), so making this provides simpler shouldn't cause
problems.

Multiple kernel providers can be dealt with in the same way as
any multiple provider.

[YOCTO: #13172]

(From OE-Core rev: 365dc1471a1b67c45de58aadf29844a9ff83d30f)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>

squash with provider

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-11-10 19:27:29 +00:00
Richard Purdie
b8b59872fa kernel: Rework kernel make flag to variable mappings
In 2017 we added changes to pass the BUILD_CFLAGS into the kernel
via BUILD_CC. This isn't really correct and the upstream kernel now has
places to pass build cflags, ldflags and more. Update our kernel
make flags to correctly use the kernel's variables. This addresses
concerns raised by kernel developers.

If this breaks some usecase please report it so we can work out how
to fix it properly.

(From OE-Core rev: 7fd06a57a1d91d8534721923f6e3951ec8220cec)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-10-16 17:41:59 +01:00
Richard Purdie
0dc5920862 kernel: Add KERNEL_DEBUG_TIMESTAMPS variable
Change the "binary reproducibility" configuration within the kernel to
work off a separate variable, defaulting to reproducible builds.

This allows kernel developers wanting timestamps in their images to enable
it easily and clearly without changing the rest of the reproduciblity
code which they likely don't need to change anyway.

(From OE-Core rev: 0725ca18af7a2835aeb9616592a45ead2ee87987)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-10-16 17:41:59 +01:00
Rasmus Villemoes
165b089a7d kernel.bbclass: remove unnecessary dead code
The grep pattern seems to have been wrong ever since we stopped adding
the -ffile-prefix-map via a patch in commit 20aea61385e, because the
actual upstream gcc produces

  -ffile-prefix-map=<old>=<new>

and not

  -ffile-prefix-map=<old=new>

Besides, these *-prefix-map options are already used when building the
kernel due to the setting of KERNEL_CC, and the kernel build system
itself also probes for and uses at least -fmacro-prefix-map (hence
taking care of __FILE__ etc., but not necessarily things that go in
.debug_info sections).

(From OE-Core rev: 5d56de8cd653d2a3a7f4c104d50c14e22d412f66)

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-28 17:55:04 +01:00
Zoltán Böszörményi
e492d55d02 base/kernel: Support zstd-compressed squashfs and cpio initramfs
Enable zstd PACKAGECONFIG knob for squashfs-tools and add support for zstd
compressed initramfs and squashfs.

(From OE-Core rev: fa146049eec5f9730781830270cc9dc55a2146f7)

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-01 14:06:17 +01:00
Richard Purdie
3d2904cab5 kernel: Use unexpanded EXTENDPKGV
EXTENDPKGV can contain AUTOINC so use an expanded form in the variables allowing
for later expansion during packaging to avoid race issues over the variable and
the build failures that can result.

(From OE-Core rev: 1f93d2426d22c74893e8daec9bb939133c5737c2)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-01 12:07:38 +01:00
Zoltán Böszörményi
7768da3fe8 kernel.bbclass: Use full versions for inter-package dependencies
If the kernel configuration enables module signing but no key
is provided, then the kernel generates one during the kernel build.

The current runtime-dependency references (with only package names
without full versions) allow mixed package installations from different
rebuilds of the same kernel version.

This creates an issue because then the modules either don't work
or taint the kernel.

Tighten RDEPENDS with the full package version, i.e. use (= ${EXTENDPKGV})
markers for inter-package dependencies.

The kernel will pull in the kernel-modules subpackage of the same
exact version automatically if KERNEL_SPLIT_MODULES="0" is set.
Otherwise the situation is the same as with the old default with
one subpackage per kernel module where they have to be upgraded
manually.

(From OE-Core rev: 56428d15803733e14d6f1faf5f77eb933ef966f3)

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-27 11:54:34 +01:00
Zoltán Böszörményi
e6fae346ea Allow opt-out of split kernel modules
For some use cases, a monolithic kernel-modules package containing
all modules built from the kernel sources may be preferred.
For one, download time is shorter and installation time is faster.

Set KERNEL_SPLIT_MODULES="0" for this in. The default is one subpackage
per module.

Also, adapt kernel.bbclass to KERNEL_SPLIT_MODULES != "1" case
Extra RDEPENDS and other inter-package references are needed in
this case.

(From OE-Core rev: 4b13409d82e9d576e32b978f7a42a143127ab894)

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-27 11:54:33 +01:00
Richard Purdie
bb6ddc3691 Convert to new override syntax
This is the result of automated script conversion:

scripts/contrib/convert-overrides.py <oe-core directory>

converting the metadata to use ":" as the override character instead of "_".

(From OE-Core rev: 42344347be29f0997cc2f7636d9603b1fe1875ae)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-02 15:44:10 +01:00
Richard Purdie
10b39fb94b kernel: Fix interaction when packaging disabled
When packaging is disabled using the nopackages class, ensure we don't
add to PACKAGES. This fixes builds where we have an unpackaged kernel
alongside a packaged kernel.

(From OE-Core rev: 2522daf22e2c27dd9c7926feda0345978217c6c3)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-06-27 22:51:05 +01:00
Andrea Adami
b32f1ad879 kernel.bbclass: fix do_sizecheck() comparison
The routine do_sizecheck() was historically needed by legacy
devices with limited flash memory.
The lowest extreme is probably with Zaurus collie having exactly
1024*1024 = 1048576 bytes for the kernel partition.

In the years the KERNEL_IMAGE_MAXSIZE has been converted to kilobytes
thus rounded so we have now KERNEL_IMAGE_MAXSIZE_collie = "1024".

The effect is that now the check fails because we hit curiously this
 | WARNING: This kernel zImage (size=1024(K) > 1024(K)) is too big for...
even though zImage is 1047288 bytes (kernel + kexecboot-klibc-initramfs).

Fix this case using test -gt (greater) instead of -ge (greater or equal).

(From OE-Core rev: 254ca956d63b4ce6aa294213b60bb943f9f3a9e6)

Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-06-14 15:05:11 +01:00
Awais Belal
44ecc935b2 kernel.bbclass: fix deployment for initramfs images
The do_bundle_initramfs() only processes kernel image
types that are found in KERNEL_IMAGETYPE_FOR_MAKE whereas
the build system can generate other types that are not
directly supported by the kernel build system. In which
case when we come to the deploy phase not all the images
mentioned in KERNEL_IMAGETYPES would have a respective
initramfs bundled image. An example is using vmlinux.gz
in KERNEL_IMAGETYPES and enabling initramfs and then we
see

install: cannot stat 'arch/arm64/boot/vmlinux.gz.initramfs': No such file or directory

So we align the deploy phase with bundle initramfs phase
and pick up relevant initramfs bundled images using
KERNEL_IMAGETYPE_FOR_MAKE instead of KERNEL_IMAGETYPES.

(From OE-Core rev: 526bdd88ccd758204452579333ba188e29270bde)

Signed-off-by: Awais Belal <awais_belal@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-01-30 10:41:04 +00:00
Abdellatif El Khlifi
af6ac32437 kernel: skip installing fitImage when using Initramfs bundles
When including an initramfs bundle inside a FIT image, the fitImage is created
after the install task by do_assemble_fitimage_initramfs.

This happens after the generation of the initramfs bundle
(done by do_bundle_initramfs).

So, at the level of the install task we should not try to install the fitImage.
The fitImage is still not generated yet.

After the generation of the fitImage, the deploy task copies the fitImage from
the build directory to the deploy folder.

Change-Id: I3eaa6bba1412f388f710fa0f389f66631c1c4826
(From OE-Core rev: 1b67fd9ac74935fa41e960478c54e45422339138)

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-01-20 00:45:05 +00:00
Ross Burton
2d99b0993a kernel: set COMPATIBLE_HOST to *-linux
The target system triple contains whether the target is Linux or not,
so use it to avoid situations where you can attempt to build a kernel
for systems which don't support Linux.

(From OE-Core rev: b1eeeab21a81990321468ddbdd1745ea24d1828d)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-12-24 08:25:14 +00:00
Bruce Ashfield
d8f47a68a9 kernel: relocate copy of module.lds to module compilation task
There were two copies of this patch floating around, and the merged
variant has the copy in the wrong place.

module.lds is only created during modules_prepare, and that target is
not invoked during our main build of the kernel. We aren't about to
change the kernel build (there's no need), so we move the copy into
the compile_kernelmodules task. After that runs, we have module.lds
availble to copy.

This has been tested against clean kernel + out of tree module
builds, and the dependencies are correct that the file is copied
before the out of tree module build starts.

(From OE-Core rev: 7d94f9209ebaaf59ea001239a889dd7f928a0e7c)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-18 13:59:27 +00:00
Wonmin Jung
60a0a2fb1e kernel: Set proper LD in KERNEL_KCONFIG_COMMAND
With 'ld-is-gold' and linux kernel 5.4 or later, menuconfig
task for kernel recipes will fail with:

$ bitbake -c menuconfig virtual/kernel
...
scripts/kconfig/mconf  Kconfig
scripts/Kconfig.include:43:  gold linker 'x86_64-poky-linux-ld' not supported
/OE/build/tmp/work-shared/qemux86-64/kernel-source/scripts/kconfig/Makefile:29:
 recipe for target 'menuconfig' failed
make[2]: *** [menuconfig] Error 1
/OE/build/tmp/work-shared/qemux86-64/kernel-source/Makefile:606:
 recipe for target 'menuconfig' failed
make[1]: *** [menuconfig] Error 2
/OE/build/tmp/work-shared/qemux86-64/kernel-source/Makefile:185:
 recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2
Command failed.

This is because that the KERNEL_LD variable already set in
kernel-arch.bbclass isn't used by do_menuconfig function of
cml1.bbclass.

To fix this issue specify LD variable while calling the kernel
menuconfig command through KERNEL_KCONFIG_COMMAND.

(From OE-Core rev: 1faf66ce0b1f8f5165277161e07e25e672370c3f)

Signed-off-by: Wonmin Jung <wonmin82@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-17 21:53:13 +00:00
Bruce Ashfield
92eceb5f1d kernel: provide module.lds for out of tree builds in v5.10+
The upstream commit 596b0474d3d [kbuild: preprocess module linker
script], adds a dependency on module.lds for external module
building.

Since module.lds is generated as part of 'modules_prepare', we
must make it available with the other kernel artifacts in the
kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on
target module builds that are often prepared with 'make scripts
prepare'. Those targets won't regenerate it, so the build fails.
If 'make modules_prepare' is used, the file will be regenerated
and overwrite our copy (as expected).

(From OE-Core rev: 0fc66a0b64953aae38d0124b57615fffaec8de52)

Signed-off-by: Pan, Kris <kris.pan@intel.com>
Signed-off-by: Lili Li <lili.li@intel.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-16 14:27:46 +00:00
Rasmus Villemoes
cbf566ec43 kernel.bbclass: ensure symlink_kernsrc task gets run even with externalsrc
Commit c5dfc2586b41 (kernel.bbclass: run do_symlink_kernsrc before
do_patch) fixed a race between do_symlink_kernsrc and
do_populate_lic. However, I missed the fact that when
externalsrc.bbclass is in use, the do_patch task doesn't exist,
meaning that do_symlink_kernsrc now doesn't get run at all, breaking
the build.

We need this task to run regardless of whether do_patch exists or not,
so reinstate the configure->symlink_kernsrc dependency explicitly.

Fixes: c5dfc2586b41 (kernel.bbclass: run do_symlink_kernsrc before
do_patch)
Reported-by: Chanho Park <parkch98@gmail.com>

(From OE-Core rev: a2b50b74d609ce079ab36b82d4c7c3539fb56485)

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-28 14:15:48 +01:00
Martin Jansa
a00ca02fbd kernel.bbclass: use camelCase notation for bash variables in do_deploy
* to match other variables there like deployDir imageType

[YOCTO #12937]

(From OE-Core rev: 13c5d1b686255d385d200cbd06b7000080809fc7)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-17 09:47:45 +01:00
Martin Jansa
d1f5f2391e kernel.bbclass: eliminate (initramfs_)symlink_name variables
* they are used only once, we can use the value directly
* notice that .bin extension isn't part of the variable values

[YOCTO #12937]

(From OE-Core rev: 22874b43de45e86418f683eb9d4394d7a8a08033)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-17 09:47:45 +01:00
Martin Jansa
89c123119b kernel.bbclass: use bash variables like imageType, base_name without {}
* just to make sure it looks like bash variable not bitbake variable in
  run.do_* scripts

[YOCTO #12937]

(From OE-Core rev: 9a16dc2ac3d5e8ea95a575c377d3ad1602c1db12)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-09-17 09:47:45 +01:00
Mark Hatle
fc807c9de7 kernel.bbclass: Move away from calling package_get_auto_pr
...instead we call read_subpackage_metadata.

Calling package_get_auto_pr *should* result in the same PKGV AUTOINC
replacement.  However, it will also end up changing PKGR differently
then do_package as the BB_TASKHASH used will be for the wrong task.

Generally this won't cause any real-world issue, but it could cause
problems.

Moving to read_subpackage_metadata ensures that the values used
in do_package will be read in and used for kernel deployment.

(From OE-Core rev: 86142dad13935a0d9af4a4177e05ff5c39003db7)

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-28 07:08:37 +01:00
Mark Hatle
d3e8f2e335 kernel.bbclass: Remove do_install[prefunc] no longer needed
Prior work has refactored the do_install task multiple times, and any
references to PKGV and PKGR (even indirect ones) have been removed.

(From OE-Core rev: 36fe4db8ae827a93abe9fce6740459d215411965)

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-26 21:56:41 +01:00
Rasmus Villemoes
94ed64f375 kernel.bbclass: run do_symlink_kernsrc before do_patch
There's a race between do_symlink_kernsrc and do_populate_lic, since
the latter is ordered "after do_patch"; so the two may run in
parallel. In some cases, that actually causes do_populate_lic to fail
if it happens to look for a license file somewhere under ${S} in the
short window after shutil.move and before the symlink has been
created.

Fix that by simply ordering symlink_kernsrc before do_patch. Any task
that pokes around in ${S} looking for files should be ordered after
do_patch, so this should also fix similar latent races with other ad
hoc tasks.

(From OE-Core rev: c5dfc2586b4135cc86e91bb04fed837daf505676)

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-26 09:04:04 +01:00
Zhang Qiang
d23cfcf727 kernel.bbclass: Configuration for environment with HOSTCXX
When compiling xilinx-zynq board linux-kernel-dev(v5.8) if
"GCC_PLUGINS=y", The following error will appear:

"HOSTCXX -fPIC scripts/gcc-plugins/arm_ssp_per_task_plugin.o
fatal error: gmp.h: No such file or directory"

the GCC_PLUGINS depend on return result of gcc-plugin.sh execution
however in gcc-plugin.sh use HOSTCC to detect the feature of GNU
extension of gcc, this will result that HOSTCC can compile the file
successfully, but HOSTCXX is used in the actual compilation process.

(From OE-Core rev: 740d87766cb87f75c477666d97cb0480c10217f4)

Signed-off-by: Zhang Qiang <qiang.zhang@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-08-13 08:07:00 +01:00
Timon Ulrich
41bb61d8f1 kernel.bbclass: make dependency on lzop-native conditional
a native lzop is only needed when an lzo compressed initramfs is actually present

(From OE-Core rev: 1217ddf070261c5fe523729b2a833bd38f1e4ccd)

Signed-off-by: Timon Ulrich <t.ulrich@anapur.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-08 10:37:12 +01:00
Matt Madison
5e8f88570b kernel.bbclass: add gzip-native to do_deploy dependencies
When a modules tarball is created during kernel_do_deploy,
the tarball is compressed using gzip, but gzip-native is not
a dependency so the build host's gzip is being used for this.

Using gzip-native will, by default, use pigz instead of
single-threaded gzip, making this task less of a bottleneck
for builds with a large modules package.

(From OE-Core rev: 1243aad78601e9a5c0a3471c8a105c429536599d)

Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-08 10:37:12 +01:00
Yanfei Xu
8b6b95106a classes/kernel: Use a copy of image for kernel*.rpm if fs doesn't support symlinks
Some filesystems don't support symlink, then you will get failure when
you install or update the kernel rpm package. Now we use a copy of
image for these filesystems instead of symlink.

Suggested-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Suggested-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(From OE-Core rev: bb946b8cdbd01408bfa0ba8e53f9e09931dfb29d)

Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-05 15:04:40 +01:00
Timon Ulrich
cd96439c58 kernel.bbclass: add lz4 dependency and fix the call to lz4
If the initramfs image is type lz4, then a native lz4 is needed.

Additionally an output filename needs to be specified when calling lz4,
otherwise STDOUT will be used implicitly.

(From OE-Core rev: c83a7aec59defbbc049d44ba34a7a409ada4fa19)

Signed-off-by: Timon Ulrich <t.ulrich@anapur.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-05 15:04:40 +01:00
Daniel Klauer
62931865d5 deploy.bbclass: Clean DEPLOYDIR before do_deploy
do_deploy should clean up ${DEPLOYDIR} before running, just like do_install
cleans up ${D} before running. This reduces the risk of DEPLOYDIR being
accidentally contaminated by files from previous runs, possibly even with
different config, in case of incremental builds.

It is convenient to have this in deploy.bbclass, so it doesn't have to be
duplicated in every recipe, considering for example meta-freescale, which
has 23 affected recipes.

All recipes using deploy.bbclass (grep -r 'inherit .*deploy') in poky,
meta-openembedded and meta-freescale look like they either benefit from
this or are at least not affected negatively by it. The only exception
I've noticed was uboot-sign.bbclass, which was however fixed by the
previous patch.

(From OE-Core rev: 7083a7d56f4d90c81d2e6652ee291d20fd908bbe)

Signed-off-by: Daniel Klauer <daniel.klauer@gin.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-06-30 23:03:02 +01:00
Lili Li
05043a26cc kernel.bbclass: Fix Module.symvers support
Starting from v5.8-rc1 commit 269a535ca931 (modpost: generate
vmlinux.symvers and reuse it for the second modpost"), kernel will
generate new vmlinux.symvers instead of dumping all the vmlinux symbols
into Module.symvers in the first pass.

Error log:
    'run.do_shared_workdir.16614' failed with exit code 1:
    DEBUG: cp: cannot stat 'Module.symvers': No such file or directory

This change will check the file Module.symvers existence before copying it.

(From OE-Core rev: cd2d62a08a1dfcd890a03ee55132b6d6c65f5ab7)

Signed-off-by: Lili Li <lili.li@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-06-28 08:35:59 +01:00
Li Wang
df1e1dc92e linux-modules.tgz: fix file permissions to root
the files of linux-modules should be same permissions with rootfs.tar.bz2,
because it is a part of rootfs when used to install.

(From OE-Core rev: 71e141906069c6f754199512741f6e3d5b72fee7)

Signed-off-by: Li Wang <li.wang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-22 17:07:44 +01:00
Bruce Ashfield
68ad047228 kernel/reproducibility: kernel modules need SOURCE_DATE_EPOCH export
If CONFIG_IKHEADERS is set to =m, then reproducibility issues creep
into the modules build, since the variables we are setting for the
main kernel build are not present.

Since the source code must be available for a possibly git query
on the timestamp, there didn't seem to be an easy way to move the
environment variable setting to a common routine. As such, we
duplicate the block of code that exports the required variables for
reproducible builds. There is a maintenance risk to this, but any
issues should be easy enough to catch.

(From OE-Core rev: 82cdfcdccfedd320ebc0cdc778c7d4966198b96f)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-15 16:31:45 +01:00
Joshua Watt
54865c7c1e classes/kernel: Generate reproducible kernel module tarball
If reproducible binaries are requested, generate the kernel modules
tarball in a reproducible way. Namely, sort the tarball contents, clamp
the mtime to the source date epoch, compress the archive with a
consistent compression level (9), and don't include the name and
timestamp in the compressed file.

[YOCTO #12719]

(From OE-Core rev: 5c6a472c82a9b3c122fc54d3ee7171508c643a8b)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-14 14:15:11 +01:00
Christopher Clark
2ac00852cd kernel.bbclass: fix SOURCE_DATE_EPOCH for non-git kernel builds
The source directory is not always a git repository, so when querying
git for data to set SOURCE_DATE_EPOCH, specify ${S}/.git as the git
directory to prevent retrieving incorrect data from any parent directory.

Fixes the following errors with the prior logic when building a kernel
that is not obtained from a git repository:

1. With TMPDIR set to a directory outside any git repository on a
mounted filesystem, reproducible builds fail in do_compile with this git
error:

  fatal: not a git repository (or any parent up to mount point <abspath>)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

aborting before the error handling logic.

2. With TMPDIR located within a subdirectory of a git repository, the
SOURCE_DATE_EPOCH timestamp would be that of said repository rather than
that of the kernel.

(From OE-Core rev: 270ae94fe345b9ce98d822034cbfad7e24c5f393)

Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-03-10 23:20:33 +00:00