0

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!

5
  • 1
    "It seems as if struct module is not being defined..." - No, the error struct module has no member named name means that the structure is defined, but has no specified field. An error about using undefined structure type looks different. Commented May 14, 2018 at 21:32
  • Is the unmodified example works? Commented May 15, 2018 at 7:47
  • I haven't modified the example, just included it into my layer. I agree that the error indicates that something is defining struct module, however, struct module as defined in <linux/module.h> definitely has a member called name. Commented May 15, 2018 at 10:08
  • 1
    Do you have CONFIG_MODULES=y in your kernel .config? That's probably a silly question because it shouldn't get to stage 2 if it is not defined, but the struct module full declaration does depend on the CONFIG_MODULES macro being defined. Commented May 15, 2018 at 13:42
  • Thanks for the feedback Ian, as you guessed though, CONFIG_MODULES=y is indeed defined. Commented May 16, 2018 at 7:56

1 Answer 1

0

It seems to be an issue with the Yocto build system. The hello-mod module builds when I follow these steps.

  1. Check out a version of the kernel 4.16.x, add hello-mod to MACHINE_ESSENTIAL_EXTRA _RRECOMMENDS and watch the build fail.
  2. Check out a copy of another kernel 4.16.y by setting SRCREV to the corresponding commit id, continue the build and watch it succeed.

So far I have observed this when moving from 4.16.5 to 4.16.8 and vice versa. So at this point I am pretty sure that this is an issue with the build system.

I had a close look at the output of bitbake -e using grep (against "hello" and "MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS") and diff but couldn't find any significant differences. I also checked the compilation and configuration logs, the only interesting thing I saw was in the configuration logs where on the second run this is printed:

DEBUG: Executing shell function do_configure
NOTE: make KERNEL_SRC=/path/to/poky-rocko/build/tmp/work-shared/duovero/kernel-source clean
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
rm -f Module.markers Module.symvers modules.order
rm -rf .tmp_versions Modules.symvers
DEBUG: Shell function do_configure finished
DEBUG: Executing python function do_qa_configure
DEBUG: Python function do_qa_configure finished

while on the first run, we only have:

DEBUG: Executing shell function do_configure
DEBUG: Shell function do_configure finished
DEBUG: Executing python function do_qa_configure
DEBUG: Python function do_qa_configure finished

Although this may have just occurred since this was the second run of the configure task for hello-mod. This seems very much like a bug in the build system to me. To this end, I have reported the issue on Bugzilla:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=12748

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.