Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: HONG Yifan <elsk@google.com>
To: Nathan Chancellor <nathan@kernel.org>, Nicolas Schier <nsc@kernel.org>
Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	linux-kbuild@vger.kernel.org, linux-um@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	"HONG Yifan" <elsk@google.com>
Subject: [PATCH] kbuild: avoid recursive make headers when HEADER_ARCH is set
Date: Fri,  4 Dec 2026 23:21:02 +0000	[thread overview]
Message-ID: <20261204232102.1380500-1-elsk@google.com> (raw)

When HEADER_ARCH is set (ARCH=um), the headers target spawns a recursive
$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers.
This re-runs $(version_h), scripts_unifdef, uapi-asm-generic, and
archheaders a second time.

Because headers is in no-dot-config-targets, the recursive sub-make skips
include/config/auto.conf and drops CONFIG_WERROR flags (-Werror and
-Wl,--fatal-warnings) from KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS,
causing scripts/unifdef to be recompiled on every prepare build with
CONFIG_HEADERS_INSTALL=y and CONFIG_WERROR=y. During parallel builds, the
recursive $(build)=scripts scripts/unifdef also races with the scripts
target even when scripts depends on the outer scripts_unifdef.

arch/um/Makefile's archheaders target already invokes
ARCH=$(HEADER_ARCH) asm-generic archheaders, generating the required
arch/$(HEADER_ARCH)/include/generated/uapi/ headers. Invoke $(hdr-inst)
directly for include/uapi (passing SRCARCH for include/uapi/Kbuild) and
arch/$(or $(HEADER_ARCH),$(SRCARCH))/include/uapi instead of recursing
into top-level headers.

Investigation, verification, and patch drafting were assisted by Gemini.

Fixes: 268d191abc57 ("kbuild: implement CONFIG_HEADERS_INSTALL for Usermode Linux")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/CAABy=s2iGODbNUdjYFd3MHLsTWsoN3_L5=v4aTX_wW4C3n1_Rg@mail.gmail.com
Signed-off-by: HONG Yifan <elsk@google.com>
---
 Makefile | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 5aac6f1b011e..d990a19e7839 100644
--- a/Makefile
+++ b/Makefile
@@ -1509,12 +1509,8 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
 
 PHONY += headers
 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
-ifdef HEADER_ARCH
-	$(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
-else
-	$(Q)$(MAKE) $(hdr-inst)=include/uapi
-	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
-endif
+	$(Q)$(MAKE) $(hdr-inst)=include/uapi SRCARCH=$(or $(HEADER_ARCH),$(SRCARCH))
+	$(Q)$(MAKE) $(hdr-inst)=arch/$(or $(HEADER_ARCH),$(SRCARCH))/include/uapi
 
 ifdef CONFIG_HEADERS_INSTALL
 prepare: headers

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


                 reply	other threads:[~2026-12-04 23:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204232102.1380500-1-elsk@google.com \
    --to=elsk@google.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox