I have multiple projects that involve building a kernel module and all are failing on my newly installed Fedora Linux 44 (Sway). My config used to work fine on Arch Linux, and I think I must have also built it when I was trying Fedora Atomic. I can still build it in my source directory when not using MO= flag.
AI says it’s a bug. It shouldn’t write anything in the kernel source directory.
I then tried running as sudo and it replaced the Makefile at /usr/src/kernels/7.1.3-200.fc44.x86_64/Makefile with its wrapper. AI states that this is a serious bug. I re-installed kernel-devel.
Seems like this a Kbuild issue. I updated my Arch Linux system and it doesn’t build. It definitely used to build before. I can still build, just without the MO flag, leading to all build artifacts being generated in the source directory of the kernel module.
($KDIR refers to the path of the kernel source directory, or the path of the kernel output directory if the kernel was built in a separate build directory.)
You can optionally pass MO= option if you want to build the modules in a separate directory.
make -C $KDIR M=$PWD [MO=$BUILD_DIR]
-C $KDIR
The directory that contains the kernel and relevant build artifacts used for building an external module. “make” will actually change to the specified directory when executing and will change back when finished.
M=$PWD
Informs kbuild that an external module is being built. The value given to “M” is the absolute path of the directory where the external module (kbuild file) is located.
MO=$BUILD_DIR
Specifies a separate output directory for the external module.
I think I tried but it doesn’t fix it. I can anyways see with the original command that the values of M and MO variables in the output log are being expanded to the correct path name.
edit - Trust LLMs a bit, they will pick up such syntax errors.
Why do I need DKMS for a simple Hello World kernel module? My projects are just standalone projects for learning. I don’t want them to auto build on every new kernel install.
I am literally using make or Makefile as per the guides. It definitely used to build before on early Linux 7 (or with the packages of that time). Did something change recently?
I don’t understand why I should be needing to use DKMS for learning to write kernel modules. It would be a better tool for actually distributing my module and having it persistently in use or active. I don’t plan to distribute or in a way that has to be persistent on a system. And isn’t DKMS a helpful tool rather than a hard requirement to compile a basic kernel module?
You have not addressed anything about what I am calling out a bug. The make command, as per the official guides, should work with the MO flag as I have stated. I am damn sure it used to work before. I could probably spin up a Debian instance to verify.
I don’t understand why the MO flag specifically is behaving this way. Without it, the module builds fine and all the build artifacts are in my source folder. All MO does is set the output directory. If I give it root privileges as it wants, it is replacing the kernel source’s Makefile with its wrapper. In which scenario does anything require to write to the installed kernel source’s Makefile?