From bb1374cf5a353a151c233cb7568d6d5c5de4519d Mon Sep 17 00:00:00 2001 From: ririyeye <200610237@qq.com> Date: Thu, 23 Apr 2026 11:02:53 +0800 Subject: fix linux module intermediate filenames Generate linux module intermediate files from the target basename instead of the final .ko path so modpost reads hello.o rather than hello.ko.o. This avoids the bogus *.ko.ko module name and undefined symbol warnings reported in #5721. Made-with: Cursor --- xmake/rules/platform/linux/module/driver_modules.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xmake/rules/platform/linux/module/driver_modules.lua b/xmake/rules/platform/linux/module/driver_modules.lua index 0e23a0100..5c9d833a5 100644 --- a/xmake/rules/platform/linux/module/driver_modules.lua +++ b/xmake/rules/platform/linux/module/driver_modules.lua @@ -361,14 +361,15 @@ function link(target, opt) if ldflags_o then table.join2(argv, ldflags_o) end - local targetfile_o = target:objectfile(targetfile) + local targetfile_base = path.join(path.directory(target:objectfile(targetfile)), target:basename()) + local targetfile_o = targetfile_base .. ".o" table.join2(argv, "-o", targetfile_o) table.join2(argv, objectfiles) os.mkdir(path.directory(targetfile_o)) os.vrunv(ld, argv) -- generate target.mod - local targetfile_mod = targetfile_o:gsub("%.o$", ".mod") + local targetfile_mod = targetfile_base .. ".mod" io.writefile(targetfile_mod, table.concat(objectfiles, "\n") .. "\n\n") -- generate .sourcename.o.cmd @@ -399,8 +400,8 @@ function link(target, opt) os.vrunv(modpost, argv) -- compile target.mod.c - local targetfile_mod_c = targetfile_o:gsub("%.o$", ".mod.c") - local targetfile_mod_o = targetfile_o:gsub("%.o$", ".mod.o") + local targetfile_mod_c = targetfile_base .. ".mod.c" + local targetfile_mod_o = targetfile_base .. ".mod.o" local compinst = target:compiler("cc") target:fileconfig_set(targetfile_mod_c, {defines = "KBUILD_BASENAME=\"" .. path.basename(targetfile_mod_c) .. "\""}) if option.get("verbose") then @@ -425,7 +426,6 @@ function link(target, opt) if ldflags_ko then table.join2(argv, ldflags_ko) end - local targetfile_o = target:objectfile(targetfile) table.join2(argv, "-o", targetfile, targetfile_o, targetfile_mod_o) if modulecommon_objectfile then table.insert(argv, modulecommon_objectfile) -- cgit v1.3.1