[Solved] Current64: How to build an out-of-tree module
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[Solved] Current64: How to build an out-of-tree module
For many years I configure, build and install my own kernels from the kernel.org sources -- at the moment that is 5.3.9.
Once installed and rebooted I then have to build two out-of-kernel module-sets -- the VirtualBox one and the rtlwifi_new-extended one (the zip from https://github.com/lwfinger/rtlwifi_new/tree/extended).
Out of curiosity I installed the testing kernel-(generic,modules,source}-5.4.0-rc6 *) and rebooted: Both the VirtualBox **) and the rtlwifi module builds failed.
First after rebuilding the kernel (make in /usr/src/linux-5.4-rc6) the rtlwifi module build succeeded. This begs the question whether this is "normal" or that I missed something. The Book does not mention building out-of-tree modules and scanning LinuxQuestions gave no definitive hints either.
Any hints would be appreciated.
Regards, Dick
*) Fafaik the kernel-headers package should be the one the userland is built with, so 4.19.82 at the moment.
**) Not researched further -- see https://www.virtualbox.org/ticket/18945.
Are you using multilib? I"m wondering if it has to do with gcc not matching the one used to compile the kernel, since others have reported issues with modules (such as the Nvidia blob) in the Latest Kernel thread with the 5.4 kernel. (gcc-multilib and gcc-stock have never mattered to the 4.19 kernels, but I don't know if things changed for 5.4.)
@garpu: No, I am not using multilib. So I assume to use the same compiler as Pat used to create the pertinent packages. I do see your point though. With a compiler upgrade adding out-of-tree modules to an already compiled kernel may cause problems. Luckily compiler upgrades do not happen often ...
As I said, I did not elaborate on the VirtualBox problem any further. I zoomed in on the rtlwifi module build as a test case but my question is more generic: Given the stock kernel {generic[,headers],modules,source} packages what is the procedure to build an out-of-tree module?
I haven't tested the 5.4.0-rc6 nor have I checked in what state the source package (tree) is, therefore I cannot comment on it. The main kernels Slackware is providing have their source tree prepared, meaning it's in the state left immediately after finishing compiling the kernel, all the necessary files (config, make files, headers, Module.symvers, etc.) are already available.
If you don't have the kernel source tree in a prepared state, let's say you're downloading the source from upstream - kernel.org, you need to have two files available from your running kernel, the .config and the Module.symvers, both need to be copied in the root of the kernel source tree - /usr/src/linux-5.4-rc6 in this case. Then, you need to prepare the kernel source tree for your out-of-tree kernel module compilation by running:
Code:
make modules_prepare
Only after these steps you can move into your out-of-tree kernel module source directory and build it.
There's another thing you should care about, usually the out-of-tree kernel module make file is looking in /lib/modules/running-kernel-version after the symlink "build", which should point to the kernel source tree. If this symlink isn't there, create it.
@colorpurple21859: Indeed it is the rtl8723de driver I am after.
@abga: With "the Book" I meant the Slackware https://www.slackbook.org/ one -- I must admit that "2012" did not hint at its up-to-dateness. It never occurred to me to have a look at the kernel's "Documentation" directory. [/blush]
Assuming the Slackware testing 5.4-rc6 was in its "prepared" stage I installed (a test build supporting kernel 5.4 of) VirtualBox and succeeded. Building the rtlwifi_new-extended drivers still failed.
So I opened issue https://github.com/lwfinger/rtlwifi_new/issues/500 on their bug tracker which was closed as:
Quote:
Obviously, you did not have a proper map of the system globals available, particularly for the other modules. A full kernel make obviously did the job.
VirtualBox can be built without needing any kernel modules other than its own, although most distro versions do use some other kernel modules.
In other words: the "prepared" stage is not sufficient for building some out-of-tree kernel modules ...
But then, before wasting your time&energy, better focus on the way the rtlwifi_new external modules are built. I read lwfinger's answer at the rtlwifi_new bug tracking you mentioned and he's right, their external modules build process require some extra modules files and those should be available in /lib/modules/5.4.0-rc6 (map/order/symbols). I'm afraid those are not considered and expected to be available in the kernel source tree.
Does this "false" apply to the statement (as in "your false and generalized statement") or to "generalized" (as in "your falsely generalized statement")? In the latter case I should rephrase my statement as "In other words: the "prepared" stage is not sufficient for building at least one out-of-tree kernel module ...".
Note that my wording is such that it does not imply who I think is to "blame": the kernel developers or the rtlwifi_new-extended developer.
I'm glad you got it working and your particular experience and the details provided in this thread with the rtlwifi_new drivers are definitely beneficial for the Slackware community. My observation (hope you didn't miss the emoji at the end of it) with your generalization had two reasons, first, avoid misleading the other people who read and learn from this thread and second, to point you at the only buggers who are to be blamed for not respecting the way defined by the kernel devs.
Again, this is a particular case and the "the "prepared" stage is not sufficient for building some" is rather false.
I still think my amended (see my Yesterday 09:50 AM post) statement: The "prepared" stage is not sufficient for building at least one out-of-tree kernel module.
is correct and neutral.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.