make-mod-scripts: change how some kernel module tools are built
PATCH v3 1/2 make-mod-scripts: change how some kernel module tools are built
From: Joe Slater <[email protected]>
Remove do_make_scripts() from module-base.bbclass and put functionality in a recipe. This will build the scripts only once instead of each time an external module is built.
[YOCTO #12228]
---
v2: added the LIC_FILES_CHECKSUM
v3: added PACKAGE_ARCH = "${MACHINE_ARCH}" for .test_sstate_sametune_samesigs
meta/classes/module-base.bbclass | 12 +++------- meta/classes/module.bbclass | 4 ---- .../make-mod-scripts/make-mod-scripts_1.0.bb | 28 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb
meta/classes/module-base.bbclass +3 -9
@@ -1,7 +1,8 @@ inherit kernel-arch -# This is instead of DEPENDS = "virtual/kernel" -do_configure[depends] += "virtual/kernel:do_compile_kernelmodules" +# We do the dependency this way because the output is not preserved +# in sstate, so we must force do_compile to run (once). +do_configure[depends] += "make-mod-scripts:do_compile" export OS = "${TARGET_OS}" export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -18,10 +19,3 @@ KERNEL_OBJECT_SUFFIX = ".ko" # kernel modules are generally machine specific PACKAGE_ARCH = "${MACHINE_ARCH}" -# Function to ensure the kernel scripts are created. Expected to -# be called before do_compile. See module.bbclass for an example. -do_make_scripts() { - unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS - make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ - -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} scripts -}
meta/classes/module.bbclass +0 -4
@@ -1,9 +1,5 @@ inherit module-base kernel-module-split pkgconfig -addtask make_scripts after do_prepare_recipe_sysroot before do_configure -do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock" -do_make_scripts[depends] += "virtual/kernel:do_shared_workdir" - EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}" MODULES_INSTALL_TARGET ?= "modules_install"
meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb new file +28 -0
@@ -0,0 +1,28 @@ +SUMMARY = "Build tools needed by external modules" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +inherit kernel-arch +inherit pkgconfig + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +S = "${WORKDIR}" + +do_configure[depends] += "virtual/kernel:do_shared_workdir" +do_compile[depends] += "virtual/kernel:do_compile_kernelmodules" + +# Build some host tools under work-shared. CC, LD, and AR are probably +# not used, but this is the historical way of invoking "make scripts". +# +do_configure() { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ + -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} scripts +} + + +# There is no reason to build this on its own. +# +EXCLUDE_FROM_WORLD = "1" +
Signature · 1 line
2.5.0
PATCH v3 2/2 make-mod-scripts: add build requirements for external modules
Newer kernels (4.14/v4.15+) have dependencies for the build of modules (and hence external modules). Without these dependencies explicitly in the build chain, you can end up with build failures like:
work-shared/qemux86/kernel-source/scripts/extract-cert.c:21:25: fatal
error: openssl/bio.h: No such file or directory
| #include <openssl/bio.h> | ^ | compilation terminated. | make[2]: *** [scripts/extract-cert] Error 1 | make[1]: *** [scripts] Error 2
To ensure that these headers are in place, and that the scripts use our build environment flags, we add a dependency on openssl-native and use oe_make to invoke the build.
Older kernels have no issues with the extra dependency, so there's no need to make this conditional.
---
v3: added bc-native to DEPENDS
meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb +6 -2
@@ -9,15 +9,19 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" S = "${WORKDIR}" -do_configure[depends] += "virtual/kernel:do_shared_workdir" +do_configure[depends] += "virtual/kernel:do_shared_workdir openssl-native:do_populate_sysroot" do_compile[depends] += "virtual/kernel:do_compile_kernelmodules" +DEPENDS += "bc-native" + +EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"" + # Build some host tools under work-shared. CC, LD, and AR are probably # not used, but this is the historical way of invoking "make scripts". # do_configure() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS - make CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ + oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} scripts }
Signature · 1 line
2.5.0