Re: [PATCH] kbuild: Include external modules compile flags

From: Gregory Rose
Date: Wed Feb 05 2020 - 17:48:31 EST


On 2/1/2020 10:07 PM, Masahiro Yamada wrote:
On Thu, Jan 30, 2020 at 3:09 AM Gregory Rose <gvrose8192@xxxxxxxxx> wrote:

On 1/28/2020 7:37 AM, Gregory Rose wrote:
On 1/27/2020 7:35 PM, Masahiro Yamada wrote:
On Tue, Jan 28, 2020 at 6:50 AM Greg Rose <gvrose8192@xxxxxxxxx> wrote:
Since this commit:
'commit 9b9a3f20cbe0 ("kbuild: split final module linking out into
Makefile.modfinal")'
at least one out-of-tree external kernel module build fails
during the modfinal make phase because Makefile.modfinal does
not include the ccflags-y variable from the exernal module's Kbuild.
ccflags-y is passed only for compiling C files in that directory.

It is not used for compiling *.mod.c
This is true for both in-kernel and external modules.

So, ccflags-y is not a good choice
for passing such flags that should be globally effective.


Maybe, KCFLAGS should work.


module:
$(MAKE) KCFLAGS=... M=$(PWD) -C /lib/modules/$(uname
-r)/build modules

Hi Masahiro,

I'm unable to get that to work. KCFLAGS does not seem to be used in
Makefile.modfinal.

I quickly tested it, and confirmed
KCFLAGS works for external modules, too.


Makefile.modfinal includes scripts/Makefile.lib


So, c_flags contains $(KCFLAGS)

c_flags -> KBUILD_CFLAGS -> KCFLAGS


Hi Masahiro,

I found a way to make this work on the openvswitch out of tree kernel module. KCFLAGS
doesn't work because it is added at the end of the gcc command line and we need to
add a '-include <file>' directive so that the include file comes *before* all other include
files. I fix this by inserting the '-include <file>' command line option to the beginning
of our own Kbuild NOSTDINC variable.

Thanks for your help in debugging this.

- Greg