All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julian Braha <julianbraha@gmail.com>
To: Nathan Chancellor <nathan@kernel.org>, Nicolas Schier <nsc@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Arnd Bergmann <arnd@arndb.de>, Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH 4/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
Date: Wed, 11 Nov 2026 19:01:19 +0000	[thread overview]
Message-ID: <6d7d25fa-69ef-42b0-b7f2-bb59ebf0eb2f@gmail.com> (raw)
In-Reply-To: <20261110-kconfig-toolchain-updates-v1-4-6d4fb636290e@kernel.org>


[-- Attachment #1.1: Type: text/plain, Size: 7367 bytes --]

On 11/11/26 05:42, Nathan Chancellor wrote:
> To make it easier to clean up unnecessary dynamic checks when the
> minimum supported version of a toolchain component is updated, add
> comments documenting when features were first supported. Request that
> future additions document this as well.

Love, love, love this!

I tested the bounds and replicated nearly all of your results, but had a
few notes:

> 
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  scripts/Kconfig.toolchain | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
> index 26a62b15e9ab..3a9eb8317d59 100644
> --- a/scripts/Kconfig.toolchain
> +++ b/scripts/Kconfig.toolchain
> @@ -1,4 +1,9 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> +# When adding a new dynamic check (such as {cc,ld}-option{,-str} or testing a
> +# small program), please add a comment documenting the first version of the
> +# tool that supported the feature being tested. For cc-option{,-str}, note the
> +# "beware" comment below.
> +
>  config CC_VERSION_TEXT
>  	string
>  	default "$(CC_VERSION_TEXT)"
> @@ -118,6 +123,7 @@ config GCC_ASM_GOTO_OUTPUT_BROKEN
>  config CC_HAS_ASM_GOTO_OUTPUT
>  	def_bool y
>  	depends on !GCC_ASM_GOTO_OUTPUT_BROKEN
> +	# supported since clang-10 and gcc-11

'asm goto' failed for me with clang 10. Seems it was added with
clang 11 [1]

>  	depends on $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
>  
>  config CC_HAS_ASM_GOTO_TIED_OUTPUT
> @@ -129,6 +135,7 @@ config TOOLS_SUPPORT_RELR
>  	def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
>  
>  config CC_HAS_ASM_INLINE
> +	# supported since clang-11 and gcc-9
>  	def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
>  
>  config CC_HAS_ASSUME
> @@ -161,6 +168,8 @@ config CC_HAS_ASSUME
>  #    pitfall.
>  
>  config CC_OPT_ZERO_INIT_PADDING_BITS
> +	# supported since gcc-15. not needed for clang, as it does this by default since clang-20
> +	# https://github.com/llvm/llvm-project/
> commit/7a086e1b2dc05f54afae3591614feede727601fa
>  	def_string "$(cc-option-str,-fzero-init-padding-bits=all)"
>  
>  config CC_OPT_NO_ADDRSIG
> @@ -168,12 +177,15 @@ config CC_OPT_NO_ADDRSIG
>  	def_string "-fno-addrsig" if CC_IS_CLANG
>  
>  config CC_OPT_DIAGNOSTICS_SHOW_CONTEXT
> +	# supported since gcc-16, not supported by clang
>  	def_string "$(cc-option-str,-fdiagnostics-show-context=2)"
>  
>  config CC_OPT_DIAGNOSTICS_SHOW_INLINING_CHAIN
> +	# supported since clang-23. not needed for gcc, as it does this by default
>  	def_string "$(cc-option-str,-fdiagnostics-show-inlining-chain)"
>  
>  config CC_OPT_STRICT_FLEX_ARRAYS
> +	# supported since clang-16 and gcc-13
>  	def_string "$(cc-option-str,-fstrict-flex-arrays=3)"

Clang 15 supports '-fstrict-flex-arrays' [1] so the check seemingly
passed, but support for level 3 wasn't actually added until clang 16.

I think this needs a:
    'depends on !CC_IS_CLANG || CLANG_VERSION >= 160000'
so the option evaluates as empty string when these deps are unmet.

>  
>  config CC_OPT_NO_ALLOW_STORE_DATA_RACES
> @@ -181,51 +193,67 @@ config CC_OPT_NO_ALLOW_STORE_DATA_RACES
>  	def_string "$(cc-option-str,-fno-allow-store-data-races,--param=allow-store-data-races=0)" if CC_IS_GCC
>  
>  config CC_HAS_MNOP_MCOUNT
> +	# supported since clang-10 and gcc-9 but option is architecture specific
>  	def_bool $(cc-option,-mnop-mcount)

'-mnop-mcount' worked for me on x86 with gcc 5 [3], but it seems s390
support came later in v9 [4]

>  
>  config LD_OPT_FORCE_GROUP_ALLOCATION
> +	# supported since ld.lld 19 and GNU ld 2.29
>  	def_string "$(ld-option-str,--force-group-allocation)"
>  
>  config LD_OPT_NO_WARN_RWX_SEGMENTS
> +	# supported since GNU ld 2.39, not supported by ld.lld
>  	def_string "$(ld-option-str,--no-warn-rwx-segments)"
>  
>  config CC_OPT_WNO_ADDRESS_OF_PACKED_MEMBER
> +	# supported since clang-4 and gcc-9
>  	def_string "$(cc-option-str,-Wno-address-of-packed-member)"
>  
>  config CC_OPT_WNO_FORMAT_OVERFLOW_NON_KPRINTF
> +	# supported since clang-18, not needed for gcc
>  	def_string "$(cc-option-str,-Wno-format-overflow-non-kprintf)"
>  
>  config CC_OPT_WNO_FORMAT_TRUNCATION_NON_KPRINTF
> +	# supported since clang-18, not needed for gcc
>  	def_string "$(cc-option-str,-Wno-format-truncation-non-kprintf)"
>  
>  config CC_OPT_WNO_DEFAULT_CONST_INIT_UNSAFE
> +	# supported since clang-21, not needed for gcc
>  	def_string "$(cc-option-str,-Wno-default-const-init-unsafe)"
>  
>  config CC_OPT_WNO_DANGLING_POINTER
> +	# supported since gcc-12, not needed for clang
>  	def_string "$(cc-option-str,-Wno-dangling-pointer)"
>  
>  config CC_OPT_WVLA_LARGER_THAN
> +	# supported since gcc-7, not supported by clang
>  	def_string "$(cc-option-str,-Wvla-larger-than=1)"
>  
>  config CC_HAS_WSTRINGOP_OVERFLOW
> +	# supported since gcc-7, not supported by clang
>  	def_bool $(cc-option,-Wstringop-overflow)
>  
>  config CC_OPT_WNO_UNTERMINATED_STRING_INITIALIZATION
> +	# supported since gcc-15 and clang-21
>  	def_string "$(cc-option-str,-Wno-unterminated-string-initialization)"
>  
>  config CC_OPT_WERROR_DESIGNATED_INIT
> +	# supported since gcc-5, not supported by clang
>  	def_string "$(cc-option-str,-Werror=designated-init)"
>  
>  config CC_OPT_WENUM_CONVERSION
> +	# supported since clang-3.2 and gcc-10
>  	def_string "$(cc-option-str,-Wenum-conversion)"
>  
>  config CC_OPT_WNO_PACKED_NOT_ALIGNED
> +	# supported since gcc-8, not supported by clang
>  	def_string "$(cc-option-str,-Wno-packed-not-aligned)"
>  
>  config CC_OPT_WNO_FORMAT_OVERFLOW
> +	# supported since gcc-7 and clang-18
>  	def_string "$(cc-option-str,-Wno-format-overflow)"
>  
>  config CC_OPT_WNO_STRINGOP_TRUNCATION
> +	# supported since gcc-8, not supported by clang
>  	def_string "$(cc-option-str,-Wno-stringop-truncation)"
>  
>  config CC_HAS_COUNTED_BY
> @@ -252,14 +280,18 @@ config CC_HAS_BROKEN_COUNTED_BY_REF
>  	default y if CC_IS_CLANG && CLANG_VERSION < 220100
>  
>  config CC_HAS_ALLOC_TOKEN
> +	# supported since clang-22, not supported by gcc
>  	def_bool $(cc-option,-falloc-token-max=123)
>  
>  config CC_HAS_MULTIDIMENSIONAL_NONSTRING
> +	# supported since gcc-15 and clang-21
>  	def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror)
>  
>  config CC_OPT_INLINE_MEMSET
>  	string
> +	# supported since gcc-14
>  	default "-finline-stringops=memset" if $(cc-option,-finline-stringops=memset)
> +	# supported since clang-22
>  	default "-mllvm -max-store-memset=4294967294" if $(cc-option,-mllvm -max-store-memset=4294967294)
>  
>  config LD_CAN_USE_KEEP_IN_OVERLAY
> 
> -- 2.56.0
> 

