Linux: modpost does not build anything

时光怂恿深爱的人放手 提交于 2019-11-29 13:54:10

I spent all day glued to my computer fighting this precise problem..which ended up mysteriously disappearing like for OP.

I can at least offer this meager detail from my experience: I was getting the same output as OP (for make V=1) and putting print statements in ${kernel_directory}/scripts/makefile.build showed that obj-m was strangely NOT being set after including my makefile, even though it was clearly typed as above.

I did a bunch of fooling around with the line "obj-m += hello.o" and the ones around it. Eventually it magically worked..although it looked exactly the same as before in the end. Maybe I had copied those lines from a tutorial online and it contained some sort of invalid/incorrect character?

For anyone experiencing this, verify that obj-m is in fact getting set to hello.o
If it mysteriously isn't, delete the line, hell the whole Makefile, and retype it.

I know that's not much help; I wish I could reproduce what happened!

In another thread I found that when I copy pasted the makefile contents, the -C after make was using the wrong "-" symbol and I had to re type it. It just so happens that this is the case for the obj-m += ... line above. You need to retype that character to make it valid. This should hopefully be found by anyone following the hello world module tutorial.

I just ran into this same problem and for me it was caused by changing the default grep options via the GREP_OPTIONS environment variable. I didn't dig into the details, but something in the module build process didn't like my alternate grep output (include file name and line number). Removing the GREP_OPTIONS environment variable fixed things right up.

This happens because when you copy the make file contents from the PDF or any other tutorial websites and use it as it is. While you do a copy-paste, the contents will appear a bit weird in Linux environment. ie; Some special character issues will be there. If you retype the contents in Linux environment and do a make, this should work.

On the machine that fails does your .config have module support disabled?

Try doing "make menuconfig" and make sure module support is enabled.

I can only guess your kernel build environment is botched, because it passes both the theoretical check (the look of the developer) as well as the practical test:

make -C /lib/modules/2.6.36-rc8-32-desktop/build M=/dev/shm modules
make[1]: Entering directory `/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop'
make -C ../../../linux-2.6.36-rc8-32 O=/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop/. modules
  CC [M]  /dev/shm/hello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /dev/shm/hello.mod.o
  LD [M]  /dev/shm/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop'

The error mysteriously went away. If anyone has an idea what could cause this. I'd like to know in case there is a next time.

saai63

I guess you copied the contents of the Makefile from a PDF or some HTML document. The hyphens used are somewhat weird. Just try replacing the hyphens in the makefile; it will work like a charm.

Try to remove modules string from the Makefile:

obj-m = hello.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) # <--
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) clean
cnnrznn

I was able to solve this problem by putting the

obj-m += <module name>.o

In a separate file named Kbuild. See Linux/documentation/kbuild/modules.txt for a hint as to why this might work

I had the same problem. Finally, I rebuilt the kernel, rewrote the makefile. It worked finally.

I guess the main reason is because I had M=$(PWD) modules in the following line right after make ARCH=arm...

OnkarPatil

I solved this problem by correcting Makefile, i.e.:

obj-m := modulename.o
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!