[PATCH 0/7] kbuild: remove cc-option-yn

24 views
Skip to first unread message

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:18 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers
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.

Base is linux-next.

Nick Desaulniers (7):
MIPS: replace cc-option-yn uses with cc-option
s390: replace cc-option-yn uses with cc-option
powerpc: replace cc-option-yn uses with cc-option
arc: replace cc-option-yn uses with cc-option
x86: remove cc-option-yn test for -mtune=
Makefile: replace cc-option-yn uses with cc-option
kbuild: remove cc-option-yn, update Docs

Documentation/kbuild/makefiles.rst | 22 ++++++---------
Makefile | 2 +-
arch/arc/Makefile | 3 +-
arch/mips/Makefile | 44 +++++++++++++++---------------
arch/mips/sgi-ip22/Platform | 4 +--
arch/powerpc/Makefile | 12 ++++----
arch/powerpc/boot/Makefile | 5 +---
arch/s390/Makefile | 14 +++++-----
arch/x86/Makefile_32.cpu | 6 ----
scripts/Makefile.compiler | 5 ----
10 files changed, 49 insertions(+), 68 deletions(-)

--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:20 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Thomas Bogendoerfer, linux...@vger.kernel.org
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 pursue removing cc-option-yn.

Cc: Thomas Bogendoerfer <tsbo...@alpha.franken.de>
Cc: linux...@vger.kernel.org
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
arch/mips/Makefile | 44 ++++++++++++++++++-------------------
arch/mips/sgi-ip22/Platform | 4 ++--
2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index ea3cd080a1c7..f4b9850f17fa 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -58,9 +58,7 @@ endif

