【问题标题】:Yocto: Why is struct module undefined during building an external kernel moduleYocto:为什么在构建外部内核模块期间未定义结构模块
【发布时间】:2018-05-14 16:46:19
【问题描述】:

我正在尝试使用 Yocto 构建系统将示例外部内核模块 hello-modmeta-skeleton/recipes-kernel 添加到我的图像中。然而,当我尝试用bitbake hello-mod 编译它时,它在第二阶段失败,抱怨struct module.name = KBUILD_MODNAME, 行上没有名为name 的成员。即使 linux/module.h 已包含在内,似乎也没有定义 struct module。这是似乎无法编译的通用模块代码:

#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=";

我在编译日志中看不到任何错误,正在使用以下行调用 make(正确,据了解):

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

我可以确认 module.h 存在于目录中: /path/to/poky-rocko/build/tmp/work-shared/duovero/kernel-source/include/linux

所以我用完了并寻找有关如何调试此问题的想法。作为记录,这些是层、内核等的当前版本:

  • poky 是来自 git.yoctoproject.org 的 9915e071bcadd7c4d5363a067c529889851d37a5 (rocko)
  • linux 是来自 git.kernel.org 的 9dc30ff9a115559cc55673d0b1d3c576402d073e

任何帮助或提示将不胜感激!

【问题讨论】:

  • "似乎struct module 没有被定义..." - 不,错误struct module has no member named name 表示结构已定义,但没有指定字段。关于使用未定义结构类型的错误看起来不同。
  • 未修改的example有效吗?
  • 我没有修改示例,只是将它包含在我的图层中。我同意该错误表明某些东西正在定义struct module,但是,struct module 中定义的&lt;linux/module.h&gt; 肯定有一个名为name 的成员。
  • 你的内核.config 中有CONFIG_MODULES=y 吗?这可能是一个愚蠢的问题,因为如果没有定义它就不应该进入第 2 阶段,但 struct module 完整声明确实依赖于正在定义的 CONFIG_MODULES 宏。
  • 感谢 Ian 的反馈,不过正如您所猜测的那样,CONFIG_MODULES=y 确实已定义。

标签: linux linux-kernel kernel-module yocto


【解决方案1】:

这似乎是 Yocto 构建系统的问题。当我按照这些步骤构建 hello-mod 模块。

  1. 查看内核 4.16.x 的版本,将 hello-mod 添加到 MACHINE_ESSENTIAL_EXTRA _RRECOMMENDS 并观察构建失败。
  2. 通过将 SRCREV 设置为相应的提交 ID 来检查另一个内核 4.16.y 的副本,继续构建并观察它是否成功。

到目前为止,我在从 4.16.5 迁移到 4.16.8 时观察到这一点,反之亦然。所以在这一点上,我很确定这是构建系统的问题。

我使用 grep(针对“hello”和“MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS”)和 diff 仔细查看了 bitbake -e 的输出,但找不到任何显着差异。我还检查了编译和配置日志,我看到的唯一有趣的事情是在第二次运行时打印的配置日志中:

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

在第一次运行时,我们只有:

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

虽然这可能刚刚发生,因为这是第二次运行 hello-mod 的配置任务。对我来说,这似乎非常像构建系统中的错误。为此,我在 Bugzilla 上报告了这个问题:

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

【讨论】:

    猜你喜欢
    • 2021-10-20
    • 1970-01-01
    • 2011-12-10
    • 2017-10-17
    • 1970-01-01
    • 2011-04-30
    • 2016-07-14
    • 2011-05-22
    • 1970-01-01
    相关资源
    最近更新 更多