* [PATCH v3] arch: enable HAS_LTO_CLANG with KASAN and KCOV
@ 2023-07-18 22:29 Jakob Koschel
2023-07-18 22:44 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Jakob Koschel @ 2023-07-18 22:29 UTC (permalink / raw)
To: Andrew Morton, Nathan Chancellor, Nick Desaulniers, Tom Rix
Cc: Kees Cook, linux-kernel, llvm, Jakob Koschel
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
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
---
Changes in v3:
- Fixed the comment linking to the Github issue
- Link to v2: https://lore.kernel.org/r/20230717-enable-kasan-lto1-v2-1-d47bf182f5c6@gmail.com
Changes in v2:
- Added correct To:/Cc:
- Added comment about required LLVM 17 version dependency
- Link to v1: https://lore.kernel.org/r/20230717-enable-kasan-lto1-v1-1-471e706a5c4e@gmail.com
---
arch/Kconfig | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index aff2746c8af2..847b52495656 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -745,7 +745,9 @@ 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
+ # https://github.com/ClangBuiltLinux/linux/issues/1721
+ 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,
--
Jakob Koschel <jkl820.git@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] arch: enable HAS_LTO_CLANG with KASAN and KCOV
2023-07-18 22:29 [PATCH v3] arch: enable HAS_LTO_CLANG with KASAN and KCOV Jakob Koschel
@ 2023-07-18 22:44 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2023-07-18 22:44 UTC (permalink / raw)
To: Jakob Koschel, Andrew Morton
Cc: Nathan Chancellor, Tom Rix, Kees Cook, linux-kernel, llvm
On Tue, Jul 18, 2023 at 3:29 PM Jakob Koschel <jkl820.git@gmail.com> wrote:
>
> 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
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
Thanks!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
AKPM, do you mind please picking this up for us?
> ---
> Changes in v3:
> - Fixed the comment linking to the Github issue
> - Link to v2: https://lore.kernel.org/r/20230717-enable-kasan-lto1-v2-1-d47bf182f5c6@gmail.com
>
> Changes in v2:
> - Added correct To:/Cc:
> - Added comment about required LLVM 17 version dependency
> - Link to v1: https://lore.kernel.org/r/20230717-enable-kasan-lto1-v1-1-471e706a5c4e@gmail.com
> ---
> arch/Kconfig | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index aff2746c8af2..847b52495656 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -745,7 +745,9 @@ 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
> + # https://github.com/ClangBuiltLinux/linux/issues/1721
> + 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,
> --
> Jakob Koschel <jkl820.git@gmail.com>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-18 22:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 22:29 [PATCH v3] arch: enable HAS_LTO_CLANG with KASAN and KCOV Jakob Koschel
2023-07-18 22:44 ` Nick Desaulniers
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®