[PATCH v2 0/3] kbuild: reduce single-build dependencies
From: Vincent Mailhol
Date: Fri Nov 13 2026 - 13:23:59 EST
Building a single .o file depends on the prepare target which contains a
lot of dependencies. Some of those preparation dependencies are not
needed for a single .o build.
This is a small annoyance because a modification of the compilation
flags causes several prepare dependencies to rebuild. Consequently,
single-build incurs an artificial penalty.
Move the generic preparation checks and scripts/mod out of the
single-build preparation path. The first patch is a preparation change
to make rq-offsets-file an explicit prepare dependency. The second
addresses missing-syscalls check and atomic-checks. The third and last
patch addresses scripts/mod.
Move the generic preparation checks and scripts/mod out of the
preparation path for single .o builds. The first patch is a preparation
change to make rq-offsets-file an explicit prepare dependency. The
second addresses missing-syscalls check and atomic-checks. The third and
last patch addresses scripts/mod.
== Illustration ==
These are the build steps triggered when just changing the compilation
flags (here: adding W=1).
Before this series...
$ time make W=1 init/main.o
CC scripts/mod/empty.o
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/modpost.o
CC scripts/mod/devicetable-offsets.s
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/sumversion.o
HOSTCC scripts/mod/symsearch.o
HOSTLD scripts/mod/modpost
CC kernel/bounds.s
CC arch/x86/kernel/asm-offsets.s
CC kernel/sched/rq-offsets.s
CALL scripts/checksyscalls.sh
DESCEND objtool
CC init/main.o
real 0m5,808s
user 0m3,216s
sys 0m3,196s
... and after:
$ time make W=1 init/main.o
CC kernel/bounds.s
CC arch/x86/kernel/asm-offsets.s
CC kernel/sched/rq-offsets.s
DESCEND objtool
CC init/main.o
real 0m4,064s
user 0m1,901s
sys 0m2,728s
(done on an x86_64 cpu).
Signed-off-by: Vincent Mailhol <mailhol@xxxxxxxxxx>
---
Changes in v2:
- Make modpost_prepare depend on prepare so scripts/mod is built after
preparation completes. This addresses the sashiko report:
https://lore.kernel.org/all/sashiko-outbox-211218@xxxxxxxxxx/
Link to v1: https://patch.msgid.link/20261111-reduce-single-build-dependencies-v1-0-7196ca986a85@xxxxxxxxxx
---
Vincent Mailhol (3):
kbuild: make rq-offsets-file an explicit preparation dependency
kbuild: move preparation checks out of single-build
kbuild: move scripts/mod target out of single-build
Kbuild | 7 +++++--
Makefile | 11 +++++++----
2 files changed, 12 insertions(+), 6 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261111-reduce-single-build-dependencies-966646f25a0c
Best regards,
--
Vincent Mailhol <mailhol@xxxxxxxxxx>