All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] kbuild: reduce single-build dependencies
@ 2026-11-11 13:41 Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 1/3] kbuild: make rq-offsets-file an explicit preparation dependency Vincent Mailhol
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vincent Mailhol @ 2026-11-11 13:41 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: linux-kernel, linux-kbuild, Vincent Mailhol

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.

== Illustration ==

These are the build steps triggered when 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	0m3.603s
  user	0m2.839s
  sys	0m0.959s

... 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	0m2.060s
  user	0m1.505s
  sys	0m0.732s

(done on an x86_64 cpu).

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
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@kernel.org>


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

* [PATCH 1/3] kbuild: make rq-offsets-file an explicit preparation dependency
  2026-11-11 13:41 [PATCH 0/3] kbuild: reduce single-build dependencies Vincent Mailhol
@ 2026-11-11 13:41 ` Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 2/3] kbuild: move preparation checks out of single-build Vincent Mailhol
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Vincent Mailhol @ 2026-11-11 13:41 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: linux-kernel, linux-kbuild, Vincent Mailhol

The generated rq-offsets.h header is included by linux/sched.h and must
exist before compiling ordinary objects. Currently that header is
prepared indirectly through the missing-syscalls target.

Make prepare depend directly on rq-offsets-file. Because rq-offsets-file
depends on offsets-file, that other dependency can be removed.

Keep the rq-offsets-file dependency in missing-syscalls so that the
check can still run independently.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 Kbuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Kbuild b/Kbuild
index a6a0192dea08..5a65be2d51b0 100644
--- a/Kbuild
+++ b/Kbuild
@@ -87,7 +87,7 @@ $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/%  FORCE
 # A phony target that depends on all the preparation targets
 
 PHONY += prepare
-prepare: $(offsets-file) missing-syscalls $(atomic-checks)
+prepare: $(rq-offsets-file) missing-syscalls $(atomic-checks)
 	@:
 
 # Ordinary directory descending

-- 
2.56.1


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

* [PATCH 2/3] kbuild: move preparation checks out of single-build
  2026-11-11 13:41 [PATCH 0/3] kbuild: reduce single-build dependencies Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 1/3] kbuild: make rq-offsets-file an explicit preparation dependency Vincent Mailhol
@ 2026-11-11 13:41 ` Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 3/3] kbuild: move scripts/mod target " Vincent Mailhol
  2026-11-23 16:53 ` [PATCH 0/3] kbuild: reduce single-build dependencies Nicolas Schier
  3 siblings, 0 replies; 8+ messages in thread
From: Vincent Mailhol @ 2026-11-11 13:41 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: linux-kernel, linux-kbuild, Vincent Mailhol

The missing-syscalls check and the atomic-checks are currently set as
preparation dependencies. However, these are not needed to compile, for
example, a single object.

Add a new prepare_checks target to group those checks and call it
conditionally only if we are not doing a single-build so that the
prepare target does not trigger that dependency anymore.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 Kbuild   | 7 +++++--
 Makefile | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Kbuild b/Kbuild
index 5a65be2d51b0..5151e32985c6 100644
--- a/Kbuild
+++ b/Kbuild
@@ -86,8 +86,11 @@ $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/%  FORCE
 
 # A phony target that depends on all the preparation targets
 
-PHONY += prepare
-prepare: $(rq-offsets-file) missing-syscalls $(atomic-checks)
+PHONY += prepare prepare_checks
+prepare: $(rq-offsets-file)
+	@:
+
+prepare_checks: missing-syscalls $(atomic-checks)
 	@:
 
 # Ordinary directory descending
diff --git a/Makefile b/Makefile
index f895752d4b05..2c1289a44c56 100644
--- a/Makefile
+++ b/Makefile
@@ -1413,8 +1413,8 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
 	include/generated/rustc_cfg remove-stale-files
 
 prepare0: archprepare
+	$(Q)$(MAKE) $(build)=. prepare $(if $(single-build),,prepare_checks)
 	$(Q)$(MAKE) $(build)=scripts/mod
-	$(Q)$(MAKE) $(build)=. prepare
 
 # All the preparing..
 prepare: prepare0

-- 
2.56.1


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

* [PATCH 3/3] kbuild: move scripts/mod target out of single-build
  2026-11-11 13:41 [PATCH 0/3] kbuild: reduce single-build dependencies Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 1/3] kbuild: make rq-offsets-file an explicit preparation dependency Vincent Mailhol
  2026-11-11 13:41 ` [PATCH 2/3] kbuild: move preparation checks out of single-build Vincent Mailhol
@ 2026-11-11 13:41 ` Vincent Mailhol
  2026-11-12 13:45   ` sashiko-bot
  2026-11-23 16:53 ` [PATCH 0/3] kbuild: reduce single-build dependencies Nicolas Schier
  3 siblings, 1 reply; 8+ messages in thread
From: Vincent Mailhol @ 2026-11-11 13:41 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: linux-kernel, linux-kbuild, Vincent Mailhol

The scripts/mod target is currently set as a preparation dependency.
However, this is not needed to compile, for example, a single object.

Add a new modpost_prepare target for scripts/mod and make in-tree
modpost and modules_prepare depend on it so that the prepare target does
not trigger that dependency anymore.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 2c1289a44c56..93236f310f08 100644
--- a/Makefile
+++ b/Makefile
@@ -1405,7 +1405,7 @@ scripts: scripts_basic scripts_dtc
 # archprepare is used in arch Makefiles and when processed asm symlink,
 # version.h and scripts_basic is processed / created.
 
-PHONY += prepare archprepare
+PHONY += prepare archprepare modpost_prepare
 
 archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
 	asm-generic $(version_h) include/generated/utsrelease.h \
@@ -1414,6 +1414,8 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
 
 prepare0: archprepare
 	$(Q)$(MAKE) $(build)=. prepare $(if $(single-build),,prepare_checks)
+
+modpost_prepare: archprepare
 	$(Q)$(MAKE) $(build)=scripts/mod
 
 # All the preparing..
@@ -1765,7 +1767,7 @@ endif
 modules: modules_prepare
 
 # Target to prepare building external modules
-modules_prepare: prepare
+modules_prepare: prepare modpost_prepare
 	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
 
 endif # CONFIG_MODULES
@@ -2189,7 +2191,8 @@ KBUILD_MODULES :=
 endif # CONFIG_MODULES
 
 PHONY += modpost
-modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
+modpost: $(if $(KBUILD_EXTMOD),,modpost_prepare) \
+	 $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
 	 $(if $(KBUILD_MODULES), modules_check)
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 

-- 
2.56.1


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

* Re: [PATCH 3/3] kbuild: move scripts/mod target out of single-build
  2026-11-11 13:41 ` [PATCH 3/3] kbuild: move scripts/mod target " Vincent Mailhol
@ 2026-11-12 13:45   ` sashiko-bot
  2026-11-23 16:52     ` Nicolas Schier
  0 siblings, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-11-12 13:45 UTC (permalink / raw)
  To: Vincent Mailhol, Nathan Chancellor, Nicolas Schier; +Cc: linux-kbuild

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] kbuild: unordered modpost_prepare and stack_protector_prepare
  mutates CFLAGS
--

commit 08ffc13380249741520c2ea434688d701b5d0e9b
Author: Vincent Mailhol <mailhol@kernel.org>

kbuild: move scripts/mod target out of single-build

This commit moves the scripts/mod build out of prepare0 into a new
modpost_prepare target depended on by modules_prepare and modpost.

