public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Paul Menzel <pmenzel@molgen.mpg.de>,
	Borislav Petkov <bp@alien8.de>,
	Nikolay Borisov <nik.borisov@suse.com>,
	Marco Elver <elver@google.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] kbuild: move cmd_cc_o_c and cmd_as_o_S to scripts/Malefile.lib
Date: Thu, 14 Nov 2024 08:45:21 +0900	[thread overview]
Message-ID: <20241113234526.402738-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20241113234526.402738-1-masahiroy@kernel.org>

The cmd_cc_o_c and cmd_as_o_S macros are duplicated in
scripts/Makefile.{build,modfinal,vmlinux}.

This commit factors them out to scripts/Makefile.lib.

No functional changes are intended.

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

 scripts/Makefile.build    |  8 --------
 scripts/Makefile.lib      | 12 ++++++++++++
 scripts/Makefile.modfinal |  6 ++----
 scripts/Makefile.vmlinux  |  8 +-------
 4 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 1aa928a6fb4f..24e10c821461 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -141,11 +141,6 @@ ifdef CONFIG_LTO_CLANG
 cmd_ld_single_m = $(if $(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
 endif
 
-quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
-      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
-		$(cmd_ld_single_m) \
-		$(cmd_objtool)
-
 ifdef CONFIG_MODVERSIONS
 # When module versioning is enabled the following steps are executed:
 # o compile a <file>.o from <file>.c
@@ -336,9 +331,6 @@ cmd_cpp_s_S       = $(CPP) $(a_flags) -o $@ $<
 $(obj)/%.s: $(obj)/%.S FORCE
 	$(call if_changed_dep,cpp_s_S)
 
-quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
-      cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool)
-
 ifdef CONFIG_ASM_MODVERSIONS
 
 # versioning matches the C process described above, with difference that
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 5660dfc9ed36..73e385946855 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -298,6 +298,18 @@ $(foreach m, $1, \
 	$(addprefix $(obj)/, $(call suffix-search, $(patsubst $(obj)/%,%,$m), $2, $3))))
 endef
 
+# Build commads
+# ===========================================================================
+# These are shared by some Makefile.* files.
+
+quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
+      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
+		$(cmd_ld_single_m) \
+		$(cmd_objtool)
+
+quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
+      cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool)
+
 # Copy a file
 # ===========================================================================
 # 'cp' preserves permissions. If you use it to copy a file in read-only srctree,
diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
index bab53884f7e3..d0153d033bbb 100644
--- a/scripts/Makefile.modfinal
+++ b/scripts/Makefile.modfinal
@@ -9,7 +9,7 @@ __modfinal:
 include $(objtree)/include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
-# for c_flags
+# include some build commands
 include $(srctree)/scripts/Makefile.lib
 
 # find all modules listed in modules.order
@@ -23,9 +23,7 @@ modname = $(notdir $(@:.mod.o=))
 part-of-module = y
 GCOV_PROFILE := n
 KCSAN_SANITIZE := n
-
-quiet_cmd_cc_o_c = CC [M]  $@
-      cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $<
+ccflags-remove-y := $(CC_FLAGS_CFI)
 
 %.mod.o: %.mod.c FORCE
 	$(call if_changed_dep,cc_o_c)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 9ef0480ed755..1652561896eb 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -6,20 +6,14 @@ __default: vmlinux
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
-# for c_flags
+# include some build commands
 include $(srctree)/scripts/Makefile.lib
 
 targets :=
 
-quiet_cmd_cc_o_c = CC      $@
-      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
-
 %.o: %.c FORCE
 	$(call if_changed_dep,cc_o_c)
 
-quiet_cmd_as_o_S = AS      $@
-      cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
-
 %.o: %.S FORCE
 	$(call if_changed_dep,as_o_S)
 
-- 
2.43.0


  reply	other threads:[~2024-11-13 23:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13 23:45 [PATCH 0/3] kbuild: enable objtool for more objects and re-enable KCSAN for *.mod.o Masahiro Yamada
2024-11-13 23:45 ` Masahiro Yamada [this message]
2024-11-16  9:19   ` [PATCH 1/3] kbuild: move cmd_cc_o_c and cmd_as_o_S to scripts/Malefile.lib Masahiro Yamada
2024-11-13 23:45 ` [PATCH 2/3] kbuild: enable objtool for *.mod.o and additional kernel objects Masahiro Yamada
2024-11-19  2:27   ` Nathan Chancellor
2024-11-19 17:22     ` Masahiro Yamada
2024-11-13 23:45 ` [PATCH 3/3] kbuild: re-enable KCSAN for autogenerated *.mod.c intermediaries Masahiro Yamada

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=20241113234526.402738-2-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=bp@alien8.de \
    --cc=elver@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=nik.borisov@suse.com \
    --cc=pmenzel@molgen.mpg.de \
    /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