[PATCH] lib/Kconfig.debug: Restrict DEBUG_INFO_SPLIT for RISC-V

Nick Desaulniers ndesaulniers at google.com
Wed Aug 16 15:35:06 PDT 2023


On Wed, Aug 16, 2023 at 3:05 PM Fangrui Song <maskray at google.com> wrote:
>
> On 2023-08-16, Nathan Chancellor wrote:
> >When building for ARCH=riscv using LLVM < 14, there is an error with
> >CONFIG_DEBUG_INFO_SPLIT=y:
> >
> >  error: A dwo section may not contain relocations
> >
> >This was worked around in LLVM 15 by disallowing '-gsplit-dwarf' with
> >'-mrelax' (the default), so CONFIG_DEBUG_INFO_SPLIT is not selectable
> >with newer versions of LLVM:
> >
> >  $ clang --target=riscv64-linux-gnu -gsplit-dwarf -c -o /dev/null -x c /dev/null
> >  clang: error: -gsplit-dwarf is unsupported with RISC-V linker relaxation (-mrelax)
> >
> >GCC silently had a similar issue that was resolved with GCC 12.x.
> >Restrict CONFIG_DEBUG_INFO_SPLIT for RISC-V when using LLVM or GCC <
> >12.x to avoid these known issues.
> >
> >Link: https://github.com/ClangBuiltLinux/linux/issues/1914
> >Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090
> >Reported-by: kernel test robot <lkp at intel.com>
> >Closes: https://lore.kernel.org/all/202308090204.9yZffBWo-lkp@intel.com/
> >Signed-off-by: Nathan Chancellor <nathan at kernel.org>
> >---
> >Since this only impacts RISC-V, it seems reasonable that this would go
> >in via their tree but I have added Andrew in case he wants to take it.
> >---
> > lib/Kconfig.debug | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> >diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> >index d6798513a8c2..bd51274f4771 100644
> >--- a/lib/Kconfig.debug
> >+++ b/lib/Kconfig.debug
> >@@ -355,6 +355,11 @@ endchoice # "Compressed Debug information"
> > config DEBUG_INFO_SPLIT
> >       bool "Produce split debuginfo in .dwo files"
> >       depends on $(cc-option,-gsplit-dwarf)
> >+      # RISC-V linker relaxation + -gsplit-dwarf has issues with LLVM and GCC
> >+      # prior to 12.x:
> >+      # https://github.com/llvm/llvm-project/issues/56642
> >+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090
> >+      depends on !RISCV || GCC_VERSION >= 120000

Thanks for the patch. I was initially surprised to see no explicit
check for LLVM version.  Rereading the commit description a few times,
I think it makes sense, but I'm guessing we may need to rework this
condition again should we eventually get split debug info working for
riscv for llvm.  I am looking to enable split debug info for kernels
for Android's next release.

Fangrui, any thoughts on feasibility for `-mrelax` and `-gsplit-dwarf`
composability for llvm?

Link: https://github.com/llvm/llvm-project/issues/56642
Reviewed-by: Nick Desaulniers <ndesaulniers at google.com>

> >       help
> >         Generate debug info into separate .dwo files. This significantly
> >         reduces the build directory size for builds with DEBUG_INFO,
> >
> >---
> >base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
> >change-id: 20230816-riscv-debug_info_split-0713571a1ac2
> >
> >Best regards,
> >--
> >Nathan Chancellor <nathan at kernel.org>
> >
>
> LGTM as the author of the Clang mitigation
> (https://github.com/llvm/llvm-project/issues/56642) and several recent
> LLVM assembler side linker relaxation improvement (I continue updating
> https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation
> about the complication of linker relaxation).
>
> Reviewed-by: Fangrui Song <maskray at google.com>



-- 
Thanks,
~Nick Desaulniers



More information about the linux-riscv mailing list