scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
Nathan Chancellor
maintainerv2 cover scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
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, mostly around removing code that is practically dead through minimum versions or adjusting options that are only supported in one compiler. See the individual patches for the details.
---
Changes in v2:
- Fix versions for a few entries (Julian)
- Add patch fixing check for asm goto with tied outputs in riscv code
- Add patch eliminating check for asm goto with tied outputs, as all
compilers that properly support asm goto with outputs will have
support for tied outputs
- Add links to tools where feature is supported/changed to make future
auditing easier
- Adjust comment format to be a little more succinct
- Reword commit messages accordingly
- Link to v1: https://patch.msgid.link/[email protected]
---
Nathan Chancellor (6):
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
riscv: checksum: Fix CC_HAS_ASM_GOTO_TIED_OUTPUT check
Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
Makefile | 5 --- arch/riscv/lib/csum.c | 4 +-- arch/x86/include/asm/uaccess.h | 82 ++++++++++++++++++++---------------------- kernel/gcov/Kconfig | 1 - scripts/Kconfig.toolchain | 80 +++++++++++++++++++++++++++++++++-------- 5 files changed, 107 insertions(+), 65 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,
Signature · 2 lines
Cheers, Nathan
Nathan Chancellor
maintainerPATCH v2 1/6 scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
__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.
--- kernel/gcov/Kconfig | 1 - scripts/Kconfig.toolchain | 3 --- 2 files changed, 4 deletions(-)
kernel/gcov/Kconfig +0 -1
@@ -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
scripts/Kconfig.toolchain +0 -3
@@ -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
Signature · 1 line
2.56.0
Re: [PATCH v2 1/6] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
Quoted 11 lines · Nathan Chancellor
__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.
Reviewed-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- kernel/gcov/Kconfig | 1 - scripts/Kconfig.toolchain | 3 --- 2 files changed, 4 deletions(-)
Thanks.
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerPATCH v2 2/6 scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
In reply to Nathan Chancellor'-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.
--- scripts/Kconfig.toolchain | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Kconfig.toolchain +2 -1
@@ -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)"
Signature · 1 line
2.56.0
Re: [PATCH v2 2/6] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig'
Quoted 11 lines · Nathan Chancellor
'-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_ADDRSIGinto a simple string symbol that depends onCC_IS_CLANGto clean up a dynamic probe that is unnecessary.Reviewed-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- scripts/Kconfig.toolchain | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerPATCH v2 3/6 scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling
In reply to Nathan ChancellorCommit 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.
--- Makefile | 5 ----- scripts/Kconfig.toolchain | 7 ++----- 2 files changed, 2 insertions(+), 10 deletions(-)
Makefile +0 -5
@@ -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.
scripts/Kconfig.toolchain +2 -5
@@ -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 + 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)
Signature · 1 line
2.56.0
Re: [PATCH v2 3/6] scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling
Quoted 8 lines · Nathan Chancellor
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.
Quoted 6 lines
Signed-off-by Nathan Chancellor <[email protected]>--- Makefile | 5 ----- scripts/Kconfig.toolchain | 7 ++----- 2 files changed, 2 insertions(+), 10 deletions(-)
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerPATCH v2 4/6 riscv: checksum: Fix CC_HAS_ASM_GOTO_TIED_OUTPUT check
In reply to Nathan ChancellorThe defined symbol is CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT, not CC_HAS_ASM_GOTO_TIED_OUTPUT.
---
Cc: Charlie Jenkins <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: [email protected]
--- arch/riscv/lib/csum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/lib/csum.c +2 -2
@@ -142,7 +142,7 @@ do_csum_with_alignment(const unsigned char *buff, int len) end = (const unsigned long *)(buff + len); csum =do_csum_common (ptr, end, data); -#ifdef CC_HAS_ASM_GOTO_TIED_OUTPUT +#ifdef CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT if (IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&IS_ENABLED (CONFIG_TOOLCHAIN_HAS_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB )) {
@@ -186,7 +186,7 @@ do_csum_with_alignment(const unsigned char *buff, int len) return csum >> 16; } -#endif /* CC_HAS_ASM_GOTO_TIED_OUTPUT */ +#endif /* CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT */ #ifndef CONFIG_32BIT csum +=ror64 (csum,32 ); csum >>=32 ;
Signature · 1 line
2.56.0
Re: [PATCH v2 4/6] riscv: checksum: Fix CC_HAS_ASM_GOTO_TIED_OUTPUT check
Quoted 5 lines · Nathan Chancellor
The defined symbol is
CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT, notCC_HAS_ASM_GOTO_TIED_OUTPUT.Fixes 4525462dd0db ("riscv: lib: Check if output in asm goto supported")Signed-off-by Nathan Chancellor <[email protected]>
Quoted 9 lines
---
Cc: Charlie Jenkins <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: [email protected]--- arch/riscv/lib/csum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks for catching!
Since 4525462dd0db (v6.7) still supported clang-11: shall we add 'Cc: stable'?
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerRe: [PATCH v2 4/6] riscv: checksum: Fix CC_HAS_ASM_GOTO_TIED_OUTPUT check
Quoted 16 lines · Nicolas Schier
Quoted 5 lines · Nathan Chancellor
The defined symbol is
CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT, notCC_HAS_ASM_GOTO_TIED_OUTPUT.Fixes 4525462dd0db ("riscv: lib: Check if output in asm goto supported")Signed-off-by Nathan Chancellor <[email protected]>Quoted 9 lines
---
Cc: Charlie Jenkins <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: [email protected]--- arch/riscv/lib/csum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Thanks for catching!
Reviewed-by Nicolas Schier <[email protected]>Since
4525462dd0db(v6.7) still supported clang-11: shall we add 'Cc: stable'?
I was a little on the fence about the 'Cc: stable'. On the one hand, it is definitely a bug and it would totally qualify for stable. On the other hand, nobody has noticed for almost three years and it is exercising a new code path. I'll leave that up to you when you apply it (or the RISC-V people can give their input as well).
Signature · 2 lines
Cheers, Nathan
Nathan Chancellor
maintainerPATCH v2 5/6 Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
In reply to Nathan ChancellorCommit 1aa0e8b144b6 ("Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug") added CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT to avoid a bug in clang's asm goto with outputs support when a tied output was used. The fix in clang was to match GCC's documented behavior.
Now that the minimum supported version of clang has long been bumped past the version where the fix landed (clang-14), any compiler that satisfies the dependencies of CONFIG_CC_HAS_ASM_GOTO_OUTPUT will support tied outputs properly. Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT in favor of just checking for CONFIG_CC_HAS_ASM_GOTO_OUTPUT directly.
---
Cc: Linus Torvalds <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Charlie Jenkins <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: [email protected]
--- arch/riscv/lib/csum.c | 4 +-- arch/x86/include/asm/uaccess.h | 82 ++++++++++++++++++++---------------------- scripts/Kconfig.toolchain | 5 --- 3 files changed, 41 insertions(+), 50 deletions(-)
arch/riscv/lib/csum.c +2 -2
@@ -142,7 +142,7 @@ do_csum_with_alignment(const unsigned char *buff, int len) end = (const unsigned long *)(buff + len); csum =do_csum_common (ptr, end, data); -#ifdef CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT if (IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&IS_ENABLED (CONFIG_TOOLCHAIN_HAS_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB )) {
@@ -186,7 +186,7 @@ do_csum_with_alignment(const unsigned char *buff, int len) return csum >> 16; } -#endif /* CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT */ +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ #ifndef CONFIG_32BIT csum +=ror64 (csum,32 ); csum >>=32 ;
arch/x86/include/asm/uaccess.h +39 -43
100 lines not on this page · raw message
scripts/Kconfig.toolchain +0 -5
@@ -120,11 +120,6 @@ config CC_HAS_ASM_GOTO_OUTPUT depends on !GCC_ASM_GOTO_OUTPUT_BROKEN 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 - depends on CC_HAS_ASM_GOTO_OUTPUT - # Detect buggy gcc and clang, fixed in gcc-11 clang-14. - def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null) - config TOOLS_SUPPORT_RELR def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
Signature · 1 line
2.56.0
Nicolas Schier
maintainerRe: [PATCH v2 5/6] Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
Quoted 13 lines · Nathan Chancellor
Commit
1aa0e8b144b6("Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug") addedCONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUTto avoid a bug in clang's asm goto with outputs support when a tied output was used. The fix in clang was to match GCC's documented behavior.Now that the minimum supported version of clang has long been bumped past the version where the fix landed (clang-14), any compiler that satisfies the dependencies of
CONFIG_CC_HAS_ASM_GOTO_OUTPUTwill support tied outputs properly. EliminateCONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUTin favor of just checking forCONFIG_CC_HAS_ASM_GOTO_OUTPUTdirectly.Signed-off-by Nathan Chancellor <[email protected]>---
[...]
scripts/Kconfig.toolchain config CC_HAS_ASM_GOTO_OUTPUT · line 126
Quoted 12 lines
scripts/Kconfig.toolchain +0
-4@@ -120,11 +120,6 @@ config CC_HAS_ASM_GOTO_OUTPUT depends on !GCC_ASM_GOTO_OUTPUT_BROKEN 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 - depends on CC_HAS_ASM_GOTO_OUTPUT - # Detect buggy gcc and clang, fixed in gcc-11 clang-14. - def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null)
The comments reads as if gcc 8 to 10 are affected. Is the comment somehow misleading, or should we still keep this until gcc-10 is the minimum gcc version?
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerRe: [PATCH v2 5/6] Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
Quoted 9 lines · Nicolas Schier
scripts/Kconfig.toolchain config CC_HAS_ASM_GOTO_OUTPUT · line 126
Quoted 4 lines · Nathan Chancellor
scripts/Kconfig.toolchain +0
-4-config CC_HAS_ASM_GOTO_TIED_OUTPUT - depends on CC_HAS_ASM_GOTO_OUTPUT - # Detect buggy gcc and clang, fixed in gcc-11 clang-14. - def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null)The comments reads as if gcc 8 to 10 are affected. Is the comment somehow misleading, or should we still keep this until gcc-10 is the minimum gcc version?
It is a little misleading. GCC 11 was the first version that supported asm goto with outputs, so this program will not compile with GCC 8 to 10 as a result:
<stdin>: In function 'foo':
<stdin>:1:51: error: expected ':' before string constant
The bug that it is trying to trigger was fixed during the GCC 11 development cycle between the initial asm goto with outputs commit and the final release. As a result, for GCC, if it supports asm goto with outputs, it supports tied outputs in the expected manner.
This test was mostly to catch buggy versions of clang, as asm goto with outputs was first shipped in clang-11 but using tied outputs breaks the build until they were fixed to be compatible with GCC in clang-14:
<stdin>:1:29: error: invalid operand in inline asm: '.long (${1:l}) - .'
int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }
^
<stdin>:1:29: error: unknown token in expression in '.long' directive
<inline asm>:1:9: note: instantiated into assembly here
.long () - .
^2 errors generated.
So if the compiler results in CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y, we know that CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y will be present as well.
Signature · 2 lines
Cheers, Nathan
Re: [PATCH v2 5/6] Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
Quoted 34 lines · Nathan Chancellor
Quoted 9 lines · Nicolas Schier
scripts/Kconfig.toolchain config CC_HAS_ASM_GOTO_OUTPUT · line 126
Quoted 4 lines · Nathan Chancellor
scripts/Kconfig.toolchain +0
-4-config CC_HAS_ASM_GOTO_TIED_OUTPUT - depends on CC_HAS_ASM_GOTO_OUTPUT - # Detect buggy gcc and clang, fixed in gcc-11 clang-14. - def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null)The comments reads as if gcc 8 to 10 are affected. Is the comment somehow misleading, or should we still keep this until gcc-10 is the minimum gcc version?
It is a little misleading. GCC 11 was the first version that supported asm goto with outputs, so this program will not compile with GCC 8 to 10 as a result:
<stdin>: In function 'foo':
<stdin>:1:51: error: expected ':' before string constantThe bug that it is trying to trigger was fixed during the GCC 11 development cycle between the initial asm goto with outputs commit and the final release. As a result, for GCC, if it supports asm goto with outputs, it supports tied outputs in the expected manner.
This test was mostly to catch buggy versions of clang, as asm goto with outputs was first shipped in clang-11 but using tied outputs breaks the build until they were fixed to be compatible with GCC in clang-14:
<stdin>:1:29: error: invalid operand in inline asm: '.long (${1:l}) - .'
intfoo(int *x){ asm goto (".long (%l[bar]) - .": "+m"(*x) ::: bar); return *x; bar: return 0; }^ <stdin>:1:29: error: unknown token in expression in '.long' directive <inline asm>:1:9: note: instantiated into assembly here .long () - . ^
Quoted 4 lines
2 errors generated.
So if the compiler results in
CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y, we know thatCONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=ywill be present as well.
ah ok, thanks for clarification!
Signature · 1 line
Nicolas
Nathan Chancellor
maintainerPATCH v2 6/6 scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks
In reply to Nathan ChancellorTo 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.
--- scripts/Kconfig.toolchain | 64 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
scripts/Kconfig.toolchain +63 -1
@@ -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, ideally with a link to the tool +# change as well. For cc-option{,-str}, note the "beware" comment below. + config CC_VERSION_TEXT string default "$(CC_VERSION_TEXT)"
@@ -118,12 +123,16 @@ config GCC_ASM_GOTO_OUTPUT_BROKEN config CC_HAS_ASM_GOTO_OUTPUT def_bool y depends on !GCC_ASM_GOTO_OUTPUT_BROKEN + # gcc-11: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=e3b3b59683c1e7d31a9d313dd97394abebf644be + # clang-11: https://github.com/llvm/llvm-project/commit/50cac248773c3a023e8f6ceb9938bdd5e9f15da2 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 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 + # gcc-9: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5b76e75f760f3e4787851366359d5d50f989877c + # clang-11: https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null) config CC_HAS_ASSUME
@@ -156,6 +165,8 @@ config CC_HAS_ASSUME # pitfall. config CC_OPT_ZERO_INIT_PADDING_BITS + # gcc-15: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0547dbb725b6d8e878a79e28a2e171eafcfbc1aa + # clang-20 does this by default without a flag: https://github.com/llvm/llvm-project/commit/7a086e1b2dc05f54afae3591614feede727601fa def_string "$(cc-option-str,-fzero-init-padding-bits=all)" config CC_OPT_NO_ADDRSIG
@@ -163,64 +174,109 @@ config CC_OPT_NO_ADDRSIG def_string "-fno-addrsig" if CC_IS_CLANG config CC_OPT_DIAGNOSTICS_SHOW_CONTEXT + # gcc-16: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6faa3cfe60ff9769d1bebfffdd2c7325217d7389 + # clang: not supported def_string "$(cc-option-str,-fdiagnostics-show-context=2)" config CC_OPT_DIAGNOSTICS_SHOW_INLINING_CHAIN + # clang-23: https://github.com/llvm/llvm-project/commit/f9ad232421e37e4168f6937abdd0a1665a590f12 + # gcc: not needed, it does this by default def_string "$(cc-option-str,-fdiagnostics-show-inlining-chain)" config CC_OPT_STRICT_FLEX_ARRAYS + # gcc-13: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1879e48f3d8595bc9e7f583bbd12df3c6f5c42dc + # clang-16: https://github.com/llvm/llvm-project/commit/7f93ae808634e33e4dc9bce753c909aa5f9a6eb4 def_string "$(cc-option-str,-fstrict-flex-arrays=3)" config CC_OPT_NO_ALLOW_STORE_DATA_RACES - # gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races + # gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races: + # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=e622a32db78300821fc1327637ec6413febc2c66 + # clang: not needed 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 + # s390 support + # gcc-9: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=79c2f6d7de59d5580d224b491d5600d20e3101fe + # clang-10: https://github.com/llvm/llvm-project/commit/93767143147b7d765c6ce8123a4226d449228649 + # x86 support + # gcc-5: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ecc81e33123d7ac9c11742161e128858d844b99d + # clang-24: https://github.com/llvm/llvm-project/commit/f514b16972f785fdd3fad1d19195aad5c9324fb5 def_bool $(cc-option,-mnop-mcount) config LD_OPT_FORCE_GROUP_ALLOCATION + # GNU ld 2.29: https://sourceware.org/git/gitweb.cgi?h=7bdf4127c38081c7764c0bf1db55d0b2e56391dc&p=binutils-gdb.git + # ld.lld 19: https://github.com/llvm/llvm-project/commit/4d9020ca0b125a936d5e26b48f07fcfa4bd78004 def_string "$(ld-option-str,--force-group-allocation)" config LD_OPT_NO_WARN_RWX_SEGMENTS + # GNU ld 2.39: https://sourceware.org/git/gitweb.cgi?h=ba951afb99912da01a6e8434126b8fac7aa75107&p=binutils-gdb.git + # ld.lld: not supported def_string "$(ld-option-str,--no-warn-rwx-segments)" config CC_OPT_WNO_ADDRESS_OF_PACKED_MEMBER + # gcc-9: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=da77eace90fd99b38cd89ce281033d86ebfda434 + # clang-4: https://github.com/llvm/llvm-project/commit/585ea9ddce50f3c3d3fd6dae0f9f148c074bcc2b def_string "$(cc-option-str,-Wno-address-of-packed-member)" config CC_OPT_WNO_FORMAT_OVERFLOW_NON_KPRINTF + # clang-18: https://github.com/llvm/llvm-project/commit/56c3b8e997d065b568964f71715ecbbd28c2e4a4 + # gcc: not needed, it has this behavior by default def_string "$(cc-option-str,-Wno-format-overflow-non-kprintf)" config CC_OPT_WNO_FORMAT_TRUNCATION_NON_KPRINTF + # clang-18: https://github.com/llvm/llvm-project/commit/56c3b8e997d065b568964f71715ecbbd28c2e4a4 + # gcc: not needed, it has this behavior by default def_string "$(cc-option-str,-Wno-format-truncation-non-kprintf)" config CC_OPT_WNO_DEFAULT_CONST_INIT_UNSAFE + # clang-21: https://github.com/llvm/llvm-project/commit/00f9ef282c7482754a0fea497417604d1deca9fa + # gcc: not supported def_string "$(cc-option-str,-Wno-default-const-init-unsafe)" config CC_OPT_WNO_DANGLING_POINTER + # gcc-12: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=9d6a0f388eb048f8d87f47af78f07b5ce513bfe6 + # clang: not supported def_string "$(cc-option-str,-Wno-dangling-pointer)" config CC_OPT_WVLA_LARGER_THAN + # gcc-7 for -Wvla-larger-than=: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=adc577c558a4b2e3b604511927cce17039d57c11 + # gcc-9 for -Wvla-larger-than=0: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=00abf86c47606f8220d6508654ef52ef11d76e3d + # clang: not supported def_string "$(cc-option-str,-Wvla-larger-than=1)" config CC_HAS_WSTRINGOP_OVERFLOW + # gcc-7: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ee92e7bafb52d267f52e4c48edada5f279bcf591 + # clang: not supported def_bool $(cc-option,-Wstringop-overflow) config CC_OPT_WNO_UNTERMINATED_STRING_INITIALIZATION + # gcc-15: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=44c9403ed1833ae71a59e84f9e37af3182be0df5 + # clang-21: https://github.com/llvm/llvm-project/commit/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e def_string "$(cc-option-str,-Wno-unterminated-string-initialization)" config CC_OPT_WERROR_DESIGNATED_INIT + # gcc-5: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=976d5a222fc23279e239ad926472c7810869e494 + # clang: not supported def_string "$(cc-option-str,-Werror=designated-init)" config CC_OPT_WENUM_CONVERSION + # gcc-10: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=68e2c1996ec6bde27363ce0db15233ac8cae1c4d + # clang-3.2: https://github.com/llvm/llvm-project/commit/68e2c7bee3ab337cc3134ff99fdd1ce2ddb33c2f def_string "$(cc-option-str,-Wenum-conversion)" config CC_OPT_WNO_PACKED_NOT_ALIGNED + # gcc-8: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=00aa1fa221744dc57f6c6cea8baa669b732d1101 + # clang: not supported def_string "$(cc-option-str,-Wno-packed-not-aligned)" config CC_OPT_WNO_FORMAT_OVERFLOW + # gcc-7: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bce6f76013fd5f2e88a235231231c7879597220c + # clang-18: https://github.com/llvm/llvm-project/commit/56c3b8e997d065b568964f71715ecbbd28c2e4a4 def_string "$(cc-option-str,-Wno-format-overflow)" config CC_OPT_WNO_STRINGOP_TRUNCATION + # gcc-8: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=025d57f037ad13eb479818b677ef4be4d97b639c + # clang: not supported def_string "$(cc-option-str,-Wno-stringop-truncation)" config CC_HAS_COUNTED_BY
@@ -247,14 +303,20 @@ config CC_HAS_BROKEN_COUNTED_BY_REF default y if CC_IS_CLANG && CLANG_VERSION < 220100 config CC_HAS_ALLOC_TOKEN + # clang-22: https://github.com/llvm/llvm-project/commit/774ffe5cce7392e6b4e29c83e725337727c2c994 + # gcc: not supported def_bool $(cc-option,-falloc-token-max=123) config CC_HAS_MULTIDIMENSIONAL_NONSTRING + # gcc-15: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ab714e60870d1bb98039652b760918b5e680ac10 + # clang-21: https://github.com/llvm/llvm-project/commit/3d4f979e271d2a1fe0906f4d1b16db108838f98f 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 + # gcc-14: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1ff6d9f7428b0668cd8ab0b3e3ab94f1d733124d default "-finline-stringops=memset" if $(cc-option,-finline-stringops=memset) + # clang-22: https://github.com/llvm/llvm-project/commit/b28eeb28bea39148738dc375e8a97072a1907e64 default "-mllvm -max-store-memset=4294967294" if $(cc-option,-mllvm -max-store-memset=4294967294) config LD_CAN_USE_KEEP_IN_OVERLAY
Signature · 1 line
2.56.0
Quoted 10 lines · Nathan Chancellor
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 <[email protected]>--- scripts/Kconfig.toolchain | 64 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
Great, I really appreciate that. Thanks a million!
Signature · 1 line
Nicolas
Nicolas Schier
maintainerQuoted 8 lines · Nathan Chancellor
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 incompiler_attributes.hbut I did not want it to be as verbose.[...]
Applied to kbuild/linux.git (kbuild-next-unstable) and applied Kees' R-b trailer to 1-3+6, thanks!
[1/6] scripts/Kconfig.toolchain: Remove CONFIG_CC_HAS_NO_PROFILE_FN_ATTR
https://git.kernel.org/kbuild/c/aac435fa2bae [2/6] scripts/Kconfig.toolchain: Do not dynamically probe '-fno-addrsig' https://git.kernel.org/kbuild/c/836ac9c65e4d [3/6] scripts/Kconfig.toolchain: Clean up '-fno-allow-store-data-races' handling https://git.kernel.org/kbuild/c/e2c2434465c8 [4/6] riscv: checksum: Fix CC_HAS_ASM_GOTO_TIED_OUTPUT check https://git.kernel.org/kbuild/c/f67671cfeafb [5/6] Eliminate CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT https://git.kernel.org/kbuild/c/fe2493fd4bd9 [6/6] scripts/Kconfig.toolchain: Document minimum supported versions for dynamic checks https://git.kernel.org/kbuild/c/c71019d89ed4
Please look out for regression or issue reports or other follow up comments, as they may result in the patch/series getting dropped, reverted or modified (e.g. trailers).
Patches applied to the kbuild-next-unstable branch are accepted pending wider testing in linux-next and any post-commit review; they will generally be moved to the kbuild-next branch in about a week if no issues are found.
Best regards,
Signature · 1 line
Nicolas