ifdef CONFIG_FUNCTION_GRAPH_TRACER
ifndef KBUILD_MCOUNT_RA_ADDRESS
- ifeq ($(call cc-option-yn,-mmcount-ra-address), y)
- cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS
- endif
+ cflags-y += $(call cc-option,-mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS)
endif
endif
cflags-y += $(call cc-option, -mno-check-zero-division)
@@ -208,31 +206,33 @@ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,)
# been fixed properly.
mips-cflags := $(cflags-y)
ifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y)
-smartmips-ase := $(call cc-option-yn,$(mips-cflags) -msmartmips)
-cflags-$(smartmips-ase) += -msmartmips -Wa,--no-warn
+cflags-y += $(call cc-option,-msmartmips -Wa$(comma)--no-warn)
endif
ifeq ($(CONFIG_CPU_MICROMIPS),y)
-micromips-ase := $(call cc-option-yn,$(mips-cflags) -mmicromips)
-cflags-$(micromips-ase) += -mmicromips
+cflags-y += $(call cc-option,-mmicromips)
endif
ifeq ($(CONFIG_CPU_HAS_MSA),y)
-toolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa)
-cflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA
+ifneq ($(call cc-option,-mhard-float -mfp64 -Wa$(comma)-mmsa),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_MSA
+endif
+endif
+ifneq ($(call cc-option,-mvirt),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_VIRT
endif
-toolchain-virt := $(call cc-option-yn,$(mips-cflags) -mvirt)
-cflags-$(toolchain-virt) += -DTOOLCHAIN_SUPPORTS_VIRT
# For -mmicromips, use -Wa,-fatal-warnings to catch unsupported -mxpa which
# only warns
-xpa-cflags-y := $(mips-cflags)
-xpa-cflags-$(micromips-ase) += -mmicromips -Wa$(comma)-fatal-warnings
-toolchain-xpa := $(call cc-option-yn,$(xpa-cflags-y) -mxpa)
-cflags-$(toolchain-xpa) += -DTOOLCHAIN_SUPPORTS_XPA
-toolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc)
-cflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC
-toolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp)
-cflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP
-toolchain-ginv := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv)
-cflags-$(toolchain-ginv) += -DTOOLCHAIN_SUPPORTS_GINV
+ifneq ($(call cc-option,-mmicromips -Wa$(comma)-fatal-warnings -mxpa),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_XPA
+endif
+ifneq ($(call cc-option,-Wa$(comma)-mcrc),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_CRC
+endif
+ifneq ($(call cc-option,-Wa$(comma)-mdsp),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_DSP
+endif
+ifneq ($(call cc-option,-Wa$(comma)-mginv),)
+cflags-y += -DTOOLCHAIN_SUPPORTS_GINV
+endif

#
# Firmware support
@@ -277,7 +277,7 @@ ifdef CONFIG_64BIT
endif
endif

- ifeq ($(KBUILD_SYM32)$(call cc-option-yn,-msym32), yy)
+ ifeq ($(KBUILD_SYM32)$(call cc-option,-msym32), y-msym32)
cflags-y += -msym32 -DKBUILD_64BIT_SYM32
else
ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y)
diff --git a/arch/mips/sgi-ip22/Platform b/arch/mips/sgi-ip22/Platform
index 62fa30bb959e..fd8f1d01c867 100644
--- a/arch/mips/sgi-ip22/Platform
+++ b/arch/mips/sgi-ip22/Platform
@@ -24,8 +24,8 @@ endif
# Simplified: what IP22 does at 128MB+ in ksegN, IP28 does at 512MB+ in xkphys
#
ifdef CONFIG_SGI_IP28
- ifeq ($(call cc-option-yn,-march=r10000 -mr10k-cache-barrier=store), n)
- $(error gcc doesn't support needed option -mr10k-cache-barrier=store)
+ ifeq ($(call cc-option,-march=r10000 -mr10k-cache-barrier=store),)
+ $(error $(CC) doesn't support needed option -mr10k-cache-barrier=store)
endif
endif
cflags-$(CONFIG_SGI_IP28) += -mr10k-cache-barrier=store -I$(srctree)/arch/mips/include/asm/mach-ip28
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:22 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Heiko Carstens, Vasily Gorbik, Christian Borntraeger, linux...@vger.kernel.org
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 pursue removing cc-option-yn.

Cc: Heiko Carstens <h...@linux.ibm.com>
Cc: Vasily Gorbik <g...@linux.ibm.com>
Cc: Christian Borntraeger <bornt...@de.ibm.com>
Cc: linux...@vger.kernel.org
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
arch/s390/Makefile | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 17dc4f1ac4fa..a3cf33ad009f 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -70,7 +70,7 @@ cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
#
cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls

-ifeq ($(call cc-option-yn,-mpacked-stack -mbackchain -msoft-float),y)
+ifneq ($(call cc-option,-mpacked-stack -mbackchain -msoft-float),)
cflags-$(CONFIG_PACK_STACK) += -mpacked-stack -D__PACK_STACK
aflags-$(CONFIG_PACK_STACK) += -D__PACK_STACK
endif
@@ -78,22 +78,22 @@ endif
KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)

-ifeq ($(call cc-option-yn,-mstack-size=8192 -mstack-guard=128),y)
+ifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
cflags-$(CONFIG_CHECK_STACK) += -mstack-size=$(STACK_SIZE)
-ifneq ($(call cc-option-yn,-mstack-size=8192),y)
+ifeq ($(call cc-option,-mstack-size=8192),)
cflags-$(CONFIG_CHECK_STACK) += -mstack-guard=$(CONFIG_STACK_GUARD)
endif
endif

ifdef CONFIG_WARN_DYNAMIC_STACK
- ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y)
+ ifneq ($(call cc-option,-mwarn-dynamicstack),)
KBUILD_CFLAGS += -mwarn-dynamicstack
KBUILD_CFLAGS_DECOMPRESSOR += -mwarn-dynamicstack
endif
endif

ifdef CONFIG_EXPOLINE
- ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y)
+ ifneq ($(call cc-option,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),)
CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
CC_FLAGS_EXPOLINE += -mfunction-return=thunk
CC_FLAGS_EXPOLINE += -mindirect-branch-table
@@ -104,10 +104,10 @@ ifdef CONFIG_EXPOLINE
endif

ifdef CONFIG_FUNCTION_TRACER
- ifeq ($(call cc-option-yn,-mfentry -mnop-mcount),n)
+ ifeq ($(call cc-option,-mfentry -mnop-mcount),)
# make use of hotpatch feature if the compiler supports it
cc_hotpatch := -mhotpatch=0,3
- ifeq ($(call cc-option-yn,$(cc_hotpatch)),y)
+ ifneq ($(call cc-option,$(cc_hotpatch)),)
CC_FLAGS_FTRACE := $(cc_hotpatch)
KBUILD_AFLAGS += -DCC_USING_HOTPATCH
KBUILD_CFLAGS += -DCC_USING_HOTPATCH
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:24 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, linuxp...@lists.ozlabs.org
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 pursue removing cc-option-yn.

Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Benjamin Herrenschmidt <be...@kernel.crashing.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: linuxp...@lists.ozlabs.org
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
arch/powerpc/Makefile | 12 ++++++------
arch/powerpc/boot/Makefile | 5 +----
2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 9aaf1abbc641..85e224536cf7 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -12,12 +12,12 @@
# Rewritten by Cort Dougan and Paul Mackerras
#

-HAS_BIARCH := $(call cc-option-yn, -m32)
+HAS_BIARCH := $(call cc-option,-m32)

# Set default 32 bits cross compilers for vdso and boot wrapper
CROSS32_COMPILE ?=

-ifeq ($(HAS_BIARCH),y)
+ifeq ($(HAS_BIARCH),-m32)
ifeq ($(CROSS32_COMPILE),)
ifdef CONFIG_PPC32
# These options will be overridden by any -mcpu option that the CPU
@@ -107,7 +107,7 @@ cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian

-ifeq ($(HAS_BIARCH),y)
+ifeq ($(HAS_BIARCH),-m32)
KBUILD_CFLAGS += -m$(BITS)
KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
@@ -125,7 +125,9 @@ LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)

