@@ -26,8 +26,11 @@ class KernelModuleTest(OESDKTestCase):
parallel_make = "-j %d" % (pmv) if pmv else ""
self.ensure_target_package("kernel-devsrc")
+ # the kernel assigns HOSTPKG_CONFIG with '=', so it has to come from
+ # the make command line, as kernel.bbclass does
+ host_pkg_config = 'HOSTPKG_CONFIG="env -u PKG_CONFIG_SYSROOT_DIR -u PKG_CONFIG_PATH -u PKG_CONFIG_LIBDIR pkg-config"'
# These targets need to be built before kernel modules can be built.
- self._run("make %s -C $OECORE_TARGET_SYSROOT/usr/src/kernel prepare scripts" % (parallel_make))
+ self._run("make %s %s -C $OECORE_TARGET_SYSROOT/usr/src/kernel prepare scripts" % (parallel_make, host_pkg_config))
with tempfile.TemporaryDirectory(prefix="cryptodev", dir=self.tc.sdk_dir) as testdir:
git_url = "https://github.com/cryptodev-linux/cryptodev-linux"
@@ -39,5 +42,5 @@ class KernelModuleTest(OESDKTestCase):
self.assertTrue(os.path.isdir(sourcedir))
subprocess.check_output(["git", "-C", sourcedir, "checkout", git_sha], stderr=subprocess.STDOUT)
- self._run("make -C %s V=1 KERNEL_DIR=$OECORE_TARGET_SYSROOT/usr/src/kernel" % sourcedir)
+ self._run("make -C %s V=1 %s KERNEL_DIR=$OECORE_TARGET_SYSROOT/usr/src/kernel" % (sourcedir, host_pkg_config))
self.check_elf(os.path.join(sourcedir, "cryptodev.ko"))
The SDK environment sets PKG_CONFIG_SYSROOT_DIR, PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR so that pkg-config answers for the target. That is right for everything built to run there and wrong for a program built to run on the SDK host. The kernel build compiles host tools of its own, and objtool asks pkg-config where libelf is. It gets the target's include directory, compiles a host tool against the target's C library headers, and stops on warnings that -Wno-system-headers would otherwise have covered: usr/include/sys/cdefs.h:486: error: "__attribute_const__" redefined Pass a pkg-config that undoes those three variables on the make command line when the test builds an external module. It has to be a command line assignment: the kernel assigns HOSTPKG_CONFIG with '=', so an exported value is ignored. OE-Core already does the same thing for its own kernel builds, in kernel.bbclass. Fixes [YOCTO #16239]. AI-Generated: codex/claude-opus 5 (xhigh) Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- changes in v2: - drop the HOSTPKG_CONFIG export from the SDK environment script. It only ever took effect against a proposed kernel change that has since been abandoned, so no kernel honours it and it was dead weight. The make command line assignment, which is what makes the test work, is unchanged - the subject loses its toolchain-scripts prefix, since that file is no longer touched - drop the paragraph citing the kernel proposal --- meta/lib/oeqa/sdk/cases/kmod.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)