[1]
https://releases.llvm.org/11.0.0/tools/clang/docs/LanguageExtensions.html
[2]
https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#major-new-features
[3] https://gcc.gnu.org/gcc-5/changes.html#x86
[4] https://gcc.gnu.org/gcc-9/changes.html#s390

- Julian Braha




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2026-11-11 19:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  5:42 [PATCH 0/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks Nathan Chancellor
2026-11-11  5:42 ` [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR Nathan Chancellor
2026-11-11 19:06   ` Nick Desaulniers
2026-11-11 19:10     ` Nathan Chancellor
2026-11-11 19:29       ` Nick Desaulniers
2026-11-11  5:42 ` [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig' Nathan Chancellor
2026-11-11 16:51   ` Nick Desaulniers
2026-11-11 18:36     ` Nathan Chancellor
2026-11-11 18:45       ` Nick Desaulniers
2026-11-11  5:42 ` [PATCH 3/4] scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling Nathan Chancellor
2026-11-11  5:42 ` [PATCH 4/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks Nathan Chancellor
2026-11-11 19:01   ` Julian Braha [this message]
2026-11-12  0:59     ` Nathan Chancellor
2026-11-12 17:23 ` [PATCH 0/4] " Kees Cook

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=6d7d25fa-69ef-42b0-b7f2-bb59ebf0eb2f@gmail.com \
    --to=julianbraha@gmail.com \
    --cc=arnd@arndb.de \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nsc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.