Thread (7 messages) 7 messages, 4 authors, 2021-02-24

Re: [PATCH] Makefile: reuse CC_VERSION_TEXT

From: Nick Desaulniers <hidden>
Date: 2021-02-23 20:12:15
Also in: lkml

On Fri, Feb 5, 2021 at 5:49 PM Masahiro Yamada [off-list ref] wrote:
On Sat, Feb 6, 2021 at 7:01 AM 'Nick Desaulniers' via Clang Built
Linux [off-list ref] wrote:
quoted
I noticed we're invoking $(CC) via $(shell) more than once to check the
version.  Let's reuse the first string captured in $CC_VERSION_TEXT.

Fixes: 315bab4e972d ("kbuild: fix endless syncconfig in case arch Makefile sets CROSS_COMPILE")

I did not touch this hunk because I have a plan
for different refactoring, but I have never got
around to do it.

Anyway, you beat me, and I will pick this up.
But, the Fixes tag is questionable because
this is code refactoring.
Hi Masahiro,
A friendly reminder to please pick this up; I don't see it yet in
linux-next. I'm ok with you dropping the fixes tag when applied.

(Otherwise, I was about to use `grep -m1` instead of `| head -n1 | grep` here.)


quoted
Signed-off-by: Nick Desaulniers <redacted>
---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index a85535eb6a7d..70034d7c1051 100644
--- a/Makefile
+++ b/Makefile
@@ -557,7 +557,13 @@ ifdef building_out_of_srctree
        { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
 endif

-ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
+# 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 = $(shell $(CC) --version 2>/dev/null | head -n 1)
+
+ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
 ifneq ($(CROSS_COMPILE),)
 CLANG_FLAGS    += --target=$(notdir $(CROSS_COMPILE:%-=%))
 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
@@ -576,12 +582,6 @@ KBUILD_AFLAGS      += $(CLANG_FLAGS)
 export CLANG_FLAGS
 endif

-# 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 = $(shell $(CC) --version 2>/dev/null | head -n 1)
-
 ifdef config-build
 # ===========================================================================
 # *config targets only - make sure prerequisites are updated, and descend
--

-- 
Thanks,
~Nick Desaulniers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help