Re: [PATCH v5] modules: introduce the MODULE_SCMVERSION config
From: Masahiro Yamada
Date: Wed Jan 20 2021 - 14:48:39 EST
On Wed, Jan 20, 2021 at 9:19 AM Will McVicker <willmcvicker@xxxxxxxxxx> wrote:
> Hi Masahiro,
> After testing your suggestions for module_srcpath, I remembered why I
> needed this:
> +ifneq ($(realpath $(srctree)/$(KBUILD_EXTMOD) 2>/dev/null),)
> + module_srcpath := $(srctree)/$(KBUILD_EXTMOD)
> + module_srcpath := $(KBUILD_EXTMOD)
> Basically KBUILD_EXTMOD actually has two uses when defined as a relative path:
> (1) defines the path to the external module's source relative to $(srctree)
> (2) defines the path to the external module's build artifacts relative
> to $(objtree)
> Since setlocalversion is run from $(objtree), we need to use
> $(srctree)/$(KBUILD_EXTMOD) when it's a relative path. Just to note,
> if I do just use KBUILD_EXTMOD, then the script setlocalversion fails
> to find the srctree and returns an empty string.
> Please correct me if I'm wrong. I messed around with this by adding
> many prints to Makefile.modpost and setlocalversion to make sure
> everything was defined as expected.
Hmm, you are right.
I did not know the current Kbuild works like that.
But, I do not want to uglify the code
just for supporting this rare use-case.
Rather, I want to apply this
and, still want to see as simple code as the following:
@@ -66,6 +66,7 @@ ifeq ($(KBUILD_EXTMOD),)
input-symdump := vmlinux.symvers
output-symdump := Module.symvers
+module-srcpath := $(srctree)
@@ -82,9 +83,20 @@ MODPOST += -e
input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
+module-srcpath := $(KBUILD_EXTMOD)