From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/4] kbuild: actually include Makefile.clang for clang builds
Date: Mon, 17 Feb 2025 11:46:10 +0100 [thread overview]
Message-ID: <20250217104611.1836442-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250217104611.1836442-1-a.fatoum@pengutronix.de>
Makefile.clang is included depending on CONFIG_CC_IS_CLANG, but its
location in the Makefile was before the config variables are included.
Instead of moving it farther down and risk it being included too late,
let's do as Linux does and consult CC_VERSION_TEXT instead of any
config variables.
Fixes: f41c4d7c5649 ("Makefile: add LLVM/clang support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index b5a7d0b9918b..a80e1b60d534 100644
--- a/Makefile
+++ b/Makefile
@@ -563,7 +563,13 @@ ifdef building_out_of_srctree
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
endif
-ifeq ($(CONFIG_CC_IS_CLANG),y)
+# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
+# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
+# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
+# and from include/config/auto.conf.cmd to detect the compiler upgrade.
+CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
+
+ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
endif
@@ -578,7 +584,7 @@ include $(srctree)/scripts/Makefile.defconf
# KBUILD_DEFCONFIG may point out an alternative default configuration
# used for 'make defconfig'
include $(srctree)/arch/$(SRCARCH)/Makefile
-export KBUILD_DEFCONFIG
+export KBUILD_DEFCONFIG CC_VERSION_TEXT
config: outputmakefile scripts_basic FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
--
2.39.5
next prev parent reply other threads:[~2025-02-17 10:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag Ahmad Fatoum
2025-02-17 10:46 ` Ahmad Fatoum [this message]
2025-02-17 10:46 ` [PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early Ahmad Fatoum
2025-02-17 11:19 ` [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Sascha Hauer
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=20250217104611.1836442-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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