> diff --git a/Makefile b/Makefile
> index 2c1289a44c560..93236f310f080 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1405,7 +1405,7 @@ scripts: scripts_basic scripts_dtc
>  # archprepare is used in arch Makefiles and when processed asm symlink,
>  # version.h and scripts_basic is processed / created.
>  
> -PHONY += prepare archprepare
> +PHONY += prepare archprepare modpost_prepare
>  
>  archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
>  	asm-generic $(version_h) include/generated/utsrelease.h \
> @@ -1414,6 +1414,8 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
>  
>  prepare0: archprepare
>  	$(Q)$(MAKE) $(build)=. prepare $(if $(single-build),,prepare_checks)
> +
> +modpost_prepare: archprepare
>  	$(Q)$(MAKE) $(build)=scripts/mod

[Severity: Low]
Should modpost_prepare be ordered relative to stack_protector_prepare (or
depend on prepare)?

On arm, arm64, powerpc, and riscv, prepare depends on
stack_protector_prepare, which depends on prepare0 and mutates the
exported KBUILD_CFLAGS variable at recipe execution time:

arch/arm64/Makefile:
prepare: stack_protector_prepare
stack_protector_prepare: prepare0
	$(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg		  \
				-mstack-protector-guard-reg=sp_el0	  \
				-mstack-protector-guard-offset=$(shell	  \
			awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
				$(objtree)/include/generated/asm-offsets.h))

Previously, scripts/mod was built inside prepare0, so it always ran before
stack_protector_prepare modified KBUILD_CFLAGS.  With modpost_prepare
only depending on archprepare, a parallel build runs modpost_prepare
concurrently with prepare0 before stack_protector_prepare updates
KBUILD_CFLAGS, whereas a serial build or make modules_prepare runs
prepare first and passes the updated KBUILD_CFLAGS to scripts/mod.

Because scripts/mod/empty.o is compiled with KBUILD_CFLAGS, switching
between parallel and serial or single-module builds changes its recorded
command line, rebuilding empty.o, regenerating elfconfig.h (which uses
if_changed), and forcing a full rebuild of modpost.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111-reduce-single-build-dependencies-v1-0-7196ca986a85@kernel.org?part=3

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

