All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] kbuild: call checksyscalls.sh and check-atomics.sh only if prerequisites change
@ 2022-04-26 15:52 Vincent Mailhol
  2022-04-29 17:11 ` Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Vincent Mailhol @ 2022-04-26 15:52 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek, Nick Desaulniers
  Cc: linux-kernel, linux-kbuild, Arnd Bergmann, Vincent Mailhol

Currently, checksyscalls.sh and check-atomics.sh are executed
unconditionally. Most developers will not modify the files being
checked by those scripts and thus do not need to execute these again
for each iterative make. Change Kbuild target so that those two
scripts get executed only if the prerequisite are modified.

In order to implement this we:

  1. use the if_change macro instead of cmd. c.f. [1]

  2. create two dot files: scripts/.checksyscalls and
  scripts/atomic/.check-atomics to keep track of whether the script
  were already executed or not. Otherwise, the prerequisite would
  always be considered as newer than the target (c.f. output "due to
  target missing" of make V=2).

  3. modify the CLEAN_FILES target of the root Makefile to removed the
  two temporary dot files created in 2.

We also added an additional dependency to include/linux/atomic/* for
check-atomics.sh to make sure that the script gets executed again if
the header are modified. check-atomics.sh already has a dependency
toward include/generated/asm-offsets.h and so no additional
dependencies were added.

[1] https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#command-change-detection

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
Sending this as RFC because I am not an expert of Kbuild. The use of
the dot files was my best shot at tackling this issue. Maybe there is
a smarter way which I just missed?

If I receive no comments for the next two weeks, I will resend this
patch without the RFC tag.
---
 Kbuild   | 14 ++++++++------
 Makefile |  3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Kbuild b/Kbuild
index fa441b98c9f6..d579f4971aa3 100644
--- a/Kbuild
+++ b/Kbuild
@@ -39,21 +39,23 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
 #####
 # Check for missing system calls
 
-always-y += missing-syscalls
+always-y += scripts/.missing-syscalls
 
 quiet_cmd_syscalls = CALL    $<
       cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
 
-missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
-	$(call cmd,syscalls)
+scripts/.missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
+	$(call if_changed,syscalls)
+	@touch $@
 
 #####
 # Check atomic headers are up-to-date
 
-always-y += old-atomics
+always-y += scripts/atomic/.old-atomics
 
 quiet_cmd_atomics = CALL    $<
       cmd_atomics = $(CONFIG_SHELL) $<
 
-old-atomics: scripts/atomic/check-atomics.sh FORCE
-	$(call cmd,atomics)
+scripts/atomic/.old-atomics: scripts/atomic/check-atomics.sh $(wildcard include/linux/atomic/*) FORCE
+	$(call if_changed,atomics)
+	@touch $@
diff --git a/Makefile b/Makefile
index fa5112a0ec1b..b18af9d4248a 100644
--- a/Makefile
+++ b/Makefile
@@ -1483,7 +1483,8 @@ endif # CONFIG_MODULES
 # Directories & files removed with 'make clean'
 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
 	       modules.builtin modules.builtin.modinfo modules.nsdeps \
-	       compile_commands.json .thinlto-cache
+	       compile_commands.json .thinlto-cache \
+	       scripts/.missing-syscalls scripts/atomic/.old-atomics
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_FILES += include/config include/generated          \
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-05-16  8:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 15:52 [RFC PATCH] kbuild: call checksyscalls.sh and check-atomics.sh only if prerequisites change Vincent Mailhol
2022-04-29 17:11 ` Masahiro Yamada
2022-05-07 11:43   ` Vincent MAILHOL
2022-05-02 16:52 ` kernel test robot
2022-05-07 13:11 ` [RFC PATCH v2 0/2] call " Vincent Mailhol
2022-05-07 13:11   ` [RFC PATCH v2 1/2] check-atomiscs: stop build if CONFIG_WERROR=y Vincent Mailhol
2022-05-07 13:11   ` [RFC PATCH v2 2/2] kbuild: call check-atomics.sh only if prerequisites change Vincent Mailhol
2022-05-13 19:01     ` Masahiro Yamada
2022-05-14  3:21       ` Vincent MAILHOL
2022-05-14 13:14       ` Peter Zijlstra
2022-05-14 14:55         ` Peter Zijlstra
2022-05-14 16:26           ` Masahiro Yamada
2022-05-16  8:02             ` Peter Zijlstra
2022-05-14 16:07         ` Masahiro Yamada
2022-05-16  7:59           ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.