Commit Graph

303 Commits

Author SHA1 Message Date
Haiqing Bai
9729d05975 kernel.bbclass: Make task clean depend on cleaning of make-mod-scripts
The package 'make-mod-scripts' creates files in 'kernel-build-artifacts/include/config'
which are removed by 'cleanall/cleansstate' of 'virtual/kernel'. And this causes the
below error while building out of tree kernel module:
ERROR: Kernel configuration is invalid.
      include/generated/autoconf.h or include/config/auto.conf are missing.
      Run 'make oldconfig && make prepare' on kernel src to fix it.

Suggested-by: Jun Nie <jun.nie@linaro.org>

(From OE-Core rev: f79c95f6a883e999e0c2ecfd60b6b696b7595497)

Signed-off-by: Haiqing Bai <Haiqing.Bai@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-06-11 13:26:55 +01:00
Bruce Ashfield
412b88d052 kernel: package modules.builtin.modinfo
As of commit 898490c010b [moduleparam: Save information about built-in
modules in separate file] (kernels v5.2-rc1+), modules.builtin.modinfo
is generated as part of the kernel build process.

We package it along with the other module artifacts, so it can be used
by scripts/other build steps.

(From OE-Core rev: 112a4d3b2b4a829dd5657b6533b1c1bb589d6c8e)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-31 15:36:20 +01:00
Ming Liu
ea8755459f kernel.bbclass: adjust a condition checking
do_bundle_initramfs does not have to depend on
${INITRAMFS_IMAGE}:do_image_complete if INITRAMFS_IMAGE_BUNDLE is not
set.

(From OE-Core rev: 6676411fccff2d331878e4ca1f9411aafb056a80)

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-16 09:16:50 +01:00
Steven Hung (洪于玉)
bd50ff2cd0 kernel.bbclass: convert base_do_unpack_append() to a task
<pre>
when&#32;externalsrc&#32;is&#32;enabled&#32;and&#32;the&#32;&#39;do_unpack&#39;&#32;task&#32;is&#32;deleted,
building&#32;kernel&#32;module&#32;fail

(From OE-Core rev: 1ba4728f058b90957741fa016230ffa72e206ff3)

Signed-off-by:&#32;Steven&#32;Hung&#32;(&#27946;&#20110;&#29577;)&#32;&lt;Steven.Hung@mediatek.com&gt;
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-23 23:30:19 +01:00
Justin Bronder
a2938316e3 kernel: add objtool to shared workdir when CONFIG_UNWINDER_ORC is set
Based on: https://patchwork.openembedded.org/patch/148047/

When x86_64 enables CONFIG_UNWINDER_ORC [ORC (Oops Rewind Capability)
unwinder for unwinding kernel stack traces], objtool is required to
generate the required information.

If we don't copy objtool to the shared workdir, out-of-tree modules
cannot generate object files.

For instance, meta-skeleton/hello-mod fails with:
    | make[3]: *** No rule to make target 'tools/objtool/objtool', needed by ...

(From OE-Core rev: 7d4fdd3b95c949277f77df90bb2e8120b8d167ae)

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-03-02 16:49:07 +00:00
Richard Purdie
a5b7c86f23 kernel: Ensure an initramfs is added if configured
If ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio does not exist,
nor any of the compressed variants, nothing is copied to kernel build's
./usr directory.

The code does not fail, but silently proceeds without a bundled initramfs.

Change to fail and tell the user something is wrong.

Also, if an initramfs is found, contrary to the comments, it does not stop
at the first uncompressed/compressed cpio image found. Instead it keeps
processing all so the last is used. Fix this to behave as per the comments.

