module.bbclass: Add KERNEL_SRC in EXTRA_OEMAKE
PATCH 1/8 module.bbclass: Add KERNEL_SRC in EXTRA_OEMAKE
From: Otavio Salvador <[email protected]>
When the sstate hash changes for do_configure task, the do_configure default implementation triggers the 'clean' to be run. For it to succeed we need to have KERNEL_SRC defined in EXTRA_OEMAKE. Fixes following error:
,----
| DEBUG: Executing shell function do_configure | NOTE: make -e MAKEFLAGS= clean | make -C M=.../tmp/work/... clean | make[1]: *** M=.../tmp/work/...: No such file or directory. Stop. | Makefile:20: recipe for target 'clean' failed | make: *** [clean] Error 2 | ERROR: oe_runmake failed
`----
--- meta/classes/module.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/module.bbclass +2 -2
@@ -6,10 +6,11 @@ addtask make_scripts after do_patch before do_compile do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock" do_make_scripts[deptask] = "do_populate_sysroot" +EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}" + module_do_compile() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \ - KERNEL_SRC=${STAGING_KERNEL_DIR} \ KERNEL_VERSION=${KERNEL_VERSION} \ CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ AR="${KERNEL_AR}" \
@@ -19,7 +20,6 @@ module_do_compile() { module_do_install() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" \ - KERNEL_SRC=${STAGING_KERNEL_DIR} \ CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ modules_install }
Signature · 1 line
1.7.10.4
PATCH 2/8 kernel.bbclass: When linux/version.h exists, copy it
From: Otavio Salvador <[email protected]>
Old Linux kernel versions rely on linux/version.h for modules; this needs to be published for external modules to use. Copy it when available.
--- meta/classes/kernel.bbclass | 4 ++++ 1 file changed, 4 insertions(+)
meta/classes/kernel.bbclass +4 -0
@@ -252,6 +252,10 @@ kernel_do_install() { cp .config $kerneldir/ mkdir -p $kerneldir/include/config cp include/config/kernel.release $kerneldir/include/config/kernel.release + if [ -e include/linux/version.h ]; then + mkdir -p $kerneldir/include/linux + cp include/linux/version.h $kerneldir/include/linux/version.h + fi # As of Linux kernel version 3.0.1, the clean target removes # arch/powerpc/lib/crtsavres.o which is present in
Signature · 1 line
1.7.10.4
PATCH 3/8 kernel: move source and build output to work-shared
In reply to Ross BurtonFrom: Bruce Ashfield <[email protected]>
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location.
This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts".
External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build.
--- meta/classes/kernel-module-split.bbclass | 2 +- meta/classes/kernel.bbclass | 30 +++++++++++++--------- meta/classes/module-base.bbclass | 12 +++++++-- meta/classes/module.bbclass | 2 ++ meta/conf/bitbake.conf | 3 ++- meta/recipes-kernel/linux/kernel-devsrc.bb | 14 +++++++--- meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb | 2 +- meta/recipes-kernel/perf/perf.bb | 2 +- 8 files changed, 46 insertions(+), 21 deletions(-)
meta/classes/kernel-module-split.bbclass +1 -1
@@ -70,7 +70,7 @@ python split_kernel_module_packages () { m = kerverrexp.match(kernelver) if m: kernelver_stripped = m.group(1) - staging_kernel_dir = d.getVar("STAGING_KERNEL_DIR", True) + staging_kernel_dir = d.getVar("STAGING_KERNEL_BUILDDIR", True) system_map_file = "%s/boot/System.map-%s" % (dvar, kernelver) if not os.path.exists(system_map_file): system_map_file = "%s/System.map-%s" % (staging_kernel_dir, kernelver)
meta/classes/kernel.bbclass +18 -12
@@ -230,28 +230,33 @@ kernel_do_install() { [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} install -d ${D}${sysconfdir}/modules-load.d install -d ${D}${sysconfdir}/modprobe.d +} +do_install[prefuncs] += "package_get_auto_pr" - # - # Support for external module building - create a minimal copy of the - # kernel source tree. - # - kerneldir=${D}${KERNEL_SRC_PATH} +addtask shared_workdir after do_compile before do_install + +do_shared_workdir () { + cd ${B} + + kerneldir=${STAGING_KERNEL_BUILDDIR} install -d $kerneldir - mkdir -p ${D}/lib/modules/${KERNEL_VERSION} - ln -sf ${KERNEL_SRC_PATH} "${D}/lib/modules/${KERNEL_VERSION}/build" # # Store the kernel version in sysroots for module-base.bbclass # echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion - + # Copy files required for module builds cp System.map $kerneldir/System.map-${KERNEL_VERSION} cp Module.symvers $kerneldir/ cp .config $kerneldir/ mkdir -p $kerneldir/include/config cp include/config/kernel.release $kerneldir/include/config/kernel.release + + # We can also copy over all the generated files and avoid special cases + # like version.h, but we've opted to keep this small until file creep starts + # to happen if [ -e include/linux/version.h ]; then mkdir -p $kerneldir/include/linux cp include/linux/version.h $kerneldir/include/linux/version.h
@@ -273,10 +278,11 @@ kernel_do_install() { cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ fi } -do_install[prefuncs] += "package_get_auto_pr" -python sysroot_stage_all () { - oe.path.copyhardlinktree(d.expand("${D}${KERNEL_SRC_PATH}"), d.expand("${SYSROOT_DESTDIR}${KERNEL_SRC_PATH}")) +# We have an empty sysroot_stage_all to keep the default routine from +# package.bbclass from expanding the kernel source into the sysroot and +# colliding with linux-firmware files +sysroot_stage_all () { } KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig || yes '' | oe_runmake -C ${S} O=${B} oldconfig"
@@ -467,7 +473,7 @@ kernel_do_deploy() { do_deploy[dirs] = "${DEPLOYDIR} ${B}" do_deploy[prefuncs] += "package_get_auto_pr" -addtask deploy before do_build after do_install +addtask deploy after do_populate_sysroot EXPORT_FUNCTIONS do_deploy
meta/classes/module-base.bbclass +10 -2
@@ -3,16 +3,24 @@ inherit kernel-arch export OS = "${TARGET_OS}" export CROSS_COMPILE = "${TARGET_PREFIX}" -export KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-abiversion')}" +# This points to the build artefacts from the main kernel build +# such as .config and System.map +# Confusingly it is not the module build output (which is ${B}) but +# we didn't pick the name. +export KBUILD_OUTPUT = "${STAGING_KERNEL_BUILDDIR}" + +export KERNEL_VERSION = "${@base_read_file('${STAGING_KERNEL_BUILDDIR}/kernel-abiversion')}" KERNEL_OBJECT_SUFFIX = ".ko" # kernel modules are generally machine specific PACKAGE_ARCH = "${MACHINE_ARCH}" +do_configure[depends] += "virtual/kernel:do_shared_workdir" + # Function to ensure the kernel scripts are created. Expected to # be called before do_compile. See module.bbclass for an exmaple. do_make_scripts() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ - -C ${STAGING_KERNEL_DIR} scripts + -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} scripts }
meta/classes/module.bbclass +2 -0
@@ -14,6 +14,7 @@ module_do_compile() { KERNEL_VERSION=${KERNEL_VERSION} \ CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ AR="${KERNEL_AR}" \ + O=${STAGING_KERNEL_BUILDDIR} \ ${MAKE_TARGETS} }
@@ -21,6 +22,7 @@ module_do_install() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" \ CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ + O=${STAGING_KERNEL_BUILDDIR} \ modules_install }
meta/conf/bitbake.conf +2 -1
@@ -395,7 +395,8 @@ SDKPATHNATIVE = "${SDKPATH}/sysroots/${SDK_SYS}" ################################################################## OLDEST_KERNEL = "2.6.32" -STAGING_KERNEL_DIR = "${STAGING_DIR_HOST}/usr/src/kernel" +STAGING_KERNEL_DIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-source" +STAGING_KERNEL_BUILDDIR = "${TMPDIR}/work-shared/${MACHINE}/kernel-build-artifacts" ################################################################## # Specific image creation and rootfs population info.
meta/recipes-kernel/linux/kernel-devsrc.bb +11 -3
@@ -15,7 +15,7 @@ inherit module-base # We need the kernel to be staged (unpacked, patched and configured) before # we can grab the source and make the kernel-devsrc package -do_install[depends] += "virtual/kernel:do_populate_sysroot" +do_install[depends] += "virtual/kernel:do_shared_workdir" # Need the source, not just the output of populate_sysroot do_install[depends] += "virtual/kernel:do_configure"
@@ -30,7 +30,8 @@ do_populate_sysroot[noexec] = "1" # Define where the kernel headers are installed on the target as well as where # they are staged. KERNEL_SRC_PATH = "/usr/src/kernel" -S = "${STAGING_DIR_TARGET}/${KERNEL_SRC_PATH}" +S = "${STAGING_KERNEL_DIR}" +B = "${STAGING_KERNEL_BUILDDIR}" KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
@@ -45,8 +46,15 @@ do_install() { # We can keep this copy simple and take everything, since a we'll clean up any build # artifacts afterwards, and the extra i/o is not significant # + cd ${B} + find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir cd ${S} find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir + + # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not + # The main build artifacts. We clean the directory to avoid QA errors on mismatched + # architecture (since scripts and helpers are native format). + KBUILD_OUTPUT="$kerneldir" oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts # As of Linux kernel version 3.0.1, the clean target removes
@@ -54,7 +62,7 @@ do_install() { # KBUILD_LDFLAGS_MODULE, making it required to build external modules. if [ ${ARCH} = "powerpc" ]; then mkdir -p $kerneldir/arch/powerpc/lib/ - cp ${S}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o + cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o fi } # Ensure we don't race against "make scripts" during cpio
meta/recipes-kernel/lttng/lttng-modules_2.5.2.bb +1 -1
@@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=1412caf5a1aa90d6a48588a4794c0eac \ file://lgpl-2.1.txt;md5=243b725d71bb5df4a1e5920b344b86ad" DEPENDS = "virtual/kernel" -do_configure[depends] += "virtual/kernel:do_install" +do_configure[depends] += "virtual/kernel:do_shared_workdir" inherit module
meta/recipes-kernel/perf/perf.bb +1 -1
@@ -32,7 +32,7 @@ DEPENDS = " \ bison flex \ " -do_configure[depends] += "virtual/kernel:do_install" +do_configure[depends] += "virtual/kernel:do_shared_workdir" PROVIDES = "virtual/perf"
Signature · 1 line
1.7.10.4
PATCH 5/8 perf: Disable perf-libunwind
In reply to Ross BurtonFrom: Tom Zanussi <[email protected]>
It hasn't actually been being enabled anyway: 'Disabling post unwind, no support found.'. For now, turn it off because of [YOCTO #7129].
Fixes [YOCTO #7129].
--- meta/recipes-kernel/perf/perf-features.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-kernel/perf/perf-features.inc +1 -1
@@ -1,4 +1,4 @@ -PERF_FEATURES_ENABLE ?= "perf-scripting perf-tui perf-libunwind" +PERF_FEATURES_ENABLE ?= "perf-scripting perf-tui" def perf_feature_enabled(feature, trueval, falseval, d): """
Signature · 1 line
1.7.10.4
PATCH 6/8 kernel-devsrc: Depend on virtual/kernel:do_compile
In reply to Ross BurtonFrom: Darren Hart <[email protected]>
Since virtual/kernel do_compile modifies ${B}, we need to wait for do_compile to copy everything across in order to ensure a deterministic file set.
Currently, we race against the build and can see .debug directories, and the do_compile dependency we will always see them. Add .debug to the find path pruning.
--- meta/recipes-kernel/linux/kernel-devsrc.bb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
meta/recipes-kernel/linux/kernel-devsrc.bb +4 -3
@@ -14,10 +14,11 @@ inherit linux-kernel-base inherit module-base # We need the kernel to be staged (unpacked, patched and configured) before -# we can grab the source and make the kernel-devsrc package +# we can grab the source and make the source package. We also need the bits from +# ${B} not to change while we install, so virtual/kernel must finish do_compile. do_install[depends] += "virtual/kernel:do_shared_workdir" # Need the source, not just the output of populate_sysroot -do_install[depends] += "virtual/kernel:do_configure" +do_install[depends] += "virtual/kernel:do_compile" # There's nothing to do here, except install the source where we can package it do_fetch[noexec] = "1"
@@ -47,7 +48,7 @@ do_install() { # artifacts afterwards, and the extra i/o is not significant # cd ${B} - find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir + find . -type d -name '.git*' -prune -o -path '.debug' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir cd ${S} find . -type d -name '.git*' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
Signature · 1 line
1.7.10.4
PATCH 4/8 perf: Add libdw unwind support to perf-libunwind feature
In reply to Ross BurtonFrom: Tom Zanussi <[email protected]>
perf can use either libdw or libunwind dwarf unwinders, or neither. The perf-libunwind feature implies that if disabled, neither should be used, so have it disable both libdw and libunwind DWARF unwinders if disabled.
This fixes [YOCTO #7129].
--- meta/recipes-kernel/perf/perf.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-kernel/perf/perf.bb +1 -1
@@ -64,7 +64,7 @@ B = "${WORKDIR}/${BPN}-${PV}" SCRIPTING_DEFINES = "${@perf_feature_enabled('perf-scripting', '', 'NO_LIBPERL=1 NO_LIBPYTHON=1',d)}" TUI_DEFINES = "${@perf_feature_enabled('perf-tui', '', 'NO_NEWT=1',d)}" -LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1',d)}" +LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1',d)}" # The LDFLAGS is required or some old kernels fails due missing # symbols and this is preferred than requiring patches to every old
Signature · 1 line
1.7.10.4
PATCH 7/8 kernel.bbclass: Update cleandirs to remove new kernel staging dirs
In reply to Ross BurtonFrom: Darren Hart <[email protected]>
Fixes [YOCTO 6818]
Update do_unpack[cleandirs] to include the STAGING_KERNEL_BUILDDIR, and add the same set of updated cleandirs for do_clean.
--- meta/classes/kernel.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/kernel.bbclass +2 -1
@@ -40,7 +40,8 @@ python __anonymous () { # We need to move these over to STAGING_KERNEL_DIR. We can't just # create the symlink in advance as the git fetcher can't cope with # the symlink. -do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B}" +do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" +do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" base_do_unpack_append () { s = d.getVar("S", True) if s[-1] == '/':
Signature · 1 line
1.7.10.4
PATCH 8/8 kernel-yocto: remove GUILT_BASE from terminal exports
In reply to Ross BurtonFrom: Bruce Ashfield <[email protected]>
guilt is no longer used to manage linux-yocto kernel pathes, so we no longer need to export variables that it needed to locate patches in the tree.
--- meta/classes/kernel-yocto.bbclass | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
meta/classes/kernel-yocto.bbclass +1 -2
@@ -352,8 +352,7 @@ do_kernel_link_vmlinux() { ln -sf ../../../vmlinux } -OE_TERMINAL_EXPORTS += "GUILT_BASE KBUILD_OUTPUT" -GUILT_BASE = "meta" +OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" KBUILD_OUTPUT = "${B}" python () {
Signature · 1 line
1.7.10.4