Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch: enable HAS_LTO_CLANG with KASAN and KCOV

Both KASAN and KCOV had issues with LTO_CLANG if DEBUG_INFO is enabled.
With LTO inlinable function calls are required to have debug info if they
are inlined into a function that has debug info.

Starting with LLVM 17 this will be fixed ([1],[2]) and enabling LTO with
KASAN/KCOV and DEBUG_INFO doesn't cause linker errors anymore.

Link: https://github.com/llvm/llvm-project/commit/913f7e93dac67ecff47bade862ba42f27cb68ca9
Link: https://github.com/llvm/llvm-project/commit/4a8b1249306ff11f229320abdeadf0c215a00400
Link: https://lkml.kernel.org/r/20230717-enable-kasan-lto1-v3-1-650e1efc19d1@gmail.com
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Tom Rix <trix@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Jakob Koschel and committed by
Andrew Morton
349fde59 d9efb07d

+3 -1
+3 -1
arch/Kconfig
··· 732 732 depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) 733 733 depends on ARCH_SUPPORTS_LTO_CLANG 734 734 depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT 735 - depends on !KASAN || KASAN_HW_TAGS 735 + # https://github.com/ClangBuiltLinux/linux/issues/1721 736 + depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO 737 + depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO 736 738 depends on !GCOV_KERNEL 737 739 help 738 740 The compiler and Kconfig options support building with Clang's