ifdef CONFIG_PPC64
-ifeq ($(call cc-option-yn,-mcmodel=medium),y)
+ifeq ($(call cc-option,-mcmodel=medium),)
+ export NO_MINIMAL_TOC := -mno-minimal-toc
+else
# -mcmodel=medium breaks modules because it uses 32bit offsets from
# the TOC pointer to create pointers where possible. Pointers into the
# percpu data area are created by this method.
@@ -135,8 +137,6 @@ ifeq ($(call cc-option-yn,-mcmodel=medium),y)
# kernel percpu data space (starting with 0xc...). We need a full
# 64bit relocation for this to work, hence -mcmodel=large.
KBUILD_CFLAGS_MODULE += -mcmodel=large
-else
- export NO_MINIMAL_TOC := -mno-minimal-toc
endif
endif

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 10c0fb306f15..33e1de5d1c95 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -66,10 +66,7 @@ ifdef CONFIG_DEBUG_INFO
BOOTCFLAGS += -g
endif

-ifeq ($(call cc-option-yn, -fstack-protector),y)
-BOOTCFLAGS += -fno-stack-protector
-endif
-
+BOOTCFLAGS += $(call cc-option,-fstack-protector)
BOOTCFLAGS += -I$(objtree)/$(obj) -I$(srctree)/$(obj)

DTC_FLAGS ?= -p 1024
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:26 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Vineet Gupta, linux-s...@lists.infradead.org
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 pursue removing cc-option-yn.

Cc: Vineet Gupta <vgu...@kernel.org>
Cc: linux-s...@lists.infradead.org
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
arch/arc/Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index c0d87ac2e221..8782a03f24a8 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -18,8 +18,7 @@ ifeq ($(CONFIG_ARC_TUNE_MCPU),"")
cflags-y += $(tune-mcpu-def-y)
else
tune-mcpu := $(shell echo $(CONFIG_ARC_TUNE_MCPU))
-tune-mcpu-ok := $(call cc-option-yn, $(tune-mcpu))
-ifeq ($(tune-mcpu-ok),y)
+ifneq ($(call cc-option,$(tune-mcpu)),)
cflags-y += $(tune-mcpu)
else
# The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this compiler
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:29 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin, x...@kernel.org
As noted in the comment, -mtune= has been supported since GCC 3.4. The
minimum required version of GCC to build the kernel (as specified in
Documentation/process/changes.rst) is GCC 4.9.

tune is not immediately expanded. Instead it defines a macro that will
test via cc-option later values for -mtune=. But we can skip the test
whether to use -mtune= vs. -mcpu=.

Cc: Thomas Gleixner <tg...@linutronix.de>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: x...@kernel.org
Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
arch/x86/Makefile_32.cpu | 6 ------
1 file changed, 6 deletions(-)

diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index cd3056759880..e7355f8b51c2 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -2,13 +2,7 @@
# CPU tuning section - shared with UML.
# Must change only cflags-y (or [yn]), not CFLAGS! That makes a difference for UML.

-#-mtune exists since gcc 3.4
-HAS_MTUNE := $(call cc-option-yn, -mtune=i386)
-ifeq ($(HAS_MTUNE),y)
tune = $(call cc-option,-mtune=$(1),$(2))
-else
-tune = $(call cc-option,-mcpu=$(1),$(2))
-endif

cflags-$(CONFIG_M486SX) += -march=i486
cflags-$(CONFIG_M486) += -march=i486
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:31 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers
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 pursue removing cc-option-yn.

Signed-off-by: Nick Desaulniers <ndesau...@google.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 72f9e2b0202c..f76be5f62d79 100644
--- a/Makefile
+++ b/Makefile
@@ -967,7 +967,7 @@ ifdef CONFIG_FUNCTION_TRACER
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
CC_FLAGS_FTRACE += -mrecord-mcount
ifdef CONFIG_HAVE_NOP_MCOUNT
- ifeq ($(call cc-option-yn, -mnop-mcount),y)
+ ifneq ($(call cc-option, -mnop-mcount),)
CC_FLAGS_FTRACE += -mnop-mcount
CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
endif
--
2.33.0.rc1.237.g0d66db33f3-goog

Nick Desaulniers

unread,
Aug 16, 2021, 8:21:33 PM8/16/21
to Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers
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 <ndesau...@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

Nathan Chancellor

unread,
Aug 16, 2021, 9:41:49 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras, linuxp...@lists.ozlabs.org
This was previously disabling the stack protector but now it is enabling
it. Just remove the ifeq conditional altogether as the kernel assumes
-fno-stack-protector is always supported after commit 893ab00439a4
("kbuild: remove cc-option test of -fno-stack-protector").

Nathan Chancellor

unread,
Aug 16, 2021, 9:59:05 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Thomas Bogendoerfer, linux...@vger.kernel.org
On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
I do not think this diff and most of the ones that follow are
equivalent, as you are no longer including the previously checked flags
in the cc-option invocation, which could change the result (options that
follow may depend on a prior selected flag).

I think that as long as you add $(cflags-y) to all of the cc-option
tests, it should be fine. I guess cflags-y could be eliminated but it
looks like this variable exists so that the flags can be added to both
KBUILD_CFLAGS and KBUILD_AFLAGS at the same time so removing it would
duplicate a lot of things.
Heh :)

Nathan Chancellor

unread,
Aug 16, 2021, 10:03:04 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Heiko Carstens, Vasily Gorbik, Christian Borntraeger, linux...@vger.kernel.org


On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> 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 pursue removing cc-option-yn.
>
> Cc: Heiko Carstens <h...@linux.ibm.com>
> Cc: Vasily Gorbik <g...@linux.ibm.com>
> Cc: Christian Borntraeger <bornt...@de.ibm.com>
> Cc: linux...@vger.kernel.org
> Signed-off-by: Nick Desaulniers <ndesau...@google.com>

Reviewed-by: Nathan Chancellor <nat...@kernel.org>

Nathan Chancellor

unread,
Aug 16, 2021, 10:05:33 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Vineet Gupta, linux-s...@lists.infradead.org
On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
Any reason not to just turn this into

cflags-y += $(call cc-option,$(tune-mcpu))

?

If $(tune-mcpu) is empty or invalid, nothing will be added to cflags-y.

Nathan Chancellor

unread,
Aug 16, 2021, 10:08:14 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin, x...@kernel.org
On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> As noted in the comment, -mtune= has been supported since GCC 3.4. The
> minimum required version of GCC to build the kernel (as specified in
> Documentation/process/changes.rst) is GCC 4.9.
>
> tune is not immediately expanded. Instead it defines a macro that will
> test via cc-option later values for -mtune=. But we can skip the test
> whether to use -mtune= vs. -mcpu=.
>
> Cc: Thomas Gleixner <tg...@linutronix.de>
> Cc: Ingo Molnar <mi...@redhat.com>
> Cc: Borislav Petkov <b...@alien8.de>
> Cc: H. Peter Anvin <h...@zytor.com>
> Cc: x...@kernel.org
> Signed-off-by: Nick Desaulniers <ndesau...@google.com>

Yay for removing stale checks!

Reviewed-by: Nathan Chancellor <nat...@kernel.org>

Nathan Chancellor

unread,
Aug 16, 2021, 10:09:38 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com
On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> 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 pursue removing cc-option-yn.
>
> Signed-off-by: Nick Desaulniers <ndesau...@google.com>

Reviewed-by: Nathan Chancellor <nat...@kernel.org>

Nathan Chancellor

unread,
Aug 16, 2021, 10:10:50 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com
On 8/16/2021 5:21 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> 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 <ndesau...@google.com>

Reviewed-by: Nathan Chancellor <nat...@kernel.org>

Michael Ellerman

unread,
Aug 16, 2021, 10:31:59 PM8/16/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Nick Desaulniers, Benjamin Herrenschmidt, Paul Mackerras, linuxp...@lists.ozlabs.org
I don't love that we have to repeat "-m32" in each check.

I'm pretty sure you can use ifdef here, because HAS_BIARCH is a simple
variable (assigned with ":=").

ie, this can be:

ifdef HAS_BIARCH


And that avoids having to spell out "-m32" everywhere.

cheers

Nick Desaulniers

unread,
Aug 17, 2021, 2:07:58 PM8/17/21
to Nathan Chancellor, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Vineet Gupta, linux-s...@lists.infradead.org
Yes, you'll need to pull up the source; the diff doesn't provide
enough context. tune-mcpu is used in the body of the else branch
hinted at by the diff. PTAL

>
> If $(tune-mcpu) is empty or invalid, nothing will be added to cflags-y.
>
> > else
> > # The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this compiler
> >



--
Thanks,
~Nick Desaulniers

Nathan Chancellor

unread,
Aug 17, 2021, 9:40:12 PM8/17/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Vineet Gupta, linux-s...@lists.infradead.org
Ah, fair enough. The warning is a little unconventional but oh well :)

Reviewed-by: Nathan Chancellor <nat...@kernel.org>

Masahiro Yamada

unread,
Aug 19, 2021, 3:55:51 PM8/19/21
to Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux, Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin, X86 ML
LGTM.

Perhaps, a follow-up patch can remove the tune macro too,
replacing $(call tune,pentium2) with $(call cc-option,-mtune=pentium2)







--
Best Regards
Masahiro Yamada

Masahiro Yamada

unread,
Aug 19, 2021, 4:05:12 PM8/19/21
to Michael Ellerman, Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux, Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev
Yes.

Comments from Nathan and Michael
both sound good.

Miguel Ojeda

unread,
Aug 19, 2021, 6:20:00 PM8/19/21
to Nick Desaulniers, Masahiro Yamada, Linux Kbuild mailing list, clang-built-linux, Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)
On Tue, Aug 17, 2021 at 2:21 AM 'Nick Desaulniers' via Clang Built
Linux <clang-bu...@googlegroups.com> wrote:
>
> As noted in the comment, -mtune= has been supported since GCC 3.4. The
> minimum required version of GCC to build the kernel (as specified in
> Documentation/process/changes.rst) is GCC 4.9.

Yes, please!

Reviewed-by: Miguel Ojeda <oj...@kernel.org>

Cheers,
Miguel

Heiko Carstens

unread,
Aug 23, 2021, 1:43:34 PM8/23/21
to Nick Desaulniers, Masahiro Yamada, linux-...@vger.kernel.org, clang-bu...@googlegroups.com, Vasily Gorbik, Christian Borntraeger, linux...@vger.kernel.org
On Mon, Aug 16, 2021 at 05:21:04PM -0700, Nick Desaulniers wrote:
> 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 pursue removing cc-option-yn.
>
> Cc: Heiko Carstens <h...@linux.ibm.com>
> Cc: Vasily Gorbik <g...@linux.ibm.com>
> Cc: Christian Borntraeger <bornt...@de.ibm.com>
> Cc: linux...@vger.kernel.org
> Signed-off-by: Nick Desaulniers <ndesau...@google.com>
> ---
> arch/s390/Makefile | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)

Acked-by: Heiko Carstens <h...@linux.ibm.com>

Masahiro Yamada

unread,
Aug 25, 2021, 12:38:35 AM8/25/21
to Heiko Carstens, Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux, Vasily Gorbik, Christian Borntraeger, linux-s390
Applied to linux-kbuild.

Masahiro Yamada

unread,
Aug 25, 2021, 12:39:05 AM8/25/21
to Nathan Chancellor, Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux, Vineet Gupta, arcml

Masahiro Yamada

unread,
Aug 25, 2021, 12:41:10 AM8/25/21
to Miguel Ojeda, Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux, Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)

Masahiro Yamada

unread,
Aug 25, 2021, 12:44:49 AM8/25/21
to Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-li...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210817002109.2736222-7-ndesaulniers%40google.com.



I am fine with this change, but
is there any reason why you did not touch the following hunk?



ifdef CONFIG_HAVE_FENTRY
# s390-linux-gnu-gcc did not support -mfentry until gcc-9.
ifeq ($(call cc-option-yn, -mfentry),y)
CC_FLAGS_FTRACE += -mfentry
CC_FLAGS_USING += -DCC_USING_FENTRY
endif
endif

Masahiro Yamada

unread,
Aug 25, 2021, 12:50:35 AM8/25/21
to Nick Desaulniers, Linux Kbuild mailing list, clang-built-linux
Ah, I just recalled that this hunk was restored
after a build error was reported:

https://lore.kernel.org/lkml/CAKwvOdkckey1=VUHApTcJYufyhdRJ=jb4qYs52f5...@mail.gmail.com/



So, please send v2, changing -mfentry part in the same way.
Reply all
Reply to author
Forward
0 new messages