* Re: [PATCH 3/3] kbuild: move scripts/mod target out of single-build
  2026-11-12 13:45   ` sashiko-bot
@ 2026-11-23 16:52     ` Nicolas Schier
  2026-11-24  7:24       ` Vincent Mailhol
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Schier @ 2026-11-23 16:52 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: Vincent Mailhol, Nathan Chancellor, linux-kbuild

On Thu, Nov 12, 2026 at 01:45:43PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] kbuild: unordered modpost_prepare and stack_protector_prepare
>   mutates CFLAGS
> --
> 
> commit 08ffc13380249741520c2ea434688d701b5d0e9b
> Author: Vincent Mailhol <mailhol@kernel.org>
> 
> kbuild: move scripts/mod target out of single-build
> 
> This commit moves the scripts/mod build out of prepare0 into a new
> modpost_prepare target depended on by modules_prepare and modpost.
> 
> > diff --git a/Makefile b/Makefile
> > index 2c1289a44c560..93236f310f080 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1405,7 +1405,7 @@ scripts: scripts_basic scripts_dtc
> >  # archprepare is used in arch Makefiles and when processed asm symlink,
> >  # version.h and scripts_basic is processed / created.
> >  
> > -PHONY += prepare archprepare
> > +PHONY += prepare archprepare modpost_prepare
> >  
> >  archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
> >  	asm-generic $(version_h) include/generated/utsrelease.h \
> > @@ -1414,6 +1414,8 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
> >  
> >  prepare0: archprepare
> >  	$(Q)$(MAKE) $(build)=. prepare $(if $(single-build),,prepare_checks)
> > +
> > +modpost_prepare: archprepare
> >  	$(Q)$(MAKE) $(build)=scripts/mod
> 
> [Severity: Low]
> Should modpost_prepare be ordered relative to stack_protector_prepare (or
> depend on prepare)?
> 
> On arm, arm64, powerpc, and riscv, prepare depends on
> stack_protector_prepare, which depends on prepare0 and mutates the
> exported KBUILD_CFLAGS variable at recipe execution time:
> 
> arch/arm64/Makefile:
> prepare: stack_protector_prepare
> stack_protector_prepare: prepare0
> 	$(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg		  \
> 				-mstack-protector-guard-reg=sp_el0	  \
> 				-mstack-protector-guard-offset=$(shell	  \
> 			awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
> 				$(objtree)/include/generated/asm-offsets.h))
> 
> Previously, scripts/mod was built inside prepare0, so it always ran before
> stack_protector_prepare modified KBUILD_CFLAGS.  With modpost_prepare
> only depending on archprepare, a parallel build runs modpost_prepare
> concurrently with prepare0 before stack_protector_prepare updates
> KBUILD_CFLAGS, whereas a serial build or make modules_prepare runs
> prepare first and passes the updated KBUILD_CFLAGS to scripts/mod.
> 
> Because scripts/mod/empty.o is compiled with KBUILD_CFLAGS, switching
> between parallel and serial or single-module builds changes its recorded
> command line, rebuilding empty.o, regenerating elfconfig.h (which uses
> if_changed), and forcing a full rebuild of modpost.

Well yes,

   make scripts/mod/empty.o && make modules

leads to a rebuild of empty.o and modpost triggered by 'make modules'.
But if that is the only negative implication, this is not relevant as I
expect no human wants to build scripts/mod/empty.o as a single-target.

-- 
Nicolas

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

* Re: [PATCH 0/3] kbuild: reduce single-build dependencies
  2026-11-11 13:41 [PATCH 0/3] kbuild: reduce single-build dependencies Vincent Mailhol
                   ` (2 preceding siblings ...)
  2026-11-11 13:41 ` [PATCH 3/3] kbuild: move scripts/mod target " Vincent Mailhol
@ 2026-11-23 16:53 ` Nicolas Schier
  3 siblings, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2026-11-23 16:53 UTC (permalink / raw)
  To: Vincent Mailhol; +Cc: Nathan Chancellor, linux-kernel, linux-kbuild

On Wed, Nov 11, 2026 at 02:41:02PM +0100, Vincent Mailhol wrote:
> 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.
> 
> == Illustration ==
> 
> These are the build steps triggered when 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	0m3.603s
>   user	0m2.839s
>   sys	0m0.959s
> 
> ... 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	0m2.060s
>   user	0m1.505s
>   sys	0m0.732s
> 
> (done on an x86_64 cpu).
> 
> Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
> ---
> 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@kernel.org>

Thanks!

Reviewed-by: Nicolas Schier <nsc@kernel.org>

-- 
Nicolas

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

* Re: [PATCH 3/3] kbuild: move scripts/mod target out of single-build
  2026-11-23 16:52     ` Nicolas Schier
@ 2026-11-24  7:24       ` Vincent Mailhol
  0 siblings, 0 replies; 8+ messages in thread
From: Vincent Mailhol @ 2026-11-24  7:24 UTC (permalink / raw)
  To: Nicolas Schier, sashiko-reviews, Nathan Chancellor, linux-kbuild

Hi Nicolas,

Thanks for the review!

