public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: [PATCH 7/7] kbuild: remove cc-option-yn, update Docs
Date: Mon, 16 Aug 2021 17:21:09 -0700	[thread overview]
Message-ID: <20210817002109.2736222-8-ndesaulniers@google.com> (raw)
In-Reply-To: <20210817002109.2736222-1-ndesaulniers@google.com>

cc-option-yn can be replaced with cc-option. ie.
Checking for support:
ifeq ($(call cc-option-yn,$(FLAG)),y)
becomes:
ifneq ($(call cc-option,$(FLAG)),)

Checking for lack of support:
ifeq ($(call cc-option-yn,$(FLAG)),n)
becomes:
ifeq ($(call cc-option,$(FLAG)),)

This allows us to remove cc-option-yn. Do so and update the docs with
examples.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 Documentation/kbuild/makefiles.rst | 22 +++++++++-------------
 scripts/Makefile.compiler          |  5 -----
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index db3af0b45baf..4538c36d8df0 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -650,24 +650,20 @@ more details, with real examples.
 	-march=pentium-mmx if supported by $(CC), otherwise -march=i586.
 	The second argument to cc-option is optional, and if omitted,
 	cflags-y will be assigned no value if first option is not supported.
-	Note: cc-option uses KBUILD_CFLAGS for $(CC) options
+	Note: cc-option uses KBUILD_CFLAGS for $(CC) options.
 
-   cc-option-yn
-	cc-option-yn is used to check if gcc supports a given option
-	and return 'y' if supported, otherwise 'n'.
+	cc-option can be combined with conditionals to perform actions based on tool
+	support.
 
 	Example::
 
-		#arch/ppc/Makefile
-		biarch := $(call cc-option-yn, -m32)
-		aflags-$(biarch) += -a32
-		cflags-$(biarch) += -m32
+		ifneq ($(call cc-option,$(FLAG)),)
+		# $(FLAG) is supported
 
-	In the above example, $(biarch) is set to y if $(CC) supports the -m32
-	option. When $(biarch) equals 'y', the expanded variables $(aflags-y)
-	and $(cflags-y) will be assigned the values -a32 and -m32,
-	respectively.
-	Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options
+	Or::
+
+		ifeq ($(call cc-option,$(FLAG)),)
+		# $(FLAG) is not supported
 
     cc-disable-warning
 	cc-disable-warning checks if gcc supports a given warning and returns
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 86ecd2ac874c..c19c0b544c0f 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -51,11 +51,6 @@ __cc-option = $(call try-run,\
 cc-option = $(call __cc-option, $(CC),\
 	$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
 
-# cc-option-yn
-# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
-cc-option-yn = $(call try-run,\
-	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
-
 # cc-disable-warning
 # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
 cc-disable-warning = $(call try-run,\
-- 
2.33.0.rc1.237.g0d66db33f3-goog


  parent reply	other threads:[~2021-08-17  0:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  0:21 [PATCH 0/7] kbuild: remove cc-option-yn Nick Desaulniers
2021-08-17  0:21 ` [PATCH 1/7] MIPS: replace cc-option-yn uses with cc-option Nick Desaulniers
2021-08-17  1:59   ` Nathan Chancellor
2021-08-17  0:21 ` [PATCH 2/7] s390: " Nick Desaulniers
2021-08-17  2:03   ` Nathan Chancellor
2021-08-23 17:43   ` Heiko Carstens
2021-08-25  4:37     ` Masahiro Yamada
2021-08-17  0:21 ` [PATCH 3/7] powerpc: " Nick Desaulniers
2021-08-17  1:41   ` Nathan Chancellor
2021-08-17  2:31   ` Michael Ellerman
2021-08-19 20:04     ` Masahiro Yamada
2021-08-17  0:21 ` [PATCH 4/7] arc: " Nick Desaulniers
2021-08-17  2:05   ` Nathan Chancellor
2021-08-17 18:07     ` Nick Desaulniers
2021-08-18  1:40       ` Nathan Chancellor
2021-08-25  4:38         ` Masahiro Yamada
2021-08-17  0:21 ` [PATCH 5/7] x86: remove cc-option-yn test for -mtune= Nick Desaulniers
2021-08-17  2:08   ` Nathan Chancellor
2021-08-19 19:54   ` Masahiro Yamada
2021-08-19 22:19   ` Miguel Ojeda
2021-08-25  4:39     ` Masahiro Yamada
2021-08-17  0:21 ` [PATCH 6/7] Makefile: replace cc-option-yn uses with cc-option Nick Desaulniers
2021-08-17  2:09   ` Nathan Chancellor
2021-08-25  4:43   ` Masahiro Yamada
2021-08-25  4:49     ` Masahiro Yamada
2021-08-17  0:21 ` Nick Desaulniers [this message]
2021-08-17  2:10   ` [PATCH 7/7] kbuild: remove cc-option-yn, update Docs Nathan Chancellor

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=20210817002109.2736222-8-ndesaulniers@google.com \
    --to=ndesaulniers@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@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