[ovs-dev] [PATCH V2 07/11] datapath: Kbuild: Add kcompat.h header to front of NOSTDINC

Yi-Hung Wei yihung.wei at gmail.com
Fri Feb 28 00:39:27 UTC 2020


On Wed, Feb 26, 2020 at 9:42 AM Greg Rose <gvrose8192 at gmail.com> wrote:
>
> Since this commit in the Linux upstream kernel:
> 'commit 9b9a3f20cbe0 ("kbuild: split final module linking out into Makefile.modfinal")'
> The openvswitch kernel module fails to build against the upstream
> Linux kernel. The cause of the build failure is that the include of the
> KBUILD_EXTMOD variable was dropped in Makefile.modfinal when
> it was split out from Makefile.modpost.  Our Kbuild was setting
> the ccflags-y variable to include our kcompat.h header as the
> first header file.  The Linux kernel maintainer has said that
> it is incorrect to rely on the ccflags-y variable for the modfinal
> phase of the build so that is why KBUILD_EXTMOD is not included.
>
> We fix this by breaking a different Linux kernel make rule.  We
> add '-include $(builddir)/kcompat.h' to the front of the NOSTDINC
> variable setting in our Kbuild makefile.
>
> As noted already in the comment for the NOSTDINC setting:
> \# These include directories have to go before -I$(KSRC)/include.
> \# NOSTDINC_FLAGS just happens to be a variable that goes in the
> \# right place, even though it's conceptually incorrect.
>
> So we continue the misuse of the NOSTDINC variable to fix this
> issue as well.
>
> The assumption of the Linux kernel maintainers is that any
> local, out-of-tree build include files can be added to the end
> of the command line. In our case that is wrong of course, but
> there is nothing we can do about it that I know of other than using
> some utility like unifdef to strip out offending chunks of our
> compatibility layer code before invocation of Makefile.modfinal.
> That is a big change that would take a lot of work to implement.
>
> We could ask the Linux kernel maintainers to provide some
> way for out-of-tree kernel modules to include their own header
> files first in a proper manner. I consider that to be a very
> low probability of success but something we could ask about.
>
> For now we cheat and take the easy way out.
>
> Reported-by: David Ahern <dsahern at gmail.com>
> Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
> ---

Thanks for this patch.  It must be a lot of effort to figure this out.

Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>


More information about the dev mailing list