On 23/11/2026 at 17:52, Nicolas Schier wrote:
> On Thu, Nov 12, 2026 at 01:45:43PM +0000, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue to consider:
>> - [Low] kbuild: unordered modpost_prepare and stack_protector_prepare
>>   mutates CFLAGS
>> --
>>
>> commit 08ffc13380249741520c2ea434688d701b5d0e9b
>> Author: Vincent Mailhol <mailhol@kernel.org>
>>
>> kbuild: move scripts/mod target out of single-build
>>
>> This commit moves the scripts/mod build out of prepare0 into a new
>> modpost_prepare target depended on by modules_prepare and modpost.
>>
>>> diff --git a/Makefile b/Makefile
>>> index 2c1289a44c560..93236f310f080 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -1405,7 +1405,7 @@ scripts: scripts_basic scripts_dtc
>>>  # archprepare is used in arch Makefiles and when processed asm symlink,
>>>  # version.h and scripts_basic is processed / created.
>>>  
>>> -PHONY += prepare archprepare
>>> +PHONY += prepare archprepare modpost_prepare
>>>  
>>>  archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
>>>  	asm-generic $(version_h) include/generated/utsrelease.h \
>>> @@ -1414,6 +1414,8 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
>>>  
>>>  prepare0: archprepare
>>>  	$(Q)$(MAKE) $(build)=. prepare $(if $(single-build),,prepare_checks)
>>> +
>>> +modpost_prepare: archprepare
>>>  	$(Q)$(MAKE) $(build)=scripts/mod
>>
>> [Severity: Low]
>> Should modpost_prepare be ordered relative to stack_protector_prepare (or
>> depend on prepare)?
>>
>> On arm, arm64, powerpc, and riscv, prepare depends on
>> stack_protector_prepare, which depends on prepare0 and mutates the
>> exported KBUILD_CFLAGS variable at recipe execution time:
>>
>> arch/arm64/Makefile:
>> prepare: stack_protector_prepare
>> stack_protector_prepare: prepare0
>> 	$(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg		  \
>> 				-mstack-protector-guard-reg=sp_el0	  \
>> 				-mstack-protector-guard-offset=$(shell	  \
>> 			awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
>> 				$(objtree)/include/generated/asm-offsets.h))
>>
>> Previously, scripts/mod was built inside prepare0, so it always ran before
>> stack_protector_prepare modified KBUILD_CFLAGS.  With modpost_prepare
>> only depending on archprepare, a parallel build runs modpost_prepare
>> concurrently with prepare0 before stack_protector_prepare updates
>> KBUILD_CFLAGS, whereas a serial build or make modules_prepare runs
>> prepare first and passes the updated KBUILD_CFLAGS to scripts/mod.
>>
>> Because scripts/mod/empty.o is compiled with KBUILD_CFLAGS, switching
>> between parallel and serial or single-module builds changes its recorded
>> command line, rebuilding empty.o, regenerating elfconfig.h (which uses
>> if_changed), and forcing a full rebuild of modpost.
> 
> Well yes,
> 
>    make scripts/mod/empty.o && make modules
> 
> leads to a rebuild of empty.o and modpost triggered by 'make modules'.
> But if that is the only negative implication, this is not relevant as I
> expect no human wants to build scripts/mod/empty.o as a single-target.

This is indeed a low priority report, but regardless, after thinking a
bit about it, I came up with a v2 which I found a bit more elegant:

https://lore.kernel.org/all/20261113-reduce-single-build-dependencies-v2-0-93ba1f6c4e46@kernel.org/

The dependencies goes from v1:

  modpost_prepare: archprepare
  modules_prepare: prepare modpost_prepare

to v2:

  modpost_prepare: prepare
  modules_prepare: modpost_prepare

It both resolves the issue and read more naturally.


Yours sincerely,
Vincent Mailhol

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

end of thread, other threads:[~2026-11-24  7:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 13:41 [PATCH 0/3] kbuild: reduce single-build dependencies Vincent Mailhol
2026-11-11 13:41 ` [PATCH 1/3] kbuild: make rq-offsets-file an explicit preparation dependency Vincent Mailhol
2026-11-11 13:41 ` [PATCH 2/3] kbuild: move preparation checks out of single-build Vincent Mailhol
2026-11-11 13:41 ` [PATCH 3/3] kbuild: move scripts/mod target " Vincent Mailhol
2026-11-12 13:45   ` sashiko-bot
2026-11-23 16:52     ` Nicolas Schier
2026-11-24  7:24       ` Vincent Mailhol
2026-11-23 16:53 ` [PATCH 0/3] kbuild: reduce single-build dependencies Nicolas Schier

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.