Re: MO flag not working properly for building out-of-tree modules, tries to replace the Makefile in the kernel's source.

Nicolas Schier <[email protected]> Wed, 22 Jul 2026 16:58:41 +0200
Newsgroups gmane.linux.kbuild.devel
Organization FRITZ! Technology GmbH
Message-ID <20260722-conscious-petrel-of-acumen-cdac27@l-nschier-aarch64>
[Cc: nathan]

On Thu, Jul 16, 2026 at 11:04:23PM +0530, Anish Rashinkar wrote:
> I have a few projects in which I am writing kernel modules. I use the
> MO flag to put the build artifacts in a separate directory. A simple
> make command with MO would look like -
> make -C /lib/modules/$(uname -r)/build M=$PWD MO=$PWD/build/ modules
> 
> This used to work for me, and still works for me if I boot into the
> 6.19.10-300 kernel that Fedora preserved. I was on 7.0.X for a while
> on Arch Linux and it worked there too. I am not sure but I might have
> tried compiling my projects (if so, compiled successfully) on Fedora
> Atomic that I was trying out, which should have been on 7.0 or 7.1. As
> of the latest kernels on both Arch Linux and Fedora (7.1.3-201 on
> Fedora), I encounter an error when using the MO flag.
> 
> make -C /lib/modules/7.1.3-201.fc44.x86_64/build M=/home/anish/temp
> MO=/home/anish/temp/build modules
> make[1]: Entering directory '/usr/src/kernels/7.1.3-201.fc44.x86_64'
> make[2]: Entering directory '/home/anish/temp/build'
> /bin/sh: line 1: /usr/src/kernels/7.1.3-201.fc44.x86_64/.tmp_Makefile:
> Permission denied
> make[3]: *** [/usr/src/kernels/7.1.3-201.fc44.x86_64/Makefile:705:
> /usr/src/kernels/7.1.3-201.fc44.x86_64/Makefile] Error 1
> make[2]: *** [/usr/src/kernels/7.1.3-201.fc44.x86_64/Makefile:248:
> __sub-make] Error 2
> make[2]: Leaving directory '/home/anish/temp/build'
> make[1]: *** [Makefile:248: __sub-make] Error 2
> make[1]: Leaving directory '/usr/src/kernels/7.1.3-201.fc44.x86_64'
> make: *** [Makefile:6: all] Error 2
> 
> If I grant root privileges to make, it will replace the Makefile at
> /usr/src/kernels/7.1.3-201.fc44.x86_64/Makefile with its own Makefile
> wrapper.
> 
> If I don't use the MO flag, then the build succeeds and all the build
> artifacts are stored in my source directory.
> 
> I am new to Linux programming and especially bug reporting like this.
> I had raised this issue on Fedora Discussions with no one to properly
> respond that helps the problem. This issue should have appeared
> relatively recently. Please let me know if this is a bug or something
> changed with how it should be used, because the official guides state
> the same way I mentioned in writing a Makefile and using the MO flag.
> And with what I can comprehend and with what all LLMs are saying, this
> is a bug.

Thanks for the report!  This is definitely a bug and I can reproduce 
this.  I'll have a look at it tomorrow.

Kind regards,
Nicolas
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEDv+Fiet06YHnC6RpiMa8nIiabbgFAmpg2psACgkQiMa8nIia
bbiJFw//eotunoDJjVU9BuxHQSfWre0+knH9OVLfYeqxuayv9Sl/DYqT2EEWif1E
5yLbilagQ3Z5NvI7d4AzQXIje5ij4xcQuFcDuf6S6xSepr1TYQzZ++an2CbznD7J
kb7Mu4mykwZrACTTETQ/b5FVxADkN2uz6cdIX+CbDJipIBexCJZvBBqHmPj/bOdX
gyeBOjgy7OGEI89nY0LqS5ZKRATkPOJskoBn7kPLmZZdP88JYuoTvkAnsVEua76F
XUGnE8NedDvg/UWs5k69kYw3yciGvLZ0fcrO6p+i/1TR4iLZQ8joTZAe8eQgIKe2
EI5M9Yzu3Ce2ePOdMSLmIoJd/RYioL0y+yn3PcWGaMJT/bt4uKz/wQj3HM6mtUmj
ha8GdBrVGFm5nulPk8EO3YWj76Vhe2ekhQG1ylqPajpyhdWiED/30UACzHfP8FNM
/cCH5GqK/4ob682r3bzTMHBp8D0Bll1t4kRDGbsIrdGNUBhJIz2uW/BWmYQ7G7oR
F5RxRgrGFd7mjd4QqzEwePAau8V1CFFGb7tXHYGj/8bb2DelUMn9QlDuj6+6Ybl6
HwlWjDarICcPWbM4HM3JsIq07fifkuywoQvuwZxi8iR0DAyivzwx7MLtcYdmmjzS
jq8gYStshSwzyLlu7T4gbMrFM9Z4HnldCzIWnX1y0GkiOkaZeTc=
=BXtC
-----END PGP SIGNATURE-----