2

I am compiling a kernel module with a build script including the following command:

make -C /lib/modules/$(uname -r)/build SUBDIRS=$PWD modules

This used to work... but now it fails with this error:

make[1]: Entering directory '/usr/src/linux-headers-5.4.0-42-generic'
fs/aufs/Makefile:3: fs/aufs/magic.mk: No such file or directory
make[3]: *** No rule to make target 'fs/aufs/magic.mk'.  Stop.
scripts/Makefile.clean:67: recipe for target 'fs/aufs' failed
make[2]: *** [fs/aufs] Error 2
Makefile:1738: recipe for target '_clean_fs' failed
make[1]: *** [_clean_fs] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-42-generic'
Makefile:39: recipe for target 'clean' failed
make: *** [clean] Error 2

The build stops there with no other output. What happened?

2
  • So, in your current directory, is there a file fs/aufs/magic.mk ? Commented Oct 26, 2020 at 23:02
  • 1
    No, it doesn't exist. This error is being printed by a makefile within the kernel, so it would be under the kernel source tree, not $PWD. It doesn't exist with older kernels, either. I finally figured out what is going on (see answer): in newer versions, the SUBDIRS argument is totally ignored, so it's trying to compile the whole kernel (or a lot of it, anyway). But no configuration has been done so it fails right away.
    – durka42
    Commented Oct 26, 2020 at 23:56

1 Answer 1

3

The vital clue is in the kernel version that failed to compile: 5.4.0-42-generic.

Support for the SUBDIRS parameter was removed in that version in favor of the newer M parameter and KBUILD_EXTMOD environment variable.

Previous versions (since 11/2018) printed a warning even while successfully compiling, so depending on how often you update your packages, this should've been showing up for a while:

make[1]: Entering directory '/usr/src/linux-headers-5.3.0-40-generic'
Makefile:227: ================= WARNING ================
Makefile:228: 'SUBDIRS' will be removed after Linux 5.3
Makefile:229:
Makefile:230: If you are building an individual subdirectory
Makefile:231: in the kernel tree, you can do like this:
Makefile:232: $ make path/to/dir/you/want/to/build/
Makefile:233: (Do not forget the trailing slash)
Makefile:234:
Makefile:235: If you are building an external module,
Makefile:236: Please use 'M=' or 'KBUILD_EXTMOD' instead
Makefile:237: ==========================================

Don't ignore these warnings! They nearly always indicate areas of technical debt.

You need to update your build to use the new way to build external modules.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .