make modules_prepare failing

Russell King (Oracle) linux at armlinux.org.uk
Wed Jun 16 13:37:32 PDT 2021


On Wed, Jun 16, 2021 at 01:21:36PM -0700, Tim Harvey wrote:
> On Wed, Jun 16, 2021 at 12:55 PM Russell King (Oracle)
> <linux at armlinux.org.uk> wrote:
> >
> > On Wed, Jun 16, 2021 at 12:35:16PM -0700, Tim Harvey wrote:
> > > Greetings,
> > >
> > > I'm trying to understand how to use the 'modules_prepare' target to
> > > prepare kernel headers on a dev host appropriate for building
> > > out-of-tree modules on a target board. I'm interested in the minimum
> > > headers necessary and have noticed the Ubuntu 'linux-headers-*'
> > > packages are only about 24MiB.
> > >
> > > I've looked over
> > > https://www.kernel.org/doc/Documentation/kbuild/modules.txt and it
> > > does not provide an example showing how to build the headers in a
> > > different directory.
> > >
> > > $ make O=foo modules_prepare
> > > make[1]: Entering directory '/usr/src/venice/bsp/linux/foo'
> > > ***
> > > *** The source tree is not clean, please run 'make mrproper'
> > > *** in /usr/src/venice/bsp/linux
> > > ***
> > > /usr/src/venice/bsp/linux/Makefile:512: recipe for target
> > > 'outputmakefile' failed
> > > make[1]: *** [outputmakefile] Error 1
> > > make[1]: Leaving directory '/usr/src/venice/bsp/linux/foo'
> > > Makefile:179: recipe for target 'sub-make' failed
> > > make: *** [sub-make] Error 2
> >
> > This means your tree (/usr/src/venice/bsp/linux) is not clean, it
> > is not referring to "foo". It is only possible to do a split source/
> > object tree build with a clean source tree.
> >
> > So, this is telling you to do "make mrproper" with nothing else in
> > the source directory - no O= argument. If that is still failing,
> > then it suggests there is a file somewhere in the source tree that
> > shouldn't be there.
> >
> > > The 'modules_prepare' does work if I don't try to output to a
> > > different directory but then it isn't clear what to package compared
> > > to the entire >1GiB kernel source tree.
> >
> > I'm not sure you're going about this in the correct way. Doing a
> > split object tree build does not mean everything you need to build
> > modules is in the object tree - much depends on the source tree for
> > the kernel build infrastructure and the other header files in the
> > include subdirectory, as well as other places (such as picking up
> > architecture options from arch/*/Makefile and the architecture
> > specific header files.)
> >
> > So, if you are thinking "I can just package up the object tree to
> > build modules" that is not correct.
> >
> > > I wish https://www.kernel.org/doc/Documentation/kbuild/modules.txt had
> > > an example expalining how a distro packager would create
> > > linux-headers-<foo>. I'm not familiar enough with Ubuntu packaging to
> > > understand how to disect how their packages are created.
> >
> > Isn't that package used for building the C library rather than for
> > modules? That will likely be created by "make headers_install" which
> > gives you all the headers for userspace to use with kernel internals
> > sanitised away.
> 
> Russell,
> 
> Thanks for the response.
> 
> I thought that Ubuntu's linux-headers-* package also provided enough
> to build out of tree modules but perhaps I'm wrong. Here is what I did
> to try and figure out what was in the linux-headers file on an Ubuntu
> bionic system:

Maybe it does - I don't use it, so I don't really know. If you do want
to see how ubuntu creates the package, you could grab the source
for the package and look at how they build it - that's what I would do.
Of course, such a source package would mean downloading the entire kernel
source tarball. You'll also have to look at disabling other stuff that
ubuntu builds (like the kernel binary packages themselves.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



More information about the linux-arm-kernel mailing list