[PATCH] kbuild: serialize scripts after scripts_unifdef

From: HONG Yifan

Date: Thu Dec 03 2026 - 14:18:35 EST


When CONFIG_HEADERS_INSTALL is enabled, the prepare target depends on
both prepare0 -> archprepare -> scripts and headers -> scripts_unifdef
with no ordering between scripts and scripts_unifdef. Both targets
invoke $(MAKE) $(build)=scripts concurrently:

scripts: $(MAKE) $(build)=scripts
scripts_unifdef: $(MAKE) $(build)=scripts scripts/unifdef

Because scripts/Makefile lists unifdef in hostprogs,
scripts/Makefile.host adds scripts/unifdef to targets, causing
scripts/Makefile.build to include scripts/.unifdef.cmd as soon as
scripts/unifdef exists. If scripts reads scripts/.unifdef.cmd while
scripts_unifdef is still writing it via fixdep, make aborts with:

scripts/.unifdef.cmd:1: *** missing separator. Stop.
make[2]: *** [Makefile:1400: scripts] Error 2

Make scripts depend on scripts_unifdef under CONFIG_HEADERS_INSTALL so
scripts_unifdef finishes before scripts enters scripts/. Keeping the
dependency under CONFIG_HEADERS_INSTALL avoids building scripts/unifdef
when it is not needed and preserves "make headers" without a .config.

Bug triage, instrumented reproduction, and patch drafting were assisted
by Gemini.

Fixes: e949f4c2d6a3 ("kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: HONG Yifan <elsk@xxxxxxxxxx>
---
Makefile | 1 +
1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 5aac6f1b011e..787e041b5d7e 100644
--- a/Makefile
+++ b/Makefile
@@ -1518,6 +1518,7 @@ endif

ifdef CONFIG_HEADERS_INSTALL
prepare: headers
+scripts: scripts_unifdef
endif

PHONY += scripts_gen_init_cpio

base-commit: 63fdb511c27afcebce797e3db580b3534ddfa639
--
2.56.1.915.g69d5ec7298-goog