[YOCTO #12909]

(Patch by Leon Woestenberg)

(From OE-Core rev: 5b5604e288af755eb5553a97d26533445b2cf94b)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-25 10:43:06 +00:00
Richard Purdie
cd4b8a8553 meta: Fix Deprecated warnings from regexs
Fix handling of escape characters in regexs and hence fix python
Deprecation warnings which will be problematic in python 3.8.

Note that some show up as:

"""
meta/classes/package.bbclass:1293: DeprecationWarning: invalid escape sequence \.  

"""

where the problem isn't on 1293 in package.bbclass but in some _prepend to a
package.bbclass function in a different file like mesa.inc, often from
do_package_split() calls.

(From OE-Core rev: 4b1c0c7d5525fc4cea9e0f02ec54e92a6fbc6199)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-01-16 15:35:07 +00:00
Manjukumar Matha
6a080d90e5 kernel.bbclass: Fix incorrect deploying of fitimage.initramfs
When kernel-fitimage and initramfs is enabled using
INITRAMFS_IMAGE_BUNDLE = "1", kernel do_deploy tries to deploy
fitImage.initramfs with following error

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

Skip deploying fitimage.initramfs, since fitimage does not
create fitimage.initramfs

(From OE-Core rev: 0f87f8522a2c1b5a7042738887952b98060fbd9d)

Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-01-07 10:54:13 +00:00
Federico Sauter
6aef6271e1 kernel: don't assign the build user/host
The KBUILD_BUILD_USER and KBUILD_BUILD_HOST variables were
assigned at the kernel class level, which made it impossible
to override them in the local configuration.

By setting only the default values of those variables in the
kernel class, it is now possible to override them as expected.

(From OE-Core rev: a3e8cdf9c3ba966fa4b5a21235540eb0b00fb487)

Signed-off-by: Federico Sauter <federico.sauter@ableton.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-08 17:17:01 +00:00
Bruce Ashfield
d2aaa2614a kernel: use olddefconfig as the primary target for KERNEL_CONFIG_COMMAND
As was warned by commit 312ee68752fa [kconfig: announce removal of
oldnoconfig if used], oldnoconfig has been removed from the 4.20 kernel.

So we switch our default mode to olddefconfig.

commit fb16d8912 [kconfig: replace 'oldnoconfig' with 'olddefconfig',
and keep the old name as an alias] introduced olddefconfig in the 3.10
kernel, we shuffle oldnoconfig to the fallback target.

The fallback mode allows kernels between 3.10 and the currently listed
oldest kernel of 3.2 to continue to configure.

(From OE-Core rev: 8593dcb7e8c938530ff00ffedf7f3d02d26c3bad)

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-14 11:14:38 +00:00
Ioan-Adrian Ratiu
519aaef791 kernel.bbclass: allow custom KERNEL_IMAGEDEST
Some distros want to install the kernel in a custom location other
than /boot and have it properly packaged, so it's useful to use a
weaker assignment.

(From OE-Core rev: cadd91655a336eb6d65ca43dc1231bbe5271e1cf)

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-25 14:53:44 +01:00
Alex Kiernan
ce80e2572c kernel.bbclass: Avoid iterating over KERNEL_IMAGETYPES twice
During deploy we iterate over KERNEL_IMAGETYPES twice, with no consumer
of our changes in the interim. Collapse these two loops into one.

(From OE-Core rev: 8d3139640ed4cd4e196dc2d1f6ae02d612fb9564)

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-22 15:52:12 -07:00
Alex Kiernan
b492b08a4d kernel: Fix modules tarball generation with usrmerge
When usrmerge is enabled the kernel modules aren't under /lib, but /usr/lib;
ensure we fetch the modules from the correct location so we don't have a
tarball which consists of a single symlink.

(From OE-Core rev: 62d2d7d12dda69d6019a1a2d5492450487e41bfd)

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-22 15:52:12 -07:00
Alex Kiernan
4a49f5f617 Revert "kernel.bbclass: do not deploy fitImage; kernel-fitimage.bbclass does that."
This reverts commit 65cded55fa96b1ba72149a31689c081ac27af7f7.

The fitImage deployed here is the one generated in kernel-fitimage.bbclass,
whereas the one deployed by kernel-fitimage.bbclass is a raw image, so we
need the one deployed here keeping.

(From OE-Core rev: 798d2acc0141b13da7ddd18875a417b2df9d57b3)

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-22 15:52:12 -07:00
Leon Woestenberg
c2d00e2f83 kernel.bbclass: do not deploy fitImage; kernel-fitimage.bbclass does that.
kernel-fitimage.bbclass replaces an occurance of "fitImage" in
KERNEL_IMAGETYPE_FOR_MAKE by an image type that is buildable for the
architecture (such as zImage). The kernel-fitimage.bbclass packs that
image as sub-image in a flattened image tree image (fitImage) and
deploys this fitImage along with the image tree source file (.its).

kernel-fitimage.bbclass does not alter KERNEL_IMAGETYPES, which thus
also contains "fitImage", which kernel.bbclass will also deploy
redundantly with different naming.

The result is a dual deployment with slightly different naming,
each with a set of symlinks.

The solution chosen is to have fitImage deployment be handled by
kernel-fitimage.bbclass, and have kernel.bbclass ignore fitImage
types during deployment.

(From OE-Core rev: 65cded55fa96b1ba72149a31689c081ac27af7f7)

Signed-off-by: Leon Woestenberg <leon@sidebranch.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-13 07:42:28 +01:00
Martin Jansa
2a72190ba7 kernel.bbclass: rename type variable to imageType
* to avoid confusion with "type" command in shell

(From OE-Core rev: 8d454ea754c96561257b1cc011fa638ceaa771db)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-21 14:49:42 +01:00
Martin Jansa
b7d0d0b44f kernel-artifact-names.bbclass, kernel.bbclass: remove prefix and extension from MODULE_TARBALL_* variables
* for consistency with other artifacts variables, include only the version string, not the actual name or extension
* changing .tgz to something else in the MODULE_TARBALL_NAME variable only wouldn't make much sense
  because then kernel.bbclass still calls "tar -cvzf" to create it

(From OE-Core rev: 43bd7f39157da49f7fb0c2d6d9751059471c8d53)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-21 14:49:42 +01:00
Martin Jansa
f09947586c kernel*.bbclass: rename *_SYMLINK_NAME variables to *_LINK_NAME and *_BASE_NAME to *_NAME
* for consistency with IMAGE_NAME and IMAGE_LINK_NAME
  and to avoid confusion with IMAGE_BASENAME (which is the
  actual name of the artifact, e.g. PN while KERNEL_IMAGE_BASE_NAME
  was only the version suffix)

(From OE-Core rev: f952c8e08b4798aa0f8bf764cfd70bda0eae9b8b)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-21 14:49:42 +01:00
Martin Jansa
d0389bf1cd kernel.bbclass: move variables for kernel artifacts names to separate bbclass
* this makes it easier to access these variables from some other bbclass
  e.g. sdcard_image-rpi.bbclass in meta-raspberry where we need to know
  how some files in deploy are named, but we cannot inherit kernel.bbclass
  as it's used in image recipe not kernel recipe
* alternatively we can move these to bitbake.conf like similar image variables are:
  meta/conf/bitbake.conf:IMAGE_BASENAME = "${PN}"
  meta/conf/bitbake.conf:IMAGE_NAME = "${IMAGE_BASENAME}-${MACHINE}-${DATETIME}"
  meta/conf/bitbake.conf:IMAGE_LINK_NAME = "${IMAGE_BASENAME}-${MACHINE}"

(From OE-Core rev: 7d0ef0eaa1bfe97015a774c26f5791622e7e8b12)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-10 17:33:00 +01:00
Martin Jansa
c159b6249a kernel.bbclass: use the consistent naming schema for initramfs
* use INITRAMFS_BASE_NAME and INITRAMFS_SYMLINK_NAME variables, like
  other kernel artifacts are using
* use "${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" instead of
  "${PV}-${PR}-${MACHINE}-${DATETIME}" to be consistent with other files
* allow to modify default symlink name with INITRAMFS_SYMLINK_NAME
  instead of currently used:
  initramfs_symlink_name=${type}-initramfs-${MACHINE}

(From OE-Core rev: 935b9d5a2bd12effad65f69a631ecff96b8bb553)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-10 17:33:00 +01:00
Martin Jansa
c5b70d7155 kernel-devicetree.bbclass: Fix and simplify instalation of DTB files
* add 2 new variables:
  KERNEL_DTB_BASE_NAME
  KERNEL_DTB_SYMLINK_NAME
  instead of reusing KERNEL_IMAGE_SYMLINK_NAME and than expecting that
  default value ${MACHINE} was being used in e.g.:
  DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`

* install normal DTB files only once even if there is multiple entries
  in KERNEL_IMAGETYPE_FOR_MAKE and don't prefix them with the type of
  the kernel image, use the KERNEL_IMAGETYPE_FOR_MAKE as a prefix only
  when installing them bundled with kernel or initramfs image.

* deploy the files from ${D}/${KERNEL_IMAGEDEST}/ instead of kernel
  build directory, so that we don't need to call
  DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
  again in do_deploy

* create all links in do_deploy task, because default KERNEL_DTB_BASE_NAME
  like KERNEL_IMAGE_BASE_NAME contains PKGR and PKGR is different in
  do_install and do_deploy, because kernel.bbclass calls
  meta/classes/kernel.bbclass:do_install[prefuncs] += "package_get_auto_pr"
  meta/classes/kernel.bbclass:do_deploy[prefuncs] += "package_get_auto_pr"

* the filenames are a bit different, but with separate variable it
  should be easier for other bbclasses which use these DTB files to
  find them correctly, just use either the cannonical name
  $dtb_base_name.$dtb_ext or $dtb_base_name-${KERNEL_DTB_SYMLINK_NAME}.$dtb_ext
  because PKGR (and other PKG* variables) might be different in your
  task and kernel.do_deploy task.

* fix DTB files being deployed with incorrect filenames when
  KERNEL_IMAGE_SYMLINK_NAME isn't set to ${MACHINE}, e.g. instead of
  the default:
-rw-r--r-- 2 bitbake bitbake 1.4K Nov 20 07:41 deploy/images/raspberrypi3-64/Image-1-4.9.59+git0+e7976b2aff-r0.2-lirc-rpi-20171120043031.dtbo
lrwxrwxrwx 2 bitbake bitbake   64 Nov 20 07:41 deploy/images/raspberrypi3-64/Image-lirc-rpi.dtbo -> Image-1-4.9.59+git0+e7976b2aff-r0.2-lirc-rpi-20171120043031.dtbo
lrwxrwxrwx 2 bitbake bitbake   64 Nov 20 07:41 deploy/images/raspberrypi3-64/lirc-rpi.dtbo -> Image-1-4.9.59+git0+e7976b2aff-r0.2-lirc-rpi-20171120043031.dtbo
  I was getting:
-rw-r--r-- 2 bitbake bitbake 1348 Nov 20 10:28 deploy/images/raspberrypi3-64/Image-linux-raspberrypi-lirc-rpi.dtbo
lrwxrwxrwx 2 bitbake bitbake   37 Nov 20 10:28 deploy/images/raspberrypi3-64/Image-linux-raspberrypi-lirc-rpi-master-20171120102653.dtbo -> Image-linux-raspberrypi-lirc-rpi.dtbo
lrwxrwxrwx 2 bitbake bitbake   37 Nov 20 10:28 deploy/images/raspberrypi3-64/lirc-rpi.dtbo -> Image-linux-raspberrypi-lirc-rpi.dtbo
  and e.g. sdcard_image-rpi.bbclass from meta-raspberrypi:
  37e4e18f4a/classes/sdcard_image-rpi.bbclass
  was failing in:
  mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb
  because ${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb doesn't exist in my
  build, due to
  DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
  not replacing whole "${KERNEL_IMAGE_SYMLINK_NAME}" (read ${MACHINE})
  with just ${DTB_BASE_NAME}

* with this change applied the deploy dir looks like this:
-rw-r--r-- 2 bitbake bitbake 1.4K Nov 20 15:49 deploy/images/raspberrypi3-64/lirc-rpi-1-4.9.59+git0+e7976b2aff-r0.8-raspberrypi3-64-20171120154716.dtbo
lrwxrwxrwx 2 bitbake bitbake   74 Nov 20 15:49 deploy/images/raspberrypi3-64/lirc-rpi.dtbo -> lirc-rpi-1-4.9.59+git0+e7976b2aff-r0.8-raspberrypi3-64-20171120154716.dtbo
lrwxrwxrwx 2 bitbake bitbake   74 Nov 20 15:49 deploy/images/raspberrypi3-64/lirc-rpi-raspberrypi3-64.dtbo -> lirc-rpi-1-4.9.59+git0+e7976b2aff-r0.8-raspberrypi3-64-20171120154716.dtbo
  and works correctly even with DISTRO using different naming scheme

* the sdcard_image-rpi.bbclass still needs to be modified, I've provided
  updated version here:
  https://github.com/agherzan/meta-raspberrypi/pull/159
* mpc8315e-rdb.conf MACHINE in meta-yocto-bsp also needs small fix:
  https://lists.yoctoproject.org/pipermail/poky/2018-July/011436.html

(From OE-Core rev: 1860d9d3c62e2e94cd68a809385873ffd8270b6d)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-10 17:32:59 +01:00
Alex Kiernan
8d33b69ed0 kernel: Set SOURCE_DATE_EPOCH to kernel git timestamp if not set
If SOURCE_DATE_EPOCH is unset (in addition to the existing "0" behaviour)
parse out the top most commit timestamp from the kernel tree to use as the
timestamp.

(From OE-Core rev: 2f0dd67a5a8d4269f5155004d532d8fa972b3223)

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-06-28 09:22:35 +01:00
Bruce Ashfield
81e8a52e8e kernel: specify dependencies for compilation for config tasks
With recent kernels (i.e. 4.17+) the configuration phase of the kernel
will check for capabilities/options of the compiler for CVE and other
mitigation support.

For a general kernel, we want to ensure that CC is fully defined when
the config targets are invoked (so the proper compiler will be checked).

For linux-yocto, we also need to specify the compiler/tools dependencies
for the configme task since it executes before configure and hence the
main kernel build DEPENDS will not always be in the sysroot before it
executes. Without those dependencies the kernel will be incorrectly
configured (i.e. bison is missing) or the configuration will fail the
mitigation tests.

[YOCTO #12757]

(From OE-Core rev: ff1bdd75d50f0ebac3d599e461685ace29559a82)

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-06-12 23:34:24 +01:00
Andre McCurdy
95a1d7aefa kernel.bbclass: avoid duplicates in KERNEL_IMAGETYPE_FOR_MAKE
Currently if KERNEL_IMAGETYPES contains both vmlinux and vmlinux.gz,
KERNEL_IMAGETYPE_FOR_MAKE will end up containing two copies of
vmlinux, which will result in two calls to "make vmlinux" from
kernel_do_compile().

Avoid duplicating vmlinux in KERNEL_IMAGETYPE_FOR_MAKE plus some
minor non-functional updates to formatting and comments.

(From OE-Core rev: 80455a0b6cce6d12a5b32194d0cad2e4c7f71599)

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-05-22 13:13:33 +01:00
Mike Crowe
0ef7994fd0 kernel: Permit overriding of KERNEL_IMAGETYPE_FOR_MAKE
Commit a1690131691507bbf5853540229b3ad775b836bf removed the ability of
recipes to set KERNEL_IMAGETYPE_FOR_MAKE. Fix that by letting recipes
continue to set their own KERNEL_IMAGETYPE_FOR_MAKE if they so wish.
They may have been doing so for a while, and don't want to have their
carefully-selected value trampled on by kernel.bbclass.

This may be required if the recipe itself wants to build one type of
kernel, but post-process it into a different type, rather like the
vmlinux->vmlinux.gz support provided by kernel.bbclass.

(From OE-Core rev: 38abd26fe7de321e0f1fc4895f754f34dee90f6c)

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-05-11 07:49:37 +01:00
Jonathan Liu
4ca75e4226 kernel.bbclass: improve reproducibility
Set KBUILD_BUILD_VERSION=1 to avoid build version being incremented on
every build. It is visible in the output of "cat /proc/version" after
the hash character.

(From OE-Core rev: 7fa32ee42c3320e9e2b24ef747e43484b719f617)

Signed-off-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-04-03 23:53:19 +01:00
California Sullivan
d5075b648b kernel.bbclass: set HOSTLDFLAGS in KCONFIG_CONFIG_COMMAND
Kernel v4.14 and newer contain the following in their Makefile:

HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS)
HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS)

This breaks our menuconfig, because it can no longer find ncurses if its
not on the host machine. This can be seen in linux-yocto-dev, for
example:

[clsulliv@clsulliv build]$ bitbake virtual/kernel -c menuconfig

  GEN     ./Makefile
  HOSTLD  scripts/kconfig/mconf
/home/clsulliv/yocto/poky/build/tmp/hosttools/ld: cannot find -lncurses
/home/clsulliv/yocto/poky/build/tmp/hosttools/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
make[3]: *** [scripts/Makefile.host:99: scripts/kconfig/mconf] Error 1
make[2]: *** [/home/clsulliv/yocto/poky/build/tmp/work-shared/intel-corei7-64/kernel-source/Makefile:504: menuconfig] Error 2
make[1]: *** [Makefile:146: sub-make] Error 2
make: *** [Makefile:24: __sub-make] Error 2
Command failed.
Press any key to continue...

Fix this by setting HOSTLDFLAGS to ${BUILD_LDFLAGS} in our
'make menuconfig' command.

(From OE-Core rev: 6afe8e211bfb3deb359194488f34a2c56f4b5ef6)

Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-03-20 09:59:32 +00:00
Juro Bystricky
98e852983c classes/recipes: Use expanded BUILD_REPRODUCIBLE_BINARIES value
Replace the occurences of BUILD_REPRODUCIBLE_BINARIES with expanded
values ${BUILD_REPRODUCIBLE_BINARIES} so the variable does not need to be
exported.

(From OE-Core rev: 27f87bbc8395a2481ef808465a62d213a6b678ac)

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-03-12 15:06:32 -07:00
Bruce Ashfield
128dd9ec60 kernel: make copying of crtsavres.o conditional
As of the 4.13 kernel, there are configuration + linker combinations
that do not need (or build) crtsavres.o for ppc64 targets. The commit
of interest is:

    commit efe0160cfd40a99c052a00e174787c1f4158a9cd
    Author: Nicholas Piggin <npiggin@gmail.com>
    Date:   Fri May 12 01:56:52 2017 +1000

        powerpc/64: Linker on-demand sfpr functions for modules

        For final link, the powerpc64 linker generates fpr save/restore
        functions on-demand, placing them in the .sfpr section. Starting with
        binutils 2.25, these can be provided for non-final links with
        --save-restore-funcs. Use that where possible for module links.

        This saves about 200 bytes per module (~60kB) on powernv defconfig
        build.

        Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
        Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

As such, our arch test for crtsavres.o is not enough, we add a secondary
existence check before trying the copy.

[YOCTO #12576]

(From OE-Core rev: af58819253a2d4526dc8871a17e1492bd1d92951)

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-03-08 15:28:04 -08:00
Denys Dmytriyenko
20e4d309e1 kernel.bbclass: explicitly depend on bison-native for deterministic builds
Explicitly depend on bison-native for deterministic builds, as it is required
for the build:

|   HOSTCC  scripts/basic/fixdep
|   GEN     ./Makefile
|   HOSTCC  scripts/kconfig/conf.o
|   YACC    scripts/kconfig/zconf.tab.c
| /bin/sh: bison: command not found
| scripts/Makefile.lib:217: recipe for target 'scripts/kconfig/zconf.tab.c' failed

In most cases, this dependency comes indirectly via toolchain dependencies,
specifically binutils-cross, which pulls bison-native. Different setups,
such as with external toolchain, would expose this problem, since correct
dependency is not marked explicitly.

(From OE-Core rev: d26b700553fe8fa21c2e42b04e11bb380d94ef36)

Signed-off-by: Denys Dmytriyenko <denys@ti.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-02-24 10:31:47 +00:00
Ross Burton
563a020870 meta: don't use deprecated functions from utils.bbclass
These functions were moved to meta/lib/oe in 2010 and the base_* functions in
utils.bbclass were intended to be a short-term compatibility layer.  They're
still used in a few places, so update the callers to use the new functions.

(From OE-Core rev: c97acbd034532895ce57c6717ed1b3ccc7900b0d)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-30 11:50:11 +00:00
Thomas Perrot
2acedd5632 kernel: Use KERNEL_IMAGETYPE_FOR_MAKE in do_bundle_initramfs
In the case of a fitImage the this step should be done on the
image use to assemble the fitImage.

(From OE-Core rev: a061c6bfd3a049a2c8d14bcfafd6e1837afb95e5)

Signed-off-by: Thomas Perrot <thomas.perrot@tupi.fr>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-19 12:37:13 +00:00
Andre McCurdy
f2d7b5b2ee kernel: drop unnecessary True options from calls to getVar
The older style calls (plus a bashism in kernel.bbclass, fixed
separately) were introduced via the recent change to add support for
multiple kernel packages:

  http://git.openembedded.org/openembedded-core/commit/?id=6c8c899849d101fd1b86aad0b8eed05c7c785924

(From OE-Core rev: e660ef68de3b3891a26ed6e10d96dc4efaf03ffc)

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-19 12:37:13 +00:00
Andre McCurdy
f4fb8ecb8a kernel.bbclass: drop legacy fallback to yes '' | make oldconfig
The "oldnoconfig" target has been supported since Linux 2.6.36.

According to OLDEST_KERNEL, the oldest kernel currently supported by
OE is 3.2.0, so the fallback to yes '' | make oldconfig is no longer
required.

(From OE-Core rev: 6abee5468e05333fbd9bd5ac8fc203a749ae3b3e)

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-18 12:50:36 +00:00
Ricardo Salveti
ef4caecccb kernel.bbclass: remove bashism in kernel_do_install
possible bashism in run.do_install line 163 (should be 'b = a'):
if [ "kernel" == "kernel" ]; then

Fixes "[: kernel: unexpected operator" when not using bash by default,
which causes the default kernel image link to not be created.

(From OE-Core rev: 9d82fffd24742a5eb40bcb9b9ecea01a42be0be6)

Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-14 09:11:57 +00:00
Haris Okanovic
5b4aab6b40 kernel: Add support for multiple kernel packages
Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
    to local.conf so that linux-yocto-tiny may build alongside
    the main kernel (linux-yocto).
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-linux"`
    to local.conf to install both kernel flavors in core-image-base.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" (linux-yocto recipe) selected to boot via symlink.

Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130

[YOCTO #11363]

(From OE-Core rev: 6c8c899849d101fd1b86aad0b8eed05c7c785924)

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-02 17:24:37 +00:00
Mike Crowe
bbef2327f8 kernel.bbclass: Fix do_sizecheck behaviour
During the introduction of support for multiple kernel image types in
849b67b2e4820564b5e5c9bd4bb293c44351c5f3, do_sizecheck was changed to only
warn if any kernel was bigger than ${KERNEL_IMAGE_MAXSIZE}. (Well, it tried
to warn - it turns out that there's no function called "warn", it should be
"bbwarn".) The previous behaviour had been to fail the build if the single
kernel image did not fit.

It seems possible that people might be generating both compressed and
uncompressed kernels and only really care whether the compressed one fits.
This means that we shouldn't just always fail if any of the images are too
large. So, let's warn (correctly this time) on every image that is too
large, but only ultimately fail if no image will fit. The build will also
fail if ${KERNEL_IMAGETYPES} is empty, but I hope that no-one needs to do
that.

While we're here correct a typo in the KERNEL_IMAGE_MAXSIZE validity check.

(From OE-Core rev: 59f1ee104d1a6c04b0690b7c8ce481449da174d6)

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-02 17:24:37 +00:00
Saul Wold
f295c1e944 kernel.bbclass: Add cleandirs for do_shared_workdir
We add the kernel-build-artifacts to the cleandirs list to ensure
that there are no remaining artificats in the kernel-build-artifacts
directory which is STAGING_KERNEL_BUILDDIR. Without this change
multiple System.map files are visiable in the STAGING_KERNEL_BUILDDIR,
which could cause problems for some tools.

[YOCTO #11880]

(From OE-Core rev: d52a65d3d8512eeb5081d9fb5f18805428358241)

Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-12-10 22:45:18 +00:00
Wenzong Fan
59106e5dce kernel.bbclass: build host programs with native sysroots
Allow to search header files and libs from native sysroots.

For example, an expanded BUILD_CFLAGS includes:
  '-isystem/builddir/to/linux-yocto/recipe-sysroot-native/usr/include'

And an expanded BUILD_LDFLAGS includes:
  '-L/builddir/to/linux-yocto/recipe-sysroot-native/usr/lib
   -Wl,-rpath-link,/builddir/to/linux-yocto/recipe-sysroot-native/usr/lib
   -Wl,-rpath,/builddir/to/linux-yocto/recipe-sysroot-native/usr/lib'

(From OE-Core rev: 37f20f2f7bdc8b964736c09371cd8f2342e4d5cb)

Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-09-21 09:24:25 +01:00
Otavio Salvador
53067c4a97 kernel: Move Device Tree support to kernel.bbclass
The Device Tree is commonly used but it is still kept as a .inc file
instead of a proper class. Instead now we move the Device Tree code to
a kernel-devicetree class and automatically enable it when the
KERNEL_DEVICETREE variable is set.

To avoid breakage in existing layers, we kept a linux-dtb.inc file
which raises a warning telling the user about the change so in next
release this can be removed.

(From OE-Core rev: 03a00be7f2062aefef0e51ef20a4c9737f6685e7)

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-09-13 22:07:42 +01:00
Otavio Salvador
cb91b0eacd kernel: Stop using update-alternatives
The update-alternatives where using relative links so not being really
in use since December 2016 (see OE-Core:c7bc46b9 "kernel: Fix
symlinks") so instead we now generate the relative symlinks during the
do_install task and drop the update-alternatives use at all.

Acked-by: Saul Wold <sgw@linux.intel.com>
(From OE-Core rev: 10a1b293191268e6792ac8e27bd6427f1974c7ce)

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-09-11 17:30:28 +01:00
Juro Bystricky
06ff0a9c8a kernel.bbclass: external toolchain fix
Refactor get_cc_option so it is simpler and also does not fail
when using external toolchain.

(From OE-Core rev: d4564ee59df907d1e01a3610ac88a35f9a78c1ce)

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-23 12:06:51 +01:00
Juro Bystricky
55e9485735 kernel.bbclass: improve reproducibility
Several tweaks to improve reproducibility:

1. If BUILD_REPRODUCIBLE_BINARIES == 1, set KBUILD_BUILD_TIMESTAMP
to a reproducible value. This is either a non-zero SOURCE_DATE_EPOCH, or the
value obtained from top entry of GIT repo, or (if there is no GIT repo)
fallback to REPRODUCIBLE_TIMESTAMP_ROOTFS as the last resort.
Also export KCONFIG_NOTIMESTAMP=1.

2. When compressing vmlinux.gz, use gzip "-n" option

3. Kernel and kernel modules contain hard coded paths referencing the host
build system. This is usually because the source code contains __FILE__
at some place. This prevents binary reproducibility. However, some compilers
allow remapping of the __FILE__ value. If we detect the compiler is capable
of doing this, we replace the source path $(S) part of __FILE__ by a string "/kernel-source".
For example:

​/data/master/build/tmp/work-shared/qemux86/kernel-source/drivers/media/v4l2-core/videobuf2-core.​c

will be replaced by a reproducible value:

/kernel-source/drivers/media/v4l2-core/videobuf2-core.c.

(From OE-Core rev: 012a70da7ae0617740cd0cf807d01c3cd912c823)

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-16 00:03:15 +01:00
Mikko Rapeli
1d9a27d0cd kernel.bbclass: set CVE_PRODUCT to linux_kernel if not set by recipe
It is used by NVD database CVE's like:

https://nvd.nist.gov/vuln/detail/CVE-2017-7273

Setting this in kernel.bbclass fixes CVE reporting for all users of
the class.

(From OE-Core rev: 2e3d325440a50265c73f7d2e782530a02458bc33)

Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-24 09:13:31 +01:00
Nicolas Dechesne
9c800996e5 kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz
KERNEL_IMAGETYPES lists all the kernel images that we want to build. in
cb17b6c2a7 (kernel.bbclass: support kernel image type of vmlinux.gz), some logic
was added to support vmlinux.gz which is not a target built by kernel
makefiles (only vmlinux). It is clear that the goal of this logic is only to
support vmlinux.gz and not others compressed format (such as Image.gz) which are
valid target for kernel makefiles.

For Image.gz we should rely on the kernel makefiles and not do the compression
in kernel class.

This patch updates the logic used to filter out non supported kernel target from
KERNEL_IMAGETYPES, and make vmlinux.gz a 'special case', instead of *.gz. If
more special cases are needed in the future, we could add them in a similar way.

This patch should be a no-op for anyone using vmlinux or vmlinux.gz, and on top
of that it is fixing the build for Image.gz which was not working until now.

(From OE-Core rev: cfc0c897656fe67e81a6a5dcd936dff785529f41)

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-05 09:19:51 +01:00
Joshua Lock
8da8909b7b kernel: predefine KBUILD_BUILD_USER and KBUILD_BUILD_HOST
By exporting KBUILD_BUILD_USER with a pre-defined value we improve the
reproducibility of the kernel and remove the requirement for whoami in the
HOSTTOOLS.
KBUILD_BUILD_HOST also helps improve the reproducibility of the kernel.

For more kernel reproducibility options see:
https://lwn.net/Articles/437864/

(From OE-Core rev: a5a14edb5573e33667b63b1e34cb4e19d075e8e8)

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-05-25 23:59:31 +01:00
Ming Liu
5e3a636b20 kernel.bbclass: move in addtask kernel_link_images statement from linux-yocto.inc
Add kernel_link_images task in kernel.bbclass instead of adding it in
linux-yocto.inc, or else the recipes inheriting kernel.bbclass might
run into implicit dependency issues.

(From OE-Core rev: 3211d43d80f69d9c200a0e4f90fd37736046aafe)

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-05 23:22:12 +01:00
Ming Liu
c09a0631b5 kernel.bbclass: introduce INITRAMFS_IMAGE_NAME
It defaults to ${INITRAMFS_IMAGE}-${MACHINE} if INITRAMFS_IMAGE is not
empty.

This allows the end users to be able to override the initramfs image
name with a customized value.

(From OE-Core rev: e788fb2b894852f71b1c545abde71b45b9f230dc)

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-01 08:14:58 +01:00
Ming Liu
35565057fa kernel.bbclass: fix a typo
In a addtask statement, do_strip should be strip.

(From OE-Core rev: 8413e26164644230615f4503ca9488b5b4021aeb)

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-01 08:14:58 +01:00
Amarnath Valluri
0decf1cc1c kernel: use ${nonarch_base_libdir} for kernel modules installation.
Replace hardcoded '/lib' in kernel modules installation path with
${nonarch_base_libdir}, which is meant exactly for this.

(From OE-Core rev: 22f5ba7154fcbe826d0a3283740903312b2aab46)

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-22 11:35:20 +00:00