All of lore.kernel.org
 help / color / mirror / Atom feed
* make modules_prepare failing
@ 2021-06-16 19:35 Tim Harvey
  2021-06-16 19:55 ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Harvey @ 2021-06-16 19:35 UTC (permalink / raw)
  To: Linux ARM Mailing List

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

A 'make mrproper' as suggested just complains that a .config is not
found, but then if there is a .config found it will complain I need to
make mrproper again.

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 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.

Any suggestions?

Best regards,

Tim

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: make modules_prepare failing
  2021-06-16 19:35 make modules_prepare failing Tim Harvey
@ 2021-06-16 19:55 ` Russell King (Oracle)
  2021-06-16 20:21   ` Tim Harvey
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2021-06-16 19:55 UTC (permalink / raw)
  To: Tim Harvey; +Cc: Linux ARM Mailing List

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.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: make modules_prepare failing
  2021-06-16 19:55 ` Russell King (Oracle)
@ 2021-06-16 20:21   ` Tim Harvey
  2021-06-16 20:37     ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Harvey @ 2021-06-16 20:21 UTC (permalink / raw)
  To: Russell King (Oracle); +Cc: Linux ARM Mailing List

On Wed, Jun 16, 2021 at 12:55 PM Russell King (Oracle)
<linux@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:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
$ uname -r
5.4.0-73-generic
$ dpkg -S /usr/src/linux-headers-5.4.0-73-generic
linux-headers-5.4.0-73-generic: /usr/src/linux-headers-5.4.0-73-generic
$ dpkg -L linux-headers-5.4.0-73-generic
/.
/lib
/lib/modules
/lib/modules/5.4.0-73-generic
/usr
/usr/share
/usr/share/doc
/usr/share/doc/linux-headers-5.4.0-73-generic
/usr/share/doc/linux-headers-5.4.0-73-generic/changelog.Debian.gz
/usr/share/doc/linux-headers-5.4.0-73-generic/copyright
/usr/src
/usr/src/linux-headers-5.4.0-73-generic
/usr/src/linux-headers-5.4.0-73-generic/.config
/usr/src/linux-headers-5.4.0-73-generic/.config.old
/usr/src/linux-headers-5.4.0-73-generic/.gitignore
/usr/src/linux-headers-5.4.0-73-generic/.missing-syscalls.d
/usr/src/linux-headers-5.4.0-73-generic/Module.symvers
/usr/src/linux-headers-5.4.0-73-generic/arch
...
$ dpkg -L linux-headers-5.4.0-73-generic | grep -v
"^/usr/src/linux-headers-5.4.0-73-generic"
/.
/lib
/lib/modules
/lib/modules/5.4.0-73-generic
/usr
/usr/share
/usr/share/doc
/usr/share/doc/linux-headers-5.4.0-73-generic
/usr/share/doc/linux-headers-5.4.0-73-generic/changelog.Debian.gz
/usr/share/doc/linux-headers-5.4.0-73-generic/copyright
/usr/src
/lib/modules/5.4.0-73-generic/build
$ ls -l /lib/modules/5.4.0-73-generic/build
lrwxrwxrwx 1 root root 39 Apr 16 07:44
/lib/modules/5.4.0-73-generic/build ->
/usr/src/linux-headers-5.4.0-73-generic
$ du -h /usr/src/linux-headers-5.4.0-73-generic/ | tail -n1
24M     /usr/src/linux-headers-5.4.0-73-generic/

When I started poking around to see how I could create this I did find
this guide here but it did not work (the whole mrproper clean issue):
https://unix.stackexchange.com/questions/270123/how-to-create-usr-src-linux-headers-version-files

What I am after is trying to see if I can easily appease users on
embedded Linux boards that want to build out-of-tree modules on their
target because they can't seem to wrap their head around building the
kernel+modules on a development host with a cross-toolchain (the
'proper' way to do it but which has a huge barrier to entry for many
users). They run into instructions online such as:

# build out-of-tree module
apt install build-essential
apt install linux-headers-$(uname -r)
# some out-of-tree modules have you point to kernel source via a non-std env var
make KSRC=/lib/modules/$(uname -r)/build
# others follow what the kernel docs have you do which is to do a make
in the kernel dir
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
make install

Best regards,

Tim

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: make modules_prepare failing
  2021-06-16 20:21   ` Tim Harvey
@ 2021-06-16 20:37     ` Russell King (Oracle)
  0 siblings, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2021-06-16 20:37 UTC (permalink / raw)
  To: Tim Harvey; +Cc: Linux ARM Mailing List

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@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!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-16 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 19:35 make modules_prepare failing Tim Harvey
2021-06-16 19:55 ` Russell King (Oracle)
2021-06-16 20:21   ` Tim Harvey
2021-06-16 20:37     ` Russell King (Oracle)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.