]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit - scripts/Makefile.lib
kbuild: define KBUILD_MODNAME even if multiple modules share objects
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 19 Mar 2018 09:01:24 +0000 (18:01 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sun, 25 Mar 2018 17:01:25 +0000 (02:01 +0900)
commitaeacb019b61c4ea7689085574bd03d2c0810f119
tree79e90bf5709b0b33592c912a281294b15e04d535
parent8cd0e46d3f0ce730a5c7d1e9e75765b24b72013a
kbuild: define KBUILD_MODNAME even if multiple modules share objects

Currently, KBUILD_MODNAME is defined only when $(modname) contains
just one word.  If an object is shared among multiple modules,
undefined KBUILD_MODNAME could cause a build error.  For example,
if CONFIG_DYNAMIC_DEBUG is enabled, any call of printk() populates
.modname, then fails to build due to undefined KBUILD_MODNAME.

Take the following code as an example:

  obj-m += foo.o
  obj-m += bar.o
  foo-objs := foo-bar-common.o foo-only.o
  bar-objs := foo-bar-common.o bar-only.o

In this case, there is room for argument what to define for
KBUILD_MODNAME when foo-bar-common.o is being compiled.
"foo", "bar", or what else?

One idea is to define colon-separated modules that share the object,
in this case, "bar:foo" (modules are sorted alphabetically by
$(sort ...)).

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Cao jin <caoj.fnst@cn.fujitsu.com>
scripts/Makefile.lib