4

I'm working with a Linux driver that is building on v5.7.x kernels but not on the latest v5.8.x releases.

To summarise, most of the driver is pre-built and the kernel interface is built on the target. This involves a make -f Kbuild command.

Having checked all of the relevant kernel interface files for any changes that would affect us, normally the driver would just build as usual on a new kernel. However, this time we get the following error:

make[2]: *** [scripts/Makefile.modpost:111: /path/to/source/Module.symvers] Error 1
make[1]: *** [Makefile:1669: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.8.0-1.el8.elrepo.x86_64'
make: *** [Kbuild:26: default] Error 2

This is from CentOS 8.1, but the same error has been seen on Ubuntu 20.04.

I am no expert on this so interpreting these errors is a bit difficult. I have tried building with the KBUILD_VERBOSE flag and it doesn't really provide any useful information, other than the build succeeding until this point.

On previous kernels the Module.symvers file would be created but empty. On 5.8 this file is not created at all presumably due to this error. As a result, the .ko file is not created.

Finally, if we drop in the source files rather than the pre-built .o files the build does succeed. These .o files are built with a very old version of GCC (4.4.7) but we have also tried building with a much newer version (8.3.1), the same version as the target machine.

I would appreciate suggestions for things to check. Let me know if any other details would help.

Edit:

I ran make on Makefile.modpost manually and got the following output:

sudo make -f ./scripts/Makefile.modpost
WARNING: Symbol version dump "vmlinux.symvers" is missing.
         Modules may not have dependencies or modversions.
make -f /scripts/Makefile.modfinal
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-050800-generic'
make[1]: /scripts/Makefile.modfinal: No such file or directory
make[1]: *** No rule to make target '/scripts/Makefile.modfinal'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-050800-generic'
make: *** [scripts/Makefile.modpost:117: __modpost] Error 2
Alan Spark
  • 8,152
  • 8
  • 56
  • 91
  • 1
    Do you really have */patch/to/source/* in the message?! – 0andriy Aug 14 '20 at 14:05
  • Makefile.modpost builds modpost according to your kernel config and runs it. modpost is failing and should log the problem to stderr. – stark Aug 14 '20 at 14:08
  • Thanks @stark. The only errors that I saw during the module build were the ones in my post above. However, I did try building Makefile.modpost manually and have updated my post with the output. – Alan Spark Aug 17 '20 at 06:50
  • My copy of 5.8 has /scripts/Makefile.modfinal – stark Aug 17 '20 at 11:24
  • $srctree needs to be defined when you call it. – stark Aug 17 '20 at 11:36
  • @stark Thanks, I got a bit further when passing in srctree (i.e. sudo make -f ./scripts/Makefile.modpost srctree=/usr/src/linux-headers-5.8.0-050800-generic) but this just hung. I also have /scripts/Makefile.modfinal and think that was a red herring from the way that I was building Makefile.modfinal. I am back to testing the module with the .c files rather than prebuilt .o and that works. However, as soon as I go back to the .o (even the ones compiled on this machine) I get the Module.symvers error. – Alan Spark Aug 17 '20 at 12:27

1 Answers1

7

I am answering my own question in case it helps anyone else with this problem. Although it has never been an issue in the past, we've always had a warning that the corresponding .o.cmd file was not present for our .o_shipped files. This appears to be important in kernel 5.8 onwards and my fix was to add a touch command to the Kbuild file (i.e. "touch .driver.o.cmd"). This does not remove the warning but it allows the driver to build as normal.

Alan Spark
  • 8,152
  • 8
  • 56
  • 91
  • While i didn't have to add a `cmd` file, I had to specify a dummy file `make modulesymfile=src/Module.symvers` – hmaarrfk Jan 22 '21 at 18:15