public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 3/6] kbuild: implement {gcc,clang}-min-version only with built-in functions
Date: Sat, 19 Nov 2022 04:53:04 +0900	[thread overview]
Message-ID: <20221118195307.86049-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org>

Now CONFIG_{GCC,CLANG}_VERSION are always 6-digit, replace the shell
invocations with the test-ge macro.

Please note gcc-min-version must be used against a 6-digit number.
Add '0' prefix.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Documentation/kbuild/makefiles.rst          | 6 +++---
 Makefile                                    | 2 +-
 drivers/gpu/drm/amd/display/dc/dml/Makefile | 2 +-
 scripts/Makefile.compiler                   | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index 6b7368d1f516..4144f1ce1ab5 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -669,18 +669,18 @@ more details, with real examples.
 
     gcc-min-version
 	gcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than
-	or equal to the provided value and evaluates to y if so.
+	or equal to the provided value (in 6-digit form) and evaluates to y if so.
 
 	Example::
 
-		cflags-$(call gcc-min-version, 70100) := -foo
+		cflags-$(call gcc-min-version, 070100) := -foo
 
 	In this example, cflags-y will be assigned the value -foo if $(CC) is gcc and
 	$(CONFIG_GCC_VERSION) is >= 7.1.
 
     clang-min-version
 	clang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater
-	than or equal to the provided value and evaluates to y if so.
+	than or equal to the provided value (in 6-digit form) and evaluates to y if so.
 
 	Example::
 
diff --git a/Makefile b/Makefile
index 303516c035f6..03e6ae36c815 100644
--- a/Makefile
+++ b/Makefile
@@ -1050,7 +1050,7 @@ endif
 # ignored, continuing to default to PTRDIFF_MAX. So, left with no other
 # choice, we must perform a versioned check to disable this warning.
 # https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au
-KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
+KBUILD_CFLAGS-$(call gcc-min-version, 090100) += -Wno-alloc-size-larger-than
 KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
 
 # disable invalid "can't wrap" optimizations for signed / pointers
diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index ca7d24000621..8006801d1b56 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -34,7 +34,7 @@ dml_ccflags := -mhard-float -maltivec
 endif
 
 ifdef CONFIG_CC_IS_GCC
-ifneq ($(call gcc-min-version, 70100),y)
+ifneq ($(call gcc-min-version, 070100),y)
 IS_OLD_GCC = 1
 endif
 endif
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 20d353dcabfb..db6f0546b0fc 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -62,12 +62,12 @@ cc-disable-warning = $(call try-run,\
 	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 
 # gcc-min-version
-# Usage: cflags-$(call gcc-min-version, 70100) += -foo
-gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y)
+# Usage: cflags-$(call gcc-min-version, 070100) += -foo
+gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
 
 # clang-min-version
 # Usage: cflags-$(call clang-min-version, 110000) += -foo
-clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y)
+clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
 
 # ld-option
 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
-- 
2.34.1


  parent reply	other threads:[~2022-11-18 19:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 19:53 [PATCH 0/6] kbuild: strive to avoid $(shell ...) invocations Masahiro Yamada
2022-11-18 19:53 ` [PATCH 1/6] kbuild: add test-{le,ge,lt,gt} macros Masahiro Yamada
2022-11-18 21:07   ` Masahiro Yamada
2022-11-18 19:53 ` [PATCH 2/6] kbuild: make CONFIG_*_VERSION always 6-digit Masahiro Yamada
2022-11-23 15:05   ` Masahiro Yamada
2022-11-18 19:53 ` Masahiro Yamada [this message]
2022-11-18 19:53 ` [PATCH 4/6] kbuild: add read-file macro Masahiro Yamada
2022-11-18 19:53 ` [PATCH 5/6] kconfig: refactor Makefile to reduce process forks Masahiro Yamada
2022-11-18 19:53 ` [PATCH 6/6] kbuild: check Make version Masahiro Yamada

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=20221118195307.86049-4-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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