Bump minimum supported version of LLVM to 11.0.0
Subsystems (9)
Nathan Chancellor
maintainercover Bump minimum supported version of LLVM to 11.0.0
This patch series raises the minimum supported version of LLVM to 11.0.0.
Patch #1 outlines the issue, goes over the potential impact of the change, and does the actual bump. Subsequent patches clean up the various checks that are always true after the bump.
I have marked this revision as RFC to give various parties the option to comment on this bump before it is done, namely KernelCI and Linaro's LKFT, who are still testing clang-10. I have added some other folks to CC that I know are testing with clang to see if this impacts them in any way (as I would like to impact as few people as possible) but as far as I am aware, most other CIs and developers are testing closer to tip of tree. If that is not true, scream so that we can see what can be done about that. If I missed anyone who is actively testing with clang, please key them in and I will make sure to include them in future revisions (if any are needed).
It probably makes sense for this series to live in -mm.
Nathan Chancellor (6):
Documentation: Raise the minimum supported version of LLVM to 11.0.0 mm, slab: Remove compiler check in __kmalloc_index arch/Kconfig: Remove CLANG_VERSION check in HAS_LTO_CLANG Revert "ARM: 9070/1: Make UNWINDER_ARM depend on ld.bfd or ld.lld
11.0.0+"
gcov: Remove compiler version check init/Kconfig: Drop linker version check for LD_ORPHAN_WARN
Documentation/process/changes.rst | 2 +- arch/Kconfig | 3 +-- arch/arm/Kconfig.debug | 2 -- include/linux/slab.h | 3 +-- init/Kconfig | 1 - kernel/gcov/Kconfig | 1 - scripts/min-tool-version.sh | 2 +- 7 files changed, 4 insertions(+), 10 deletions(-)
base-commit: d58071a8a76d779eedab38033ae4c821c30295a5
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 1/6 Documentation: Raise the minimum supported version of LLVM to 11.0.0
LLVM versions prior to 11.0.0 have a harder time with dead code elimination, which can cause issues with commonly used expressions such as BUILD_BUG_ON and the bitmask functions/macros in bitfield.h (see the first two issues links below).
Whenever there is an issue within LLVM that has been resolved in a later release, the only course of action is to gate the problematic configuration or source code on the toolchain verson or raise the minimum supported version of LLVM for building the kernel, as LLVM has a limited support lifetime compared to GCC. GCC major releases will typically see a few point releases across a two year period on average whereas LLVM major releases are only supported until the next major release and will only see one or two point releases within that timeframe. For example, GCC 8.1 was released in May 2018 and GCC 8.5 was released in May 2021, whereas LLVM 12.0.0 was released in April 2021 and its only point release, 12.0.1, was released in July 2021, giving a minimal window for fixes to be backported.
To resolve these build errors around improper dead code elimination, raise the minimum supported version of LLVM for building the kernel to 11.0.0. Doing so is a more proper solution than mucking around with core kernel macros that have always worked with GCC or disabling drivers for using these macros in a proper manner. This type of issue may continue to crop up and require patching, which creates more debt for bumping the minimum supported version in the future.
This should have a minimal impact to distributions. Using a script to pull several different Docker images and check the output of 'clang --version':
archlinux:latest: clang version 13.0.0
debian:oldoldstable-slim: clang version 3.8.1-24 (tags/RELEASE_381/final) debian:oldstable-slim: clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final) debian:stable-slim: Debian clang version 11.0.1-2 debian:testing-slim: Debian clang version 11.1.0-4 debian:unstable-slim: Debian clang version 11.1.0-4
fedora:34: clang version 12.0.1 (Fedora 12.0.1-1.fc34) fedora:latest: clang version 13.0.0 (Fedora 13.0.0-3.fc35) fedora:rawhide: clang version 13.0.0 (Fedora 13.0.0-5.fc36)
opensuse/leap:15.2: clang version 9.0.1
opensuse/leap:latest: clang version 11.0.1
opensuse/tumbleweed:latest: clang version 13.0.0
ubuntu:bionic: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final) ubuntu:latest: clang version 10.0.0-4ubuntu1 ubuntu:hirsute: Ubuntu clang version 12.0.0-3ubuntu1~21.04.2 ubuntu:rolling: Ubuntu clang version 13.0.0-2 ubuntu:devel: Ubuntu clang version 13.0.0-9
In every case, the distribution's version of clang is either older than the current minimum supported version of LLVM 10.0.1 or equal to or greater than the proposed 11.0.0 so nothing should change.
Another benefit of this change is LLVM=1 works better with arm64 and x86_64 since commit f12b034afeb3 ("scripts/Makefile.clang: default to LLVM_IAS=1") enabled the integrated assembler by default, which only works well with clang 11+ (clang-10 required it to be disabled to successfully build a kernel).
--- Documentation/process/changes.rst | 2 +- scripts/min-tool-version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/process/changes.rst +1 -1
@@ -30,7 +30,7 @@ you probably needn't concern yourself with pcmciautils. Program Minimal version Command to check the version ====================== =============== ======================================== GNU C 5.1 gcc --version -Clang/LLVM (optional) 10.0.1 clang --version +Clang/LLVM (optional) 11.0.0 clang --version GNU make 3.81 make --version binutils 2.23 ld -v flex 2.5.35 flex --version
scripts/min-tool-version.sh +1 -1
@@ -28,7 +28,7 @@ llvm) if [ "$SRCARCH" = s390 ]; then echo 13.0.0 else - echo 10.0.1 + echo 11.0.0 fi ;; *)
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 2/6 mm, slab: Remove compiler check in __kmalloc_index
In reply to Nathan ChancellorThe minimum supported version of LLVM has been raised to 11.0.0, meaning this check is always true, so it can be dropped.
--- include/linux/slab.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/slab.h +1 -2
@@ -411,8 +411,7 @@ static __always_inline unsigned int __kmalloc_index(size_t size,if (size <=16 *1024 *1024 )return 24 ;if (size <=32 *1024 *1024 )return 25 ; -if ((IS_ENABLED (CONFIG_CC_IS_GCC ) ||CONFIG_CLANG_VERSION >=110000 ) - && !IS_ENABLED (CONFIG_PROFILE_ALL_BRANCHES ) && size_is_constant) +if (!IS_ENABLED (CONFIG_PROFILE_ALL_BRANCHES ) && size_is_constant)BUILD_BUG_ON_MSG (1 ,"unexpected size in kmalloc_index()" );else BUG ();
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 3/6 arch/Kconfig: Remove CLANG_VERSION check in HAS_LTO_CLANG
In reply to Nathan ChancellorThe minimum supported version of LLVM has been raised to 11.0.0, meaning this check is always true, so it can be dropped.
--- arch/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/Kconfig +1 -2
@@ -648,8 +648,7 @@ config ARCH_SUPPORTS_LTO_CLANG_THIN config HAS_LTO_CLANG def_bool y - # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510 - depends on CC_IS_CLANG && CLANG_VERSION >= 110000 && LD_IS_LLD && AS_IS_LLVM + depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 4/6 Revert "ARM: 9070/1: Make UNWINDER_ARM depend on ld.bfd or ld.lld 11.0.0+"
In reply to Nathan ChancellorThis reverts commit 7411cfc3c91a08a884463bbc7623087ecc2efdd8.
The minimum supported version of LLVM has been raised to 11.0.0, meaning this check is always true, so it can be dropped.
--- arch/arm/Kconfig.debug | 2 -- 1 file changed, 2 deletions(-)
arch/arm/Kconfig.debug +0 -2
@@ -66,8 +66,6 @@ config UNWINDER_FRAME_POINTER config UNWINDER_ARM bool "ARM EABI stack unwinder" depends on AEABI && !FUNCTION_GRAPH_TRACER - # https://github.com/ClangBuiltLinux/linux/issues/732 - depends on !LD_IS_LLD || LLD_VERSION >= 110000 select ARM_UNWIND help This option enables stack unwinding support in the kernel
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 5/6 gcov: Remove compiler version check
In reply to Nathan ChancellorThe minimum supported version of LLVM has been raised to 11.0.0, meaning this check is always true, so it can be dropped.
--- kernel/gcov/Kconfig | 1 - 1 file changed, 1 deletion(-)
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 !CC_IS_CLANG || CLANG_VERSION >= 110000 depends on !ARCH_WANTS_NO_INSTR || CC_HAS_NO_PROFILE_FN_ATTR select CONSTRUCTORS default n
Signature · 1 line
2.34.1
Nathan Chancellor
maintainerRFC PATCH 6/6 init/Kconfig: Drop linker version check for LD_ORPHAN_WARN
In reply to Nathan ChancellorThe minimum supported version of LLVM has been raised to 11.0.0, meaning this check is always true, so it can be dropped.
--- init/Kconfig | 1 - 1 file changed, 1 deletion(-)
init/Kconfig +0 -1
@@ -1414,7 +1414,6 @@ config LD_DEAD_CODE_DATA_ELIMINATION config LD_ORPHAN_WARN def_bool y depends on ARCH_WANT_LD_ORPHAN_WARN - depends on !LD_IS_LLD || LLD_VERSION >= 110000 depends on $(ld-option,--orphan-handling=warn) config SYSCTL
Signature · 1 line
2.34.1
Quoted 2 lines · Nathan Chancellor
tree. If that is not true, scream so that we can see what can be done
The patches themselves look good to me. Let's see if somebody screams! :)
Cheers,
Miguel
Quoted 6 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
Patch #1 outlines the issue, goes over the potential impact of the change, and does the actual bump. Subsequent patches clean up the various checks that are always true after the bump.
Quoted 19 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
Patch #1 outlines the issue, goes over the potential impact of the change, and does the actual bump. Subsequent patches clean up the various checks that are always true after the bump.
I have marked this revision as RFC to give various parties the option to comment on this bump before it is done, namely KernelCI and Linaro's LKFT, who are still testing clang-10. I have added some other folks to CC that I know are testing with clang to see if this impacts them in any way (as I would like to impact as few people as possible) but as far as I am aware, most other CIs and developers are testing closer to tip of tree. If that is not true, scream so that we can see what can be done about that. If I missed anyone who is actively testing with clang, please key them in and I will make sure to include them in future revisions (if any are needed).
Quoted 1 line
It probably makes sense for this series to live in -mm.
Series looks good to me. Thanks for the patch, and cleanups!
Quoted 25 lines
Nathan Chancellor (6):
Documentation: Raise the minimum supported version of LLVM to 11.0.0 mm, slab: Remove compiler check in__kmalloc_indexarch/Kconfig: RemoveCLANG_VERSIONcheck inHAS_LTO_CLANGRevert "ARM: 9070/1: MakeUNWINDER_ARMdepend on ld.bfd or ld.lld11.0.0+"gcov: Remove compiler version check init/Kconfig: Drop linker version check for
LD_ORPHAN_WARNDocumentation/process/changes.rst | 2 +- arch/Kconfig | 3 +-- arch/arm/Kconfig.debug | 2 -- include/linux/slab.h | 3 +-- init/Kconfig | 1 - kernel/gcov/Kconfig | 1 - scripts/min-tool-version.sh | 2 +- 7 files changed, 4 insertions(+), 10 deletions(-)base-commit:
d58071a8a76d779eedab38033ae4c821c30295a5--
2.34.1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 18 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
Patch #1 outlines the issue, goes over the potential impact of the change, and does the actual bump. Subsequent patches clean up the various checks that are always true after the bump.
I have marked this revision as RFC to give various parties the option to comment on this bump before it is done, namely KernelCI and Linaro's LKFT, who are still testing clang-10. I have added some other folks to CC that I know are testing with clang to see if this impacts them in any way (as I would like to impact as few people as possible) but as far as I am aware, most other CIs and developers are testing closer to tip of tree. If that is not true, scream so that we can see what can be done about that. If I missed anyone who is actively testing with clang, please key them in and I will make sure to include them in future revisions (if any are needed).
Quoted 1 line
It probably makes sense for this series to live in -mm.
Sounds good to me. Thanks!
Signature · 1 line
Kees Cook
Quoted 20 lines · Kees Cook
Quoted 18 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
Patch #1 outlines the issue, goes over the potential impact of the change, and does the actual bump. Subsequent patches clean up the various checks that are always true after the bump.
I have marked this revision as RFC to give various parties the option to comment on this bump before it is done, namely KernelCI and Linaro's LKFT, who are still testing clang-10. I have added some other folks to CC that I know are testing with clang to see if this impacts them in any way (as I would like to impact as few people as possible) but as far as I am aware, most other CIs and developers are testing closer to tip of tree. If that is not true, scream so that we can see what can be done about that. If I missed anyone who is actively testing with clang, please key them in and I will make sure to include them in future revisions (if any are needed).
Quoted 8 lines
Quoted 1 line
It probably makes sense for this series to live in -mm.
Sounds good to me. Thanks!
Reviewed-by Kees Cook <[email protected]>--
Kees Cook
Only positive feedback so far.
All applied to linux-kbuild.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
Quoted 4 lines · Kees Cook
Quoted 2 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
[...]
Quoted 3 lines
Only positive feedback so far.
All applied to linux-kbuild.
Some of the "dynamic" checks for compiler support unfortunately aren't as easily grepable -- as far as I can tell, we can also include the below, which would save us 2 cc-option invocations for all clang builds.
And just in case:
for the rest as well.
Thanks,
-- Marco
------ >8 ------
From: Marco Elver <[email protected]>
Date: Fri, 3 Dec 2021 14:18:44 +0100
Subject: [PATCH] Revert "ubsan, kcsan: Don't combine sanitizer with kcov on
clang"
This reverts commit ea91a1d45d19469001a4955583187b0d75915759.
The minimum Clang version is now 11.0, which fixed the UBSAN/KCSAN vs. KCOV incompatibilities.
--- lib/Kconfig.kcsan | 11 ----------- lib/Kconfig.ubsan | 12 ------------ 2 files changed, 23 deletions(-)
lib/Kconfig.kcsan +0 -11
@@ -10,21 +10,10 @@ config HAVE_KCSAN_COMPILER For the list of compilers that support KCSAN, please see <file:Documentation/dev-tools/kcsan.rst>. -config KCSAN_KCOV_BROKEN - def_bool KCOV && CC_HAS_SANCOV_TRACE_PC - depends on CC_IS_CLANG - depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=thread -fsanitize-coverage=trace-pc) - help - Some versions of clang support either KCSAN and KCOV but not the - combination of the two. - See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status - in newer releases. - menuconfig KCSAN bool "KCSAN: dynamic data race detector" depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER depends on DEBUG_KERNEL && !KASAN - depends on !KCSAN_KCOV_BROKEN select STACKTRACE help The Kernel Concurrency Sanitizer (KCSAN) is a dynamic
lib/Kconfig.ubsan +0 -12
@@ -27,16 +27,6 @@ config UBSAN_TRAP the system. For some system builders this is an acceptable trade-off. -config UBSAN_KCOV_BROKEN - def_bool KCOV && CC_HAS_SANCOV_TRACE_PC - depends on CC_IS_CLANG - depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc) - help - Some versions of clang support either UBSAN or KCOV but not the - combination of the two. - See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status - in newer releases. - config CC_HAS_UBSAN_BOUNDS def_bool $(cc-option,-fsanitize=bounds)
@@ -46,7 +36,6 @@ config CC_HAS_UBSAN_ARRAY_BOUNDS config UBSAN_BOUNDS bool "Perform array index bounds checking" default UBSAN - depends on !UBSAN_KCOV_BROKEN depends on CC_HAS_UBSAN_ARRAY_BOUNDS || CC_HAS_UBSAN_BOUNDS help This option enables detection of directly indexed out of bounds
@@ -72,7 +61,6 @@ config UBSAN_ARRAY_BOUNDS config UBSAN_LOCAL_BOUNDS bool "Perform array local bounds checking" depends on UBSAN_TRAP - depends on !UBSAN_KCOV_BROKEN depends on $(cc-option,-fsanitize=local-bounds) help This option enables -fsanitize=local-bounds which traps when an
Signature · 1 line
2.34.0.384.gca35af8252-goog
Quoted 31 lines · Marco Elver
Quoted 5 lines · Masahiro Yamada
Quoted 4 lines · Kees Cook
Quoted 2 lines · Nathan Chancellor
This patch series raises the minimum supported version of LLVM to 11.0.0.
[...]
Quoted 3 lines
Only positive feedback so far.
All applied to linux-kbuild.
Some of the "dynamic" checks for compiler support unfortunately aren't as easily grepable -- as far as I can tell, we can also include the below, which would save us 2 cc-option invocations for all clang builds.
And just in case:
Acked-by Marco Elver <[email protected]>for the rest as well.
Thanks,
-- Marco------ >8 ------
From: Marco Elver <[email protected]>
Date: Fri, 3 Dec 2021 14:18:44 +0100
Subject: [PATCH] Revert "ubsan, kcsan: Don't combine sanitizer with kcov on
clang"
Quoted 7 lines
This reverts commit
ea91a1d45d19469001a4955583187b0d75915759.The minimum Clang version is now 11.0, which fixed the UBSAN/KCSAN vs. KCOV incompatibilities.
Signed-off-by Marco Elver <[email protected]>
Thanks!
Quoted 71 lines
--- lib/Kconfig.kcsan | 11 ----------- lib/Kconfig.ubsan | 12 ------------ 2 files changed, 23 deletions(-)lib/Kconfig.kcsan +0
-11@@ -10,21 +10,10 @@ config HAVE_KCSAN_COMPILER For the list of compilers that support KCSAN, please see <file:Documentation/dev-tools/kcsan.rst>. -config KCSAN_KCOV_BROKEN - def_bool KCOV && CC_HAS_SANCOV_TRACE_PC - depends on CC_IS_CLANG - depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=thread -fsanitize-coverage=trace-pc) - help - Some versions of clang support either KCSAN and KCOV but not the - combination of the two. - See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status - in newer releases. - menuconfig KCSAN bool "KCSAN: dynamic data race detector" depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER depends on DEBUG_KERNEL && !KASAN - depends on !KCSAN_KCOV_BROKEN select STACKTRACE help The Kernel Concurrency Sanitizer (KCSAN) is a dynamiclib/Kconfig.ubsan +0
-12@@ -27,16 +27,6 @@ config UBSAN_TRAP the system. For some system builders this is an acceptable trade-off. -config UBSAN_KCOV_BROKEN - def_bool KCOV && CC_HAS_SANCOV_TRACE_PC - depends on CC_IS_CLANG - depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc) - help - Some versions of clang support either UBSAN or KCOV but not the - combination of the two. - See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status - in newer releases. - config CC_HAS_UBSAN_BOUNDS def_bool $(cc-option,-fsanitize=bounds)@@ -46,7 +36,6 @@ config CC_HAS_UBSAN_ARRAY_BOUNDS config UBSAN_BOUNDS bool "Perform array index bounds checking" default UBSAN - depends on !UBSAN_KCOV_BROKEN depends on CC_HAS_UBSAN_ARRAY_BOUNDS || CC_HAS_UBSAN_BOUNDS help This option enables detection of directly indexed out of bounds@@ -72,7 +61,6 @@ config UBSAN_ARRAY_BOUNDS config UBSAN_LOCAL_BOUNDS bool "Perform array local bounds checking" depends on UBSAN_TRAP - depends on !UBSAN_KCOV_BROKEN depends on $(cc-option,-fsanitize=local-bounds) help This option enables -fsanitize=local-bounds which traps when anSignature · 1 line
2.34.0.384.gca35af8252-goog