mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Kbuild: make sure to build fixdep first
@ 2025-10-22 13:37 Sascha Hauer
  2025-10-22 14:01 ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2025-10-22 13:37 UTC (permalink / raw)
  To: Barebox List

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@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




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

* Re: [PATCH] Kbuild: make sure to build fixdep first
  2025-10-22 13:37 [PATCH] Kbuild: make sure to build fixdep first Sascha Hauer
@ 2025-10-22 14:01 ` Ahmad Fatoum
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-10-22 14:01 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

Hi,

On 10/22/25 3:37 PM, Sascha Hauer wrote:
> 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@pengutronix.de>

:|

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

But got a comment below:

> ---
>  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

Can we name the directory just sconfig?
Maybe we add different utilities there in future.

>  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

This comment should migrate to the new scripts/sconfig/Makefile as well.

Cheers,
Ahmad

>  
>  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

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] Kbuild: make sure to build fixdep first
  2025-10-22 14:13 Sascha Hauer
@ 2025-10-22 15:55 ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-10-22 15:55 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer; +Cc: Ahmad Fatoum


On Wed, 22 Oct 2025 16:13:23 +0200, Sascha Hauer wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] Kbuild: make sure to build fixdep first
      https://git.pengutronix.de/cgit/barebox/commit/?id=e7f7ae79c4b8 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

* [PATCH] Kbuild: make sure to build fixdep first
@ 2025-10-22 14:13 Sascha Hauer
  2025-10-22 15:55 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2025-10-22 14:13 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

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")
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20251022133738.1395366-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---

Changes since v1:
- rename sconfigpost directory to sconfig
- move .gitignore content and Makefile comment to new directory

 Makefile                                 | 10 +++++++---
 scripts/basic/.gitignore                 |  1 -
 scripts/basic/Makefile                   |  2 --
 scripts/sconfig/.gitignore               |  2 ++
 scripts/sconfig/Makefile                 |  5 +++++
 scripts/{basic => sconfig}/sconfigpost.c |  0
 6 files changed, 14 insertions(+), 6 deletions(-)
 create mode 100644 scripts/sconfig/.gitignore
 create mode 100644 scripts/sconfig/Makefile
 rename scripts/{basic => sconfig}/sconfigpost.c (100%)

diff --git a/Makefile b/Makefile
index 7884953539..9af028cbc6 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/sconfig/sconfigpost
 PERL		= perl
 PYTHON3		= python3
 CHECK		= sparse
@@ -556,6 +556,10 @@ PHONY += scripts_basic
 scripts_basic:
 	$(Q)$(MAKE) $(build)=scripts/basic
 
+PHONY += scripts_sconfig
+scripts_sconfig: scripts_basic
+	$(Q)$(MAKE) $(build)=scripts/sconfig
+
 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_sconfig 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_sconfig 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/.gitignore b/scripts/basic/.gitignore
index 660035252b..961c91c8a8 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,3 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
 /fixdep
-/sconfigpost
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index cd4d9f321d..eeb6a38c55 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -1,7 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 # fixdep: used to generate dependency information during build process
-# sconfigpost: used to postprocess security configs
 
 hostprogs-always-y	+= fixdep
-hostprogs-always-y	+= sconfigpost
diff --git a/scripts/sconfig/.gitignore b/scripts/sconfig/.gitignore
new file mode 100644
index 0000000000..ceb67806fe
--- /dev/null
+++ b/scripts/sconfig/.gitignore
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+/sconfigpost
diff --git a/scripts/sconfig/Makefile b/scripts/sconfig/Makefile
new file mode 100644
index 0000000000..d40769dab5
--- /dev/null
+++ b/scripts/sconfig/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# sconfigpost: used to postprocess security configs
+
+hostprogs-always-y	+= sconfigpost
diff --git a/scripts/basic/sconfigpost.c b/scripts/sconfig/sconfigpost.c
similarity index 100%
rename from scripts/basic/sconfigpost.c
rename to scripts/sconfig/sconfigpost.c
-- 
2.47.3




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

end of thread, other threads:[~2025-10-22 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22 13:37 [PATCH] Kbuild: make sure to build fixdep first Sascha Hauer
2025-10-22 14:01 ` Ahmad Fatoum
2025-10-22 14:13 Sascha Hauer
2025-10-22 15:55 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox