Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with split debug info on riscv for clang-14 and older #1914

Closed
nickdesaulniers opened this issue Aug 14, 2023 · 5 comments
Closed

issue with split debug info on riscv for clang-14 and older #1914

nickdesaulniers opened this issue Aug 14, 2023 · 5 comments
Assignees
Labels
[ARCH] risc-v This bug impacts ARCH=riscv [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 6.6 This bug was fixed in Linux 6.6 [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com> [WORKAROUND] Applied This bug has an applied workaround

Comments

@nickdesaulniers
Copy link
Member

via: https://lore.kernel.org/llvm/ZNSWMgFF529bGy14@yujie-X299/

it seems like there's some issue with split debug info for riscv for clang-14 and older. If we bisect llvm, we can update kconfig to avoid it being selectable by randconfig

@nickdesaulniers nickdesaulniers added [BUG] linux A bug that should be fixed in the mainline kernel. [ARCH] risc-v This bug impacts ARCH=riscv [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com> labels Aug 14, 2023
@nathanchance
Copy link
Member

If we bisect llvm

Currently working on it.

@nathanchance
Copy link
Member

My bisect landed on llvm/llvm-project@80a4e6f, which just prevents CONFIG_DEBUG_INFO_SPLIT from being selected with -mrelax, which is the default as far as I understand.

I am not really sure how to restrict CONFIG_DEBUG_INFO_SPLIT based on this though. That change came out of llvm/llvm-project#56642 and based on some of the comments in that thread, it seems like GCC silently produces broken .dwo files, so maybe we just want something like

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d6798513a8c2..52a75c51b158 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -355,6 +355,9 @@ 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 is not currently compatible with split DWARF:
+       # https://github.com/llvm/llvm-project/issues/56642
+       depends on !RISCV
        help
          Generate debug info into separate .dwo files. This significantly
          reduces the build directory size for builds with DEBUG_INFO,

? Would be nice to have a GCC bug report to go with that...

@MaskRay
Copy link
Member

MaskRay commented Aug 16, 2023

My bisect landed on llvm/llvm-project@80a4e6f, which just prevents CONFIG_DEBUG_INFO_SPLIT from being selected with -mrelax, which is the default as far as I understand.

Yes. RISC-V linker relaxation doesn't work well with some debug info features in LLVM/Clang. In addition, DWARF v5 -gdwarf-5/-fdebug-dwarf-version=5 can currently be incorrect. I changed Clang main branch and 17.x to default to v4 (llvm/llvm-project-release-prs@3c0e8be).

? Would be nice to have a GCC bug report to go with that...

I think GCC's -gsplit-dwarf has been correct since 12.0 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090).

@nathanchance
Copy link
Member

Thanks a lot for the extra info, I have sent https://lore.kernel.org/20230816-riscv-debug_info_split-v1-1-d1019d6ccc11@kernel.org/ to avoid this error.

@nathanchance nathanchance added the [PATCH] Submitted A patch has been submitted for review label Aug 16, 2023
akiyks pushed a commit to akiyks/linux that referenced this issue Aug 31, 2023
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: ClangBuiltLinux#1914
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202308090204.9yZffBWo-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20230816-riscv-debug_info_split-v1-1-d1019d6ccc11@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
lyctw pushed a commit to lyctw/linux that referenced this issue Sep 1, 2023
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: ClangBuiltLinux/linux#1914
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99090
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/all/202308090204.9yZffBWo-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20230816-riscv-debug_info_split-v1-1-d1019d6ccc11@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
@nathanchance
Copy link
Member

The workaround is in mainline: https://git.kernel.org/linus/89775a27ff6d0396b44de0d6f44dcbc25221fdda

There is an issue upstream for this problem, so I'll close this one up.

@nathanchance nathanchance added [WORKAROUND] Applied This bug has an applied workaround [FIXED][LINUX] 6.6 This bug was fixed in Linux 6.6 and removed [PATCH] Submitted A patch has been submitted for review labels Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] risc-v This bug impacts ARCH=riscv [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 6.6 This bug was fixed in Linux 6.6 [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com> [WORKAROUND] Applied This bug has an applied workaround
Projects
None yet
Development

No branches or pull requests

3 participants