First round of Kbuild fixes for 7.4

- Move probing of '-mfentry' back into Makefile instead of Kconfig
   because it does not interact well with toolchains that support
   multiple bit widths
 
 - Add a big comment in scripts/Kconfig.toolchain of two pitfalls when
   moving cc-option checks from Kbuild to Kconfig
 
 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQR74yXHMTGczQHYypIdayaRccAalgUCauTsewAKCRAdayaRccAa
 lrzpAQCnAE03CslR2OH73sJezTz6DL+uSCxlwsxs7pwohD1NiwD/bEhV23ItB8zE
 c5VyQdrGgVt8zbswTm5WuO8uuBS75gE=
 =WRiy
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild fixes from Nathan Chancellor:

 - Move probing of '-mfentry' back into Makefile instead of Kconfig
   because it does not interact well with toolchains that support
   multiple bit widths

 - Add a big comment in scripts/Kconfig.toolchain of two pitfalls when
   moving cc-option checks from Kbuild to Kconfig

* tag 'kbuild-fixes-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux:
  scripts/Kconfig.toolchain: Highlight cc-option differences between Kconfig and Kbuild
  kbuild: Move testing of '-mfentry' back to Makefile from Kconfig
This commit is contained in:
Linus Torvalds 2026-10-30 14:11:27 -10:00
commit e823910506
2 changed files with 21 additions and 5 deletions

View File

@ -1059,7 +1059,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

View File

@ -144,6 +144,25 @@ config CC_HAS_ASSUME
config CC_HAS_NO_PROFILE_FN_ATTR
def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
# Beware of two problems when using cc-option in Kconfig compared to Kbuild
#
# 1. cc-option in Kbuild tests the provided flags with all previously added
# CFLAGS, whereas cc-option in Kconfig only tests the provided flags with a
# small, constant set of additional flags. If a flag (e.g., '-mfoo')
# depends on another (e.g, '-fbar') to function properly, the dependency
# must be included in the cc-option call (e.g, '-fbar -mfoo').
#
# 2. Bit and endianness flags ('-m32', '-m64', '-mbig-endian', and
# '-mlittle-endian') are not present in Kconfig cc-option checks because
# they may be included in KBUILD_CFLAGS / KBUILD_CPPFLAGS based on the
# finalized configuration result. This can result in inconsistent results
# when probing toolchains that support either option, as the toolchain's
# configured default tested in Kconfig may not support the tested flag but
# the post-configuration result in Kbuild would.
#
# In general, prefer adding truly generic compiler flags to avoid this
# pitfall.
config CC_OPT_ZERO_INIT_PADDING_BITS
def_string "$(cc-option-str,-fzero-init-padding-bits=all)"
@ -169,10 +188,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)"