I am trying to add the example external kernel module hello-mod from meta-skeleton/recipes-kernel to my image using the Yocto build system. When I try to compile it with bitbake hello-mod, however, it fails at a second stage complaining that struct module has no member named name on the line .name = KBUILD_MODNAME,. It seems as if struct module is not being defined even though linux/module.h has been included. This is the generic module code that doesn't seem to compile:
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const char __module_depends[]
__used
__attribute__((section(".modinfo"))) =
"depends=";
I am unable to see anything wrong in the compilation log, make is being invoked (correctly, to the best of knowledge) with the following line:
make -C /path/to/poky-rocko/build/tmp/work-shared/duovero/kernel-source \
M=/path/to/poky-rocko/build/tmp/work/duovero-poky-linux-gnueabi/hello-mod/0.1-r0
and I can confirm that module.h exists in the directory: /path/to/poky-rocko/build/tmp/work-shared/duovero/kernel-source/include/linux
So I am running out of and looking for ideas on how to debug this issue. For the record, these are the current versions of the layers, kernel etc:
- poky is 9915e071bcadd7c4d5363a067c529889851d37a5 (rocko) from git.yoctoproject.org
- linux is 9dc30ff9a115559cc55673d0b1d3c576402d073e from git.kernel.org
Any help or hints would really be appreciated!
struct moduleis not being defined..." - No, the errorstruct module has no member named namemeans that the structure is defined, but has no specified field. An error about using undefined structure type looks different.struct module, however,struct moduleas defined in<linux/module.h>definitely has a member calledname.CONFIG_MODULES=yin your kernel .config? That's probably a silly question because it shouldn't get to stage 2 if it is not defined, but thestruct modulefull declaration does depend on theCONFIG_MODULESmacro being defined.CONFIG_MODULES=yis indeed defined.