* [PATCH 0/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
@ 2026-11-11 5:42 Nathan Chancellor
2026-11-11 5:42 ` [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR Nathan Chancellor
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 5:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Julian Braha, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
Hi all,
Now that we have a fairly unified location for compiler and linker
feature checks in scripts/Kconfig.toolchain, we should make it easy to
clean up the checks as they become obsolete through minimum supported
version bumps by documenting when they were first supported. I somewhat
modeled this after the documentation in compiler_attributes.h but I did
not want it to be as verbose.
In doing this archaeology, I developed a few prerequisite clean up
patches. The first cleans up CONFIG_CC_HAS_NO_PROFILE_FN_ATTR since it
is always 'y'. The second cleans up '-fno-addrsig' handling, as this is
an always supported clang option for a clang specific feature. The third
unifies the GCC specific "no allow store data races" flag.
I tried to add some commentary when the option was unsupported by a
particular implementation but I am on the fence about whether that is
actually useful or not, especially since they might go stale if the
other implementation starts supporting them. However, I included it
anyways since compiler_attributes.h can have the same problem and folks
can check before removing or adjusting the option. If people don't like
it, I am fine with dropping them and only documenting the supported
versions.
---
Nathan Chancellor (4):
scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling
scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
Makefile | 5 -----
kernel/gcov/Kconfig | 1 -
scripts/Kconfig.toolchain | 45 ++++++++++++++++++++++++++++++++++++---------
3 files changed, 36 insertions(+), 15 deletions(-)
---
base-commit: 7f705c0ad1c7cab3d8de99a3a67937bc82fc8481
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261110-kconfig-toolchain-updates-d8b351370a5f
Best regards,
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
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 ` Nathan Chancellor
2026-11-11 19:06 ` Nick Desaulniers
2026-11-11 5:42 ` [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig' Nathan Chancellor
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 5:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Julian Braha, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
__attribute__((no_profile_instrument_function)) was first supported in
GCC 7 and clang-13, which is higher than both the minimum supported
versions of both compilers. This configuration is always 'y', thus it
can be removed.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
kernel/gcov/Kconfig | 1 -
scripts/Kconfig.toolchain | 3 ---
2 files changed, 4 deletions(-)
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index 04f4ebdc3cf5..f62de2dea8a3 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -4,7 +4,6 @@ menu "GCOV-based kernel profiling"
config GCOV_KERNEL
bool "Enable gcov-based kernel profiling"
depends on DEBUG_FS
- depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR
select CONSTRUCTORS
default n
help
diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
index 2acbd40a38f1..666d44cc6ba8 100644
--- a/scripts/Kconfig.toolchain
+++ b/scripts/Kconfig.toolchain
@@ -141,9 +141,6 @@ config CC_HAS_ASSUME
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106654
default y if CC_IS_GCC && GCC_VERSION >= 130100
-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
--
2.56.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
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 5:42 ` Nathan Chancellor
2026-11-11 16:51 ` 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
3 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 5:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Julian Braha, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
'-fno-addrsig' avoids generating the LLVM specific .llvm_addrsig
section. This flag is supported by all supported versions of clang, so
convert CONFIG_CC_OPT_NO_ADDRSIG into a simple string symbol that
depends on CC_IS_CLANG to clean up a dynamic probe that is unnecessary.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
scripts/Kconfig.toolchain | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
index 666d44cc6ba8..570c5a31016c 100644
--- a/scripts/Kconfig.toolchain
+++ b/scripts/Kconfig.toolchain
@@ -164,7 +164,8 @@ config CC_OPT_ZERO_INIT_PADDING_BITS
def_string "$(cc-option-str,-fzero-init-padding-bits=all)"
config CC_OPT_NO_ADDRSIG
- def_string "$(cc-option-str,-fno-addrsig)"
+ # supported in clang, not needed for gcc
+ def_string "-fno-addrsig" if CC_IS_CLANG
config CC_OPT_DIAGNOSTICS_SHOW_CONTEXT
def_string "$(cc-option-str,-fdiagnostics-show-context=2)"
--
2.56.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/4] scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling
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 5:42 ` [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig' Nathan Chancellor
@ 2026-11-11 5:42 ` Nathan Chancellor
2026-11-11 5:42 ` [PATCH 4/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks Nathan Chancellor
3 siblings, 0 replies; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 5:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Julian Braha, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
Commit 454e00cf8ee5 ("kbuild: avoid re-running compiler and linker
probes") added two separate symbols for the "no allow store data races"
GCC flags. These flags serve the same purpose, so combine them using the
second argument of cc-option-str to handle the old value. To avoid
setting the second value of cc-option-str for clang, add a GCC
dependency to the symbol. This will eventually allow the cc-option-str
call to be eliminated when GCC 10 is the minimum version for the kernel.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Makefile | 5 -----
scripts/Kconfig.toolchain | 7 ++-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index d73f2bbd3b93..fb2490faa8d1 100644
--- a/Makefile
+++ b/Makefile
@@ -949,12 +949,7 @@ KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS),y,n)
KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
# Tell gcc to never replace conditional load with a non-conditional one
-ifdef CONFIG_CC_IS_GCC
-# gcc-10 renamed --param=allow-store-data-races=0 to
-# -fno-allow-store-data-races.
-KBUILD_CFLAGS += $(CONFIG_CC_OPT_ALLOW_STORE_DATA_RACES_PARAM)
KBUILD_CFLAGS += $(CONFIG_CC_OPT_NO_ALLOW_STORE_DATA_RACES)
-endif
ifdef CONFIG_READABLE_ASM
# Disable optimizations that make assembler listings hard to read.
diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
index 570c5a31016c..26a62b15e9ab 100644
--- a/scripts/Kconfig.toolchain
+++ b/scripts/Kconfig.toolchain
@@ -176,12 +176,9 @@ config CC_OPT_DIAGNOSTICS_SHOW_INLINING_CHAIN
config CC_OPT_STRICT_FLEX_ARRAYS
def_string "$(cc-option-str,-fstrict-flex-arrays=3)"
-# gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races
-config CC_OPT_ALLOW_STORE_DATA_RACES_PARAM
- def_string "$(cc-option-str,--param=allow-store-data-races=0)"
-
config CC_OPT_NO_ALLOW_STORE_DATA_RACES
- def_string "$(cc-option-str,-fno-allow-store-data-races)"
+ # gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races. not needed for clang
+ 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
def_bool $(cc-option,-mnop-mcount)
--
2.56.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
2026-11-11 5:42 [PATCH 0/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks Nathan Chancellor
` (2 preceding siblings ...)
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 ` Nathan Chancellor
2026-11-11 19:01 ` Julian Braha
3 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 5:42 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Julian Braha, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
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.
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
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)"
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)
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
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
0 siblings, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2026-11-11 16:51 UTC (permalink / raw)
To: Nathan Chancellor, Jordan Abrahams-Whitehead
Cc: Nicolas Schier, Julian Braha, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
On Tue, Nov 10, 2026 at 9:43 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> '-fno-addrsig' avoids generating the LLVM specific .llvm_addrsig
> section. This flag is supported by all supported versions of clang, so
> convert CONFIG_CC_OPT_NO_ADDRSIG into a simple string symbol that
> depends on CC_IS_CLANG to clean up a dynamic probe that is unnecessary.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Jordan, I know you were playing with -Wl,--icf=all recently. Looks
like the kernel does not use it; AFAIK, no one has ever tried. Even
-Wl,--icf=safe. Worth a shot to see if it boots. If we did, we'd
have to update this kconfig check (the linker flag is only supported
by LLD). Even if the result doesn't boot, it's perhaps worth doing
builds with BOTH to see what kind of savings are possible at the
limit.
> ---
> scripts/Kconfig.toolchain | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
> index 666d44cc6ba8..570c5a31016c 100644
> --- a/scripts/Kconfig.toolchain
> +++ b/scripts/Kconfig.toolchain
> @@ -164,7 +164,8 @@ config CC_OPT_ZERO_INIT_PADDING_BITS
> def_string "$(cc-option-str,-fzero-init-padding-bits=all)"
>
> config CC_OPT_NO_ADDRSIG
> - def_string "$(cc-option-str,-fno-addrsig)"
> + # supported in clang, not needed for gcc
> + def_string "-fno-addrsig" if CC_IS_CLANG
>
> config CC_OPT_DIAGNOSTICS_SHOW_CONTEXT
> def_string "$(cc-option-str,-fdiagnostics-show-context=2)"
>
> --
> 2.56.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
2026-11-11 16:51 ` Nick Desaulniers
@ 2026-11-11 18:36 ` Nathan Chancellor
2026-11-11 18:45 ` Nick Desaulniers
0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 18:36 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Jordan Abrahams-Whitehead, Nicolas Schier, Julian Braha,
Bill Wendling, Justin Stitt, Arnd Bergmann, Kees Cook,
linux-kernel, linux-kbuild, llvm
On Wed, Nov 11, 2026 at 08:51:05AM -0800, Nick Desaulniers wrote:
> Jordan, I know you were playing with -Wl,--icf=all recently. Looks
> like the kernel does not use it; AFAIK, no one has ever tried. Even
> -Wl,--icf=safe. Worth a shot to see if it boots. If we did, we'd
> have to update this kconfig check (the linker flag is only supported
> by LLD). Even if the result doesn't boot, it's perhaps worth doing
> builds with BOTH to see what kind of savings are possible at the
> limit.
FWIW, ICF came up once before through OpenMandriva defaulting it on in
their toolchain.
https://github.com/ClangBuiltLinux/linux/issues/1341
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
2026-11-11 18:36 ` Nathan Chancellor
@ 2026-11-11 18:45 ` Nick Desaulniers
0 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2026-11-11 18:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Jordan Abrahams-Whitehead, Nicolas Schier, Julian Braha,
Bill Wendling, Justin Stitt, Arnd Bergmann, Kees Cook,
linux-kernel, linux-kbuild, llvm
On Wed, Nov 11, 2026 at 10:36 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Wed, Nov 11, 2026 at 08:51:05AM -0800, Nick Desaulniers wrote:
> > Jordan, I know you were playing with -Wl,--icf=all recently. Looks
> > like the kernel does not use it; AFAIK, no one has ever tried. Even
> > -Wl,--icf=safe. Worth a shot to see if it boots. If we did, we'd
> > have to update this kconfig check (the linker flag is only supported
> > by LLD). Even if the result doesn't boot, it's perhaps worth doing
> > builds with BOTH to see what kind of savings are possible at the
> > limit.
>
> FWIW, ICF came up once before through OpenMandriva defaulting it on in
> their toolchain.
>
> https://github.com/ClangBuiltLinux/linux/issues/1341
oh, I forgot about that.
maybe worth researching at some point. Low priority, but filed
https://github.com/ClangBuiltLinux/linux/issues/2189
to track this at least.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
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
0 siblings, 0 replies; 12+ messages in thread
From: Julian Braha @ 2026-11-11 19:01 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Arnd Bergmann,
Kees Cook, linux-kernel, linux-kbuild, llvm
[-- 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 --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
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
0 siblings, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2026-11-11 19:06 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Julian Braha, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
On Tue, Nov 10, 2026 at 9:42 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> __attribute__((no_profile_instrument_function)) was first supported in
> GCC 7 and clang-13, which is higher than both the minimum supported
> versions of both compilers. This configuration is always 'y', thus it
Verified, but...
> can be removed.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> kernel/gcov/Kconfig | 1 -
> scripts/Kconfig.toolchain | 3 ---
> 2 files changed, 4 deletions(-)
>
> diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
> index 04f4ebdc3cf5..f62de2dea8a3 100644
> --- a/kernel/gcov/Kconfig
> +++ b/kernel/gcov/Kconfig
> @@ -4,7 +4,6 @@ menu "GCOV-based kernel profiling"
> config GCOV_KERNEL
> bool "Enable gcov-based kernel profiling"
> depends on DEBUG_FS
> - depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR
did you want to retain `depends on !ARCH_WANTS_NO_INSTR` (deleting the
` || CC_HAS_NO_PROFILE_FN_ATTR`)?
> select CONSTRUCTORS
> default n
> help
> diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
> index 2acbd40a38f1..666d44cc6ba8 100644
> --- a/scripts/Kconfig.toolchain
> +++ b/scripts/Kconfig.toolchain
> @@ -141,9 +141,6 @@ config CC_HAS_ASSUME
> # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106654
> default y if CC_IS_GCC && GCC_VERSION >= 130100
>
> -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
>
> --
> 2.56.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
2026-11-11 19:06 ` Nick Desaulniers
@ 2026-11-11 19:10 ` Nathan Chancellor
2026-11-11 19:29 ` Nick Desaulniers
0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2026-11-11 19:10 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Nicolas Schier, Julian Braha, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
On Wed, Nov 11, 2026 at 11:06:06AM -0800, Nick Desaulniers wrote:
> On Tue, Nov 10, 2026 at 9:42 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
> > index 04f4ebdc3cf5..f62de2dea8a3 100644
> > --- a/kernel/gcov/Kconfig
> > +++ b/kernel/gcov/Kconfig
> > @@ -4,7 +4,6 @@ menu "GCOV-based kernel profiling"
> > config GCOV_KERNEL
> > bool "Enable gcov-based kernel profiling"
> > depends on DEBUG_FS
> > - depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR
>
> did you want to retain `depends on !ARCH_WANTS_NO_INSTR` (deleting the
> ` || CC_HAS_NO_PROFILE_FN_ATTR`)?
No. If CONFIG_CC_HAS_NO_PROFILE_FN_ATTR is always 'y', this whole
'depends on' line is 'y', so it can be removed entirely. The noinstr
part of that dependency was only added because the "no profile"
attribute is only relevant for noinstr.
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
2026-11-11 19:10 ` Nathan Chancellor
@ 2026-11-11 19:29 ` Nick Desaulniers
0 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2026-11-11 19:29 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nicolas Schier, Julian Braha, Bill Wendling, Justin Stitt,
Arnd Bergmann, Kees Cook, linux-kernel, linux-kbuild, llvm
On Wed, Nov 11, 2026 at 11:10 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Wed, Nov 11, 2026 at 11:06:06AM -0800, Nick Desaulniers wrote:
> > On Tue, Nov 10, 2026 at 9:42 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > > diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
> > > index 04f4ebdc3cf5..f62de2dea8a3 100644
> > > --- a/kernel/gcov/Kconfig
> > > +++ b/kernel/gcov/Kconfig
> > > @@ -4,7 +4,6 @@ menu "GCOV-based kernel profiling"
> > > config GCOV_KERNEL
> > > bool "Enable gcov-based kernel profiling"
> > > depends on DEBUG_FS
> > > - depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR
> >
> > did you want to retain `depends on !ARCH_WANTS_NO_INSTR` (deleting the
> > ` || CC_HAS_NO_PROFILE_FN_ATTR`)?
>
> No. If CONFIG_CC_HAS_NO_PROFILE_FN_ATTR is always 'y', this whole
> 'depends on' line is 'y', so it can be removed entirely. The noinstr
> part of that dependency was only added because the "no profile"
> attribute is only relevant for noinstr.
SGTM
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-11-11 19:29 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®