Subject: Re: [bug#35110] [PATCH 1/3] gnu: Add make-linux-module.

From: Danny Milosavljevic <[email-masked]>
Date: Wed, 3 Apr 2019 22:48:23 +0200

Hi Ludo,

On Wed, 03 Apr 2019 22:16:07 +0200
Ludovic Courtès <[email-masked]> wrote:

> Would it make sense to turn it into a ‘linux-module-build-system’?  

I started on it but haven't finished it yet.

>That would avoid having to create a package object that cannot be built, just

It can be built, it's just not very useful standalone because it only contains
the source code and a few build artifacts (only the ones required to start
building a module).  On the other hand it can be substituted and that's nice
(if we can cut down the source code a lot, that is).

I don't understand how a build system would enable us to remove this step.
(If it can, that's cool!)

> to pass it to ‘make-linux-module’.  ‘linux-libre’ and ‘kmod’ would be
> implicit inputs.
> 
> > +;; FIXME: Remove CONFIG_MODULE_SRCVERSION_ALL=y from our configs.  
> 
> What does that flag do?

It adds a field "srcversion" to the ELF file of the module which is a hash of
all the source files used to build it.

Instead of removing it, we can also merge bug# 35111 instead and use that.

Otherwise, the problem is that if CONFIG_MODULE_SRCVERSION_ALL is set and
bug# 35111 not merged, one cannot build standalone modules because those
would require the file "Module.symvers" of the completely built kernel
to be available.

Linux would also write a new file "Module.symvers" in the MODPOST step of
the build of the module.

> Is it OK to use the default GCC?

Definitely not.  It has to be exactly the same gcc as used in building the
Linux kernel.

> Other than that it looks really cool!

It's just a quick hack.

I've started with the build system but it was too much work and I didn't
understand the mechanisms well enough.

For example, the lowest maintenance overhead would be to somehow have
most of linux-libre's phases be injected into the module package and have
both build in one build environment.  I.e. the module would have a package
which would actually have phases 'unpack 'prepare-linux 'build 'check 'install
where all the phases except for 'prepare-linux would be module-specific and
'prepare-linux would unpack the linux source and do everything just
like the linux-libre package would have done, up until the 'build phase.
It turned out that's too complicated to get to work for me for now.