Out-of-tree module build in a dedicated build directory.

Aruna Hewapathirane aruna.hewapathirane at gmail.com
Thu Mar 15 14:58:59 EDT 2018


On Thu, Mar 15, 2018 at 12:39 PM, Aleksei Fedotov <lexa at cfotr.com> wrote:

> > If for some reason make modules did not create module.symvers then try:
> >
> >         cd /home/lexa/linux
> >         make
> >         [wait a few minutes as it builds some scripts and starts
> building kernel code...]
> >         hit <Ctrl-C>
> >
> > then go back and try building your module.
>
> But i have my kernel completely build, including kernel modules.
>
> I get the error about ./Module.symvers only if I specify
> O=module_build_directory. When I build the module without O= there is
> not such error, but the object files are created in the same directory
> as module source, which I want to avoid.
>

This will help:

https://www.kernel.org/doc/Documentation/kbuild/modules.txt

In section 2. of the above link on "How to Build External Modules" it
specifically mentions that:

NOTE: "modules_prepare" will not build Module.symvers even if
CONFIG_MODVERSIONS is set; therefore, a full kernel build needs to be
executed to make module versioning work.

This is the *reason* I asked you to run make to trigger a full kernel build
and press Ctrl+C because no one wants to hang around until it completes.
Especially if one is on a Pentium 3 like I used to be with my first kernel
compile which took over 6 hours.

And pay very careful attention to what is below, read ten times if u must
but 'understand' what that is saying :-) took me more than ten times before
I understood..

6.2 Symbols and External Modules

	When building an external module, the build system needs access
	to the symbols from the kernel to check if all external symbols
	are defined. This is done in the MODPOST step. modpost obtains
	the symbols by reading Module.symvers from the kernel source
	tree. If a Module.symvers file is present in the directory
	where the external module is being built, this file will be
	read too. During the MODPOST step, a new Module.symvers file
	will be written containing all exported symbols that were not
	defined in the kernel.

So that is why Gregkh said run make modules_prepare ( which yet needs
a full compile )

Hope this helps - Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180315/14362cbe/attachment.html>


More information about the Kernelnewbies mailing list