arch: enable HAS_LTO_CLANG with KASAN and KCOV
PATCH v2 1/1 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.
---
Changes in v2:
- Added correct To:/Cc:
- Added comment about required LLVM 17 version dependency
- Link to v1: https://lore.kernel.org/r/[email protected]
--- arch/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/Kconfig +4 -1
@@ -745,7 +745,10 @@ config HAS_LTO_CLANG depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT - depends on !KASAN || KASAN_HW_TAGS + # KASAN & KCOV were missing necessary debug information prior to LLVM 17 + # which are required with LTO. + depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO + depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO depends on !GCOV_KERNEL help The compiler and Kconfig options support building with Clang's
---
base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c
change-id: 20230717-enable-kasan-lto1-656754c76241
Best regards,
Signature · 1 line
Jakob Koschel <[email protected]>
Quoted 26 lines · Jakob Koschel
Both KASAN and KCOV had issues with
LTO_CLANGifDEBUG_INFOis 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_INFOdoesn't cause linker errors anymore.Reviewed-by Nathan Chancellor <[email protected]>Signed-off-by Jakob Koschel <[email protected]>---
Changes in v2:
- Added correct To:/Cc:
- Added comment about required LLVM 17 version dependency
- Link to v1: https://lore.kernel.org/r/[email protected]--- arch/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/Kconfig +0
-0
arch/Kconfig config HAS_LTO_CLANG · line 749
Quoted 6 lines
arch/Kconfig +2
-1@@ -745,7 +745,10 @@ config HAS_LTO_CLANG depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT - depends on !KASAN || KASAN_HW_TAGS + # KASAN & KCOV were missing necessary debug information prior to LLVM 17 + # which are required with LTO.
Hi Jakob,
Thanks for follow up with a v2. I think Nathan meant he was literally looking for a link here in the comment, like:
# https://github.com/ClangBuiltLinux/linux/issues/1721
Mind sending a v3 with that? You can replace the comment you added to arch/Kconfig in v2 outright with that link.
If folks need to know more they can follow that link or run git blame on it.
Quoted 14 lines
arch/Kconfig +2
-1+ depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO + depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO depends on !GCOV_KERNEL help The compiler and Kconfig options support building with Clang's ---base-commit:
fdf0eaf11452d72945af31804e2a1048ee1b574c
change-id: 20230717-enable-kasan-lto1-656754c76241Best regards,
--
Jakob Koschel <[email protected]>
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 38 lines · Nick Desaulniers
Quoted 26 lines · Jakob Koschel
Both KASAN and KCOV had issues with
LTO_CLANGifDEBUG_INFOis 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_INFOdoesn't cause linker errors anymore.Reviewed-by Nathan Chancellor <[email protected]>Signed-off-by Jakob Koschel <[email protected]>---
Changes in v2:
- Added correct To:/Cc:
- Added comment about required LLVM 17 version dependency
- Link to v1: https://lore.kernel.org/r/[email protected]--- arch/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/Kconfig +0
-0arch/Kconfig config HAS_LTO_CLANG · line 749
Quoted 6 lines
arch/Kconfig +2
-1@@ -745,7 +745,10 @@ config HAS_LTO_CLANG depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT - depends on !KASAN || KASAN_HW_TAGS + # KASAN & KCOV were missing necessary debug information prior to LLVM 17 + # which are required with LTO.Hi Jakob,
Thanks for follow up with a v2. I think Nathan meant he was literally looking for a link here in the comment, like:
Quoted 6 lines
# https://github.com/ClangBuiltLinux/linux/issues/1721
Mind sending a v3 with that? You can replace the comment you added to
arch/Kconfigin v2 outright with that link.If folks need to know more they can follow that link or run git blame on it.
Ha, that's on me when copying from the other email I shamelessly forgot the most important line.
Will make a v3, sorry about that.
Quoted 20 lines
Quoted 15 lines
arch/Kconfig +2
-1+ depends on (!KASAN || KASAN_HW_TAGS || CLANG_VERSION >= 170000) || !DEBUG_INFO + depends on (!KCOV || CLANG_VERSION >= 170000) || !DEBUG_INFO depends on !GCOV_KERNEL help The compiler and Kconfig options support building with Clang's ---base-commit:
fdf0eaf11452d72945af31804e2a1048ee1b574c
change-id: 20230717-enable-kasan-lto1-656754c76241Best regards,
--
Jakob Koschel <[email protected]>Signature · 2 lines
Thanks, ~Nick Desaulniers