diff options
| author | ririyeye <[email protected]> | 2026-04-23 11:02:53 +0800 |
|---|---|---|
| committer | ririyeye <[email protected]> | 2026-04-23 17:00:13 +0800 |
| commit | bb1374cf5a353a151c233cb7568d6d5c5de4519d (patch) | |
| tree | 3065d85a563bd1b20f3bf8e1fa6c57da39590411 /xmake/rules/platform/linux/module/driver_modules.lua | |
| parent | e7d86ead6c2760d1ca3548093673ef1db99e85c3 (diff) | |
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
Diffstat (limited to 'xmake/rules/platform/linux/module/driver_modules.lua')
| -rw-r--r-- | xmake/rules/platform/linux/module/driver_modules.lua | 10 |
1 files 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) |
