public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 3/3] [pending] kbuild: make forbid sharing objects among multiple modules
Date: Sun, 13 Nov 2022 20:15:25 +0900	[thread overview]
Message-ID: <20221113111525.3762483-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20221113111525.3762483-1-masahiroy@kernel.org>

 *** This patch is applicable after all the warnings are fixed.
 *** It may take a couple of development cycles.

Now that all the warnings are fixed, the warning can be promoted to
an error.

Simplify the modules.builtin rule because modname always consists of
a single word.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.build     | 6 ------
 scripts/Makefile.lib       | 8 ++++----
 scripts/Makefile.vmlinux_o | 5 +----
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 799df12b53f3..37cf88d076e8 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -222,10 +222,6 @@ endif
 
 cmd_check_local_export = $(srctree)/scripts/check-local-export $@
 
-ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
-cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
-endif
-
 define rule_cc_o_c
 	$(call cmd_and_fixdep,cc_o_c)
 	$(call cmd,gen_ksymdeps)
@@ -235,7 +231,6 @@ define rule_cc_o_c
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_c)
 	$(call cmd,record_mcount)
-	$(call cmd,warn_shared_object)
 endef
 
 define rule_as_o_S
@@ -244,7 +239,6 @@ define rule_as_o_S
 	$(call cmd,check_local_export)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_S)
-	$(call cmd,warn_shared_object)
 endef
 
 # Built-in and composite module parts
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3aa384cec76b..d73bfe0fabda 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -106,13 +106,13 @@ endif
 
 # Finds the multi-part object the current object will be linked into.
 # If the object belongs to two or more multi-part objects, list them all.
-modname-multi = $(sort $(foreach m,$(multi-obj-ym),\
+__modname-multi = $(sort $(foreach m,$(multi-obj-ym),\
 		$(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=))))
 
-__modname = $(or $(modname-multi),$(basetarget))
+modname-multi = $(if $(word 2, $(__modname-multi)), $(error $(kbuild-file): $*.o is added to multiple modules: $(__modname-multi)))$(__modname-multi)
 
-modname = $(subst $(space),:,$(__modname))
-modfile = $(addprefix $(obj)/,$(__modname))
+modname = $(or $(modname-multi),$(basetarget))
+modfile = $(addprefix $(obj)/,$(modname))
 
 # target with $(obj)/ and its suffix stripped
 target-stem = $(basename $(patsubst $(obj)/%,%,$@))
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 0edfdb40364b..2faf4960aa7a 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -74,13 +74,10 @@ modules.builtin.modinfo: vmlinux.o FORCE
 # module.builtin
 # ---------------------------------------------------------------------------
 
-# The second line aids cases where multiple modules share the same object.
-
 quiet_cmd_modules_builtin = GEN     $@
       cmd_modules_builtin = \
 	tr '\0' '\n' < $< | \
-	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
-	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
+	sed -n 's@^[[:alnum:]:_]*\.file=\(.*\)@kernel/\1.ko@p' | uniq > $@
 
 targets += modules.builtin
 modules.builtin: modules.builtin.modinfo FORCE
-- 
2.34.1


  parent reply	other threads:[~2022-11-13 11:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-13 11:15 [PATCH 0/3] kbuild: detect objects shared among multiple modules Masahiro Yamada
2022-11-13 11:15 ` [PATCH 1/3] kbuild: add kbuild-file macro Masahiro Yamada
2022-11-17 20:47   ` Nicolas Schier
2022-11-18  0:45     ` Masahiro Yamada
2022-11-13 11:15 ` [PATCH 2/3] kbuild: warn objects shared among multiple modules Masahiro Yamada
2022-11-13 12:20   ` Masahiro Yamada
2022-11-13 11:15 ` Masahiro Yamada [this message]
2022-11-22  6:27   ` [PATCH 3/3] [pending] kbuild: make forbid sharing objects " Nicolas Schier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221113111525.3762483-4-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox