[PATCH 1/2] kbuild: Move testing of '-mfentry' back to Makefile from Kconfig
From: Nathan Chancellor
Date: Tue Oct 20 2026 - 17:53:02 EST
Unlike cc-option in Kbuild, cc-option in Kconfig does not test options
with either bit ('-m32' / '-m64') or endianness ('-mbig-endian' /
'-mlittle-endian') flags because which flag to use may depend on the
result of the configuration stage. This difference changes the result of
testing for '-mfentry' support when using the kernel.org s390 cross
compiler, which is configured for 32-bit by default.
$ s390-linux-gcc -mfentry -o /dev/null -x c -c /dev/null
cc1: error: '-mfentry' is supported only for 64-bit CPUs
arch/s390/Makefile sets '-m64' in KBUILD_CPPFLAGS early, so '-mfentry'
support was properly tested before the move to Kconfig.
$ s390-linux-gcc -m64 -mfentry -o /dev/null -x c -c /dev/null
Ricardo reported another issue with moving this check from Kbuild to
Kconfig, as '-mfentry' is not supported for x86_32 without '-fno-pic',
which affects GCC builds that are configured with PIE enabled by
default. arch/x86/Makefile adds '-fno-pic' to KBUILD_CFLAGS, so this
works properly in Kbuild.
Move the '-mfentry' check back into Kbuild to avoid adding additional
complexity to the Kconfig entry.
Fixes: 454e00cf8ee5 ("kbuild: avoid re-running compiler and linker probes")
Reported-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
Closes: https://lore.kernel.org/20261020-pie-v1-1-9be09f2324b1@xxxxxxxxxxxx/
Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
---
Cc: linux-s390@xxxxxxxxxxxxxxx
---
Makefile | 3 ++-
scripts/Kconfig.toolchain | 4 ----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 8d23af898d44..f123ac983e62 100644
--- a/Makefile
+++ b/Makefile
@@ -1057,7 +1057,8 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
endif
endif
ifdef CONFIG_HAVE_FENTRY
- ifdef CONFIG_CC_HAS_MFENTRY
+ # 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
diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
index 254393d4f98a..01b49fa5d6be 100644
--- a/scripts/Kconfig.toolchain
+++ b/scripts/Kconfig.toolchain
@@ -169,10 +169,6 @@ config CC_OPT_NO_ALLOW_STORE_DATA_RACES
config CC_HAS_MNOP_MCOUNT
def_bool $(cc-option,-mnop-mcount)
-# s390-linux-gnu-gcc did not support -mfentry until gcc-9.
-config CC_HAS_MFENTRY
- def_bool $(cc-option,-mfentry)
-
config LD_OPT_FORCE_GROUP_ALLOCATION
def_string "$(ld-option-str,--force-group-allocation)"
--
2.56.0