[PATCH] Kbuild: make sure to build fixdep first

Sascha Hauer s.hauer at pengutronix.de
Wed Oct 22 06:37:38 PDT 2025


A host tool is built with:

$(host-csingle): $(obj)/%: $(src)/%.c FORCE
	$(call if_changed_dep,host-csingle)

if_changed_dep calls fixdep after successful compilation. fixdep is a
host tool itself, so this only works when fixdep ist the first host tool
that is being built.

Recently the sconfigpost tool was added to scripts/basic, so it can
happen that this is built before fixdep so that the fixdep call fails.

Fix this by moving sconfigpost to a separate directory and adding
scripts_basic as a dependency.

The erroneous behaviour can be reproduced with:
make ARCH=arm --shuffle=2659722306 O=build-foo imx_v8_defconfig

Fixes: b720fb9a90 ("Add security policy support")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 Makefile                                     | 10 +++++++---
 scripts/basic/Makefile                       |  1 -
 scripts/sconfigpost/Makefile                 |  1 +
 scripts/{basic => sconfigpost}/sconfigpost.c |  0
 4 files changed, 8 insertions(+), 4 deletions(-)
 create mode 100644 scripts/sconfigpost/Makefile
 rename scripts/{basic => sconfigpost}/sconfigpost.c (100%)

diff --git a/Makefile b/Makefile
index 7884953539..3774b4f9c1 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ AWK		= awk
 GENKSYMS	= scripts/genksyms/genksyms
 DEPMOD		= /sbin/depmod
 KALLSYMS	= scripts/kallsyms
-SCONFIGPOST	= scripts/basic/sconfigpost
+SCONFIGPOST	= scripts/sconfigpost/sconfigpost
 PERL		= perl
 PYTHON3		= python3
 CHECK		= sparse
@@ -556,6 +556,10 @@ PHONY += scripts_basic
 scripts_basic:
 	$(Q)$(MAKE) $(build)=scripts/basic
 
+PHONY += scripts_sconfigpost
+scripts_sconfigpost: scripts_basic
+	$(Q)$(MAKE) $(build)=scripts/sconfigpost
+
 PHONY += outputmakefile
 # Before starting out-of-tree build, make sure the source tree is clean.
 # outputmakefile generates a Makefile in the output directory, if using a
@@ -1223,10 +1227,10 @@ endif
 quiet_cmd_sconfigpost = SCONFPP $@
       cmd_sconfigpost = $(SCONFIGPOST) $2 -D $(depfile) -o $@ $<
 
-include/generated/security_autoconf.h: .security_config scripts_basic FORCE
+include/generated/security_autoconf.h: .security_config scripts_sconfigpost FORCE
 	$(call if_changed_dep,sconfigpost,-e)
 
-include/generated/sconfig_names.h: .security_config scripts_basic include/generated/security_autoconf.h FORCE
+include/generated/sconfig_names.h: .security_config scripts_sconfigpost include/generated/security_autoconf.h FORCE
 	$(call if_changed_dep,sconfigpost,-s)
 
 archprepare: include/generated/security_autoconf.h include/generated/sconfig_names.h
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index cd4d9f321d..65a714b578 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -4,4 +4,3 @@
 # sconfigpost: used to postprocess security configs
 
 hostprogs-always-y	+= fixdep
-hostprogs-always-y	+= sconfigpost
diff --git a/scripts/sconfigpost/Makefile b/scripts/sconfigpost/Makefile
new file mode 100644
index 0000000000..6120c30459
--- /dev/null
+++ b/scripts/sconfigpost/Makefile
@@ -0,0 +1 @@
+hostprogs-always-y	+= sconfigpost
diff --git a/scripts/basic/sconfigpost.c b/scripts/sconfigpost/sconfigpost.c
similarity index 100%
rename from scripts/basic/sconfigpost.c
rename to scripts/sconfigpost/sconfigpost.c
-- 
2.47.3




More information about the barebox mailing list