linux - Yocto:为什么在构建外部内核模块期间未定义结构模块
问题描述
我正在尝试使用 Yocto 构建系统将示例外部内核模块hello-mod从meta-skeleton/recipes-kernel添加到我的图像中。但是,当我尝试使用 编译它时bitbake hello-mod
,它在第二阶段失败,抱怨struct module
没有name
在该行中命名的成员.name = KBUILD_MODNAME,
。struct module
即使linux/module.h已包含在内,似乎也没有被定义。这是似乎无法编译的通用模块代码:
#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
任何帮助或提示将不胜感激!
解决方案
这似乎是 Yocto 构建系统的问题。当我按照这些步骤操作时,hello-mod 模块就会构建。
- 查看内核 4.16.x 的版本,添加 hello-mod
MACHINE_ESSENTIAL_EXTRA
_RRECOMMENDS
并观察构建失败。 - 通过将 SRCREV 设置为相应的提交 id 来检查另一个内核 4.16.y 的副本,继续构建并观察它是否成功。
到目前为止,我在从 4.16.5 移动到 4.16.8 时观察到这一点,反之亦然。所以在这一点上,我很确定这是构建系统的问题。
我仔细查看了bitbake -e
使用 grep(针对“hello”和“MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS”)和 diff 的输出,但找不到任何显着差异。我还检查了编译和配置日志,我看到的唯一有趣的事情是在第二次运行时打印的配置日志中:
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 上报告了这个问题:
推荐阅读
- python - 在分组数据帧上使用条件时出现值错误
- php - 为什么 PHP 没有 mysqli.default_database 运行时设置?
- mongodb - 如何在mongodb中通过输出找到两组的比率
- sql - 仅当差异为正时才获得差异
- c++ - 在函数内声明后更改向量值
- amazon-web-services - 关系数据库到单个 Dynamo 数据库表
- clojure - 无法在类型 `QueryRoot' 上查询字段 `XXX'。”(用于 GraphQL 的 Lacinia Clojure 库)
- python-3.x - 要打印井字游戏,哪种代码更好?
- reactjs - 在 React / Redux 中,如果一个函数组件正在使用 redux-thunk 调度一个函数,它如何 setIsLoading() 呢?
- automation - Github Actions - 比较并找出两个 OAS V3 文件之间的差异