Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modpost: "_printk" [<...>/<redacted>.ko.ko] undefined #5721

Open
TheAifam5 opened this issue Oct 15, 2024 · 1 comment
Open

modpost: "_printk" [<...>/<redacted>.ko.ko] undefined #5721

TheAifam5 opened this issue Oct 15, 2024 · 1 comment
Labels

Comments

@TheAifam5
Copy link

TheAifam5 commented Oct 15, 2024

Xmake Version

v2.9.5+20241016

Operating System Version and Architecture

Gentoo (AMD64)

Describe Bug

While compiling a kernel module with "-v" (verbose) flag, modpost shows a warnings:

WARNING: modpost: "_printk" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!
WARNING: modpost: "__x86_return_thunk" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!
WARNING: modpost: "module_layout" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!

Notice in file listing below that .ko.ko has duplicate extensions and file is non-existing.

Expected Behavior

There should be no warnings for such simple example. The module compiles fine and runs.

Project Configuration

xmake.lua:

option("linux-headers", { showmenu = true, description = "Set linux-headers path." })

target("<redacted>")
	add_rules("platform.linux.driver")
	add_files("src/*.c")
	set_values("linux.driver.linux-headers", "$(linux-headers)")
	set_license("GPL-2.0")

entry.c:

#include <linux/init.h>   // Needed for the macros
#include <linux/kernel.h> // Needed for KERN_INFO
#include <linux/module.h> // Needed by all modules

MODULE_LICENSE("GPL-2.0");
MODULE_AUTHOR("<redacted> <redacted>");
MODULE_DESCRIPTION("<redacted>");

static int __init dw_init(void) {
  printk(KERN_INFO "<redacted>: Hello, World!\n");
  return 0;
}

static void __exit dw_exit(void) {
  printk(KERN_INFO "<redacted>: Goodbye, World!\n");
}

module_init(dw_init);
module_exit(dw_exit);

Additional Information and Error Logs

[ 50%]: cache compiling.release dw-kmod/src/entry.c
/usr/bin/gcc -c -DKBUILD_MODNAME=\"<redacted>\" -I/usr/src/linux/arch/x86/include -I/usr/src/linux/arch/x86/include/generated -I/usr/src/linux/include -I/usr/src/linux/arch/x86/include/uapi -I/usr/src/linux/arch/x86/include/generated/uapi -I/usr/src/linux/include/uapi -I/usr/src/linux/include/generated/uapi -include /usr/src/linux/include/linux/compiler-version.h -include /usr/src/linux/include/linux/kconfig.h -include /usr/src/linux/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -fno-allow-store-data-races -fstack-protector -fno-stack-clash-protection -mrecord-mcount -mfentry -DCC_USING_FENTRY -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-overflow -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wextra -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-unused-parameter -DMODULE -DKBUILD_BASENAME=\"entry\" -o build/.objs/<redacted>/linux/x86_64/release/dw-kmod/src/entry.c.o dw-kmod/src/entry.c
[ 75%]: linking.release build/linux/x86_64/release/<redacted>.ko
/usr/bin/ld -m elf_x86_64 -z noexecstack --no-warn-rwx-segments -r -o build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.o build/.objs/<redacted>/linux/x86_64/release/dw-kmod/src/entry.c.o
/usr/src/linux/scripts/mod/modpost -m -a -o build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/Module.symvers -e -N -w -T build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/modules.order
WARNING: modpost: "_printk" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!
WARNING: modpost: "__x86_return_thunk" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!
WARNING: modpost: "module_layout" [build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.ko] undefined!
/usr/bin/gcc -c -DKBUILD_MODNAME=\"<redacted>\" -I/usr/src/linux/arch/x86/include -I/usr/src/linux/arch/x86/include/generated -I/usr/src/linux/include -I/usr/src/linux/arch/x86/include/uapi -I/usr/src/linux/arch/x86/include/generated/uapi -I/usr/src/linux/include/uapi -I/usr/src/linux/include/generated/uapi -include /usr/src/linux/include/linux/compiler-version.h -include /usr/src/linux/include/linux/kconfig.h -include /usr/src/linux/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -fno-allow-store-data-races -fstack-protector -fno-stack-clash-protection -mrecord-mcount -mfentry -DCC_USING_FENTRY -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-overflow -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wextra -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-unused-parameter -DMODULE -o build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod.o build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod.c
/usr/bin/ld -r -m elf_x86_64 -z noexecstack --no-warn-rwx-segments --build-id=sha1 -T /usr/src/linux/scripts/module.lds -o build/linux/x86_64/release/<redacted>.ko build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.o build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod.o

build cache stats:
cache directory: /home/theaifam5/Projects/<redacted>/build/.build_cache
cache hit rate: 100%
cache hit: 2
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s

[100%]: build ok, spent 0.347s

Build dir file listing:

╭───┬────────────────────────────────────────────────────────────────────────────────────────┬──────┬─────────┬────────────────╮
│ # │                                          name                                          │ type │  size   │    modified    │
├───┼────────────────────────────────────────────────────────────────────────────────────────┼──────┼─────────┼────────────────┤
│ 0 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod.c │ file │   847 B │ 24 minutes ago │
│ 1 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod   │ file │    65 B │ 3 minutes ago  │
│ 2 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.mod.o │ file │ 4.1 KiB │ 3 minutes ago  │
│ 3 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/Module.symvers    │ file │     0 B │ 3 minutes ago  │
│ 4 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/modules.order     │ file │    83 B │ 3 minutes ago  │
│ 5 │ build/.objs/<redacted>/linux/x86_64/release/build/linux/x86_64/release/<redacted>.ko.o     │ file │ 3.7 KiB │ 3 minutes ago  │
╰───┴────────────────────────────────────────────────────────────────────────────────────────┴──────┴─────────┴────────────────╯
@TheAifam5 TheAifam5 added the bug label Oct 15, 2024
@waruqi
Copy link
Member

waruqi commented Oct 22, 2024

you can debug here. try to rename targetfile_o. xxx.ko.o -> xxx.o

io.writefile(orderfile, targetfile_o .. "\n")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants