lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
Subsystems (3)
Nathan Chancellor
maintainerPATCH v2 1/1 lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supported
Dumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair
.uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset
.uleb128 .Ltmp1-.Lfunc_begin0 # ending offset
.byte 1 # Loc expr size
.byte 90 # DW_OP_reg10
.byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair
.uleb128 .Ltmp6-.Lfunc_begin0 # starting offset
.uleb128 .Ltmp27-.Lfunc_begin0 # ending offset
.byte 4 # DW_RLE_offset_pair
.uleb128 .Ltmp28-.Lfunc_begin0 # starting offset
.uleb128 .Ltmp30-.Lfunc_begin0 # ending offset
.byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in Kconfig with as-instr plus the small test program from the dwz test suite from the binutils issue.
---
v2:
- Rebase on commit bb1435f3f575 ("Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- Limit CONFIG_AS_HAS_NON_CONST_LEB128 dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply the CONFIG_AS_HAS_NON_CONST_LEB128 dependency to CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT as well, due to the aforementioned kbuild change.
- Move comment block to above CONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.
v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/Kconfig.debug +7 -2
@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL
@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.
@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for some
base-commit: bb1435f3f575b5213eaf27434efa3971f51c01de
Signature · 1 line
2.38.0
Quoted 31 lines · Nathan Chancellor
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedDumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset .byte 1 # Loc expr size .byte 90 # DW_OP_reg10 .byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset .byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset .byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
Quoted 8 lines
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in
Kconfigwith as-instr plus the small test program from the dwz test suite from the binutils issue.
Thanks for keeping these LLVM_IAS=0 builds alive a little longer. My hope is the GNU binutils can relax their requirement for debug info sections to improve support for DWARF v5.
Quoted 57 lines
---
v2:
- Rebase on commitbb1435f3f575("Kconfig.debug: add toolchain checks forDEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- LimitCONFIG_AS_HAS_NON_CONST_LEB128dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply theCONFIG_AS_HAS_NON_CONST_LEB128dependency toCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULTas well, due to the aforementioned kbuild change.
- Move comment block to aboveCONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/Kconfig.debug +7
-2@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for some
Quoted 4 lines
base-commit:
bb1435f3f575b5213eaf27434efa3971f51c01de--
2.38.0
--
Thanks,
~Nick Desaulniers
Quoted 42 lines · Nick Desaulniers
Quoted 31 lines · Nathan Chancellor
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedDumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset .byte 1 # Loc expr size .byte 90 # DW_OP_reg10 .byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset .byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset .byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
Quoted 8 lines
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in
Kconfigwith as-instr plus the small test program from the dwz test suite from the binutils issue.
Quoted 5 lines
Thanks for keeping these LLVM_IAS=0 builds alive a little longer. My hope is the GNU binutils can relax their requirement for debug info sections to improve support for DWARF v5.
Reviewed-by Nick Desaulniers <[email protected]>
Applied to linux-kbuild.
Thanks.
Quoted 57 lines
Quoted 57 lines
---
v2:
- Rebase on commitbb1435f3f575("Kconfig.debug: add toolchain checks forDEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- LimitCONFIG_AS_HAS_NON_CONST_LEB128dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply theCONFIG_AS_HAS_NON_CONST_LEB128dependency toCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULTas well, due to the aforementioned kbuild change.
- Move comment block to aboveCONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/Kconfig.debug +7
-2@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for some
Quoted 9 lines
Quoted 4 lines
base-commit:
bb1435f3f575b5213eaf27434efa3971f51c01de--
2.38.0--
Thanks,
~Nick Desaulniers
--
Best Regards
Masahiro Yamada
Sedat Dilek
Tested-by Conor DooleyQuoted 49 lines · Masahiro Yamada
Quoted 46 lines · Nick Desaulniers
Quoted 31 lines · Nathan Chancellor
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedDumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset .byte 1 # Loc expr size .byte 90 # DW_OP_reg10 .byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset .byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset .byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
Quoted 8 lines
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in
Kconfigwith as-instr plus the small test program from the dwz test suite from the binutils issue.Thanks for keeping these LLVM_IAS=0 builds alive a little longer. My hope is the GNU binutils can relax their requirement for debug info sections to improve support for DWARF v5.
Quoted 6 lines
Quoted 1 line
Reviewed-by Nick Desaulniers <[email protected]>Applied to linux-kbuild.
Thanks.
[1] says:
"This looks good to me! Feel free to submit with a:
-sed@-
[1] https://github.com/ClangBuiltLinux/linux/issues/1719#issuecomment-1261158627
Quoted 74 lines
Quoted 59 lines
Quoted 59 lines
---
v2:
- Rebase on commitbb1435f3f575("Kconfig.debug: add toolchain checks forDEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- LimitCONFIG_AS_HAS_NON_CONST_LEB128dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply theCONFIG_AS_HAS_NON_CONST_LEB128dependency toCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULTas well, due to the aforementioned kbuild change.
- Move comment block to aboveCONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/Kconfig.debug +7
-2@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for someQuoted 9 lines
Quoted 4 lines
base-commit:
bb1435f3f575b5213eaf27434efa3971f51c01de--
2.38.0--
Thanks,
~Nick Desaulniers--
Best Regards
Masahiro Yamada
Quoted 53 lines · Sedat Dilek
Quoted 52 lines · Masahiro Yamada
Quoted 47 lines · Nick Desaulniers
Quoted 31 lines · Nathan Chancellor
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedDumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset .byte 1 # Loc expr size .byte 90 # DW_OP_reg10 .byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset .byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset .byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
Quoted 8 lines
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in
Kconfigwith as-instr plus the small test program from the dwz test suite from the binutils issue.Thanks for keeping these LLVM_IAS=0 builds alive a little longer. My hope is the GNU binutils can relax their requirement for debug info sections to improve support for DWARF v5.
Reviewed-by Nick Desaulniers <[email protected]>
Quoted 8 lines
Quoted 3 lines
Applied to linux-kbuild.
Thanks.[1] says:
"This looks good to me! Feel free to submit with a:
Tested-by Conor Dooley <[email protected]>"
Hey Sedat,
I actually didn't take a proper look at the v2 at all... I didn't realise that Nathan dropped by T-b for v2 since he'd changed the patch enough to feel that he should.
I'm not too worried about the removed T-b (espcially since Linus has just merged Masahiro's PR containing this change).
Thanks though!
Conor.
Quoted 79 lines
-sed@-
[1] https://github.com/ClangBuiltLinux/linux/issues/1719#issuecomment-1261158627
Quoted 74 lines
Quoted 59 lines
Quoted 59 lines
---
v2:
- Rebase on commitbb1435f3f575("Kconfig.debug: add toolchain checks forDEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- LimitCONFIG_AS_HAS_NON_CONST_LEB128dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply theCONFIG_AS_HAS_NON_CONST_LEB128dependency toCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULTas well, due to the aforementioned kbuild change.
- Move comment block to aboveCONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/Kconfig.debug +7
-2@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for someQuoted 9 lines
Quoted 4 lines
base-commit:
bb1435f3f575b5213eaf27434efa3971f51c01de--
2.38.0--
Thanks,
~Nick Desaulniers--
Best Regards
Masahiro Yamada
Quoted 70 lines · Conor Dooley
Quoted 53 lines · Sedat Dilek
Quoted 52 lines · Masahiro Yamada
Quoted 47 lines · Nick Desaulniers
Quoted 31 lines · Nathan Chancellor
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedDumping the .s file reveals these .uleb128 directives come from .debug_loc and .debug_ranges:
.Ldebug_loc0:
.byte 4 # DW_LLE_offset_pair .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset .byte 1 # Loc expr size .byte 90 # DW_OP_reg10 .byte 0 # DW_LLE_end_of_list.Ldebug_ranges0:
.byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset .byte 4 # DW_RLE_offset_pair .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset .byte 0 # DW_RLE_end_of_listThere is an outstanding binutils issue to support a non-constant operand to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to be any movement on it, due to concerns over how it would work with linker relaxation.
Quoted 8 lines
To avoid these build errors, prevent DWARF5 from being selected when using clang and an assembler that does not have support for these symbol deltas, which can be easily checked in
Kconfigwith as-instr plus the small test program from the dwz test suite from the binutils issue.Thanks for keeping these LLVM_IAS=0 builds alive a little longer. My hope is the GNU binutils can relax their requirement for debug info sections to improve support for DWARF v5.
Reviewed-by Nick Desaulniers <[email protected]>Quoted 8 lines
Quoted 3 lines
Applied to linux-kbuild.
Thanks.[1] says:
"This looks good to me! Feel free to submit with a:
Tested-by Conor Dooley <[email protected]>"Hey Sedat,
I actually didn't take a proper look at the v2 at all... I didn't realise that Nathan dropped by T-b for v2 since he'd changed the patch enough to feel that he should.
Quoted 6 lines
I'm not too worried about the removed T-b (espcially since Linus has just merged Masahiro's PR containing this change).
Thanks though!
Conor.
Yes, just saw the update on
https://github.com/torvalds/linux/commits/master first.
-Sedat-
Quoted 79 lines
Quoted 79 lines
-sed@-
[1] https://github.com/ClangBuiltLinux/linux/issues/1719#issuecomment-1261158627
Quoted 74 lines
Quoted 59 lines
Quoted 59 lines
---
v2:
- Rebase on commitbb1435f3f575("Kconfig.debug: add toolchain checks forDEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT") from the kbuild tree.
- LimitCONFIG_AS_HAS_NON_CONST_LEB128dependency to GNU as. There is no point to applying this dependency to the integrated assembler because it will always pass.
- Apply theCONFIG_AS_HAS_NON_CONST_LEB128dependency toCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULTas well, due to the aforementioned kbuild change.
- Move comment block to aboveCONFIG_AS_HAS_NON_CONST_LEB128, as the configuration is now used in two places.
- Drop Conor's tested by, as the patch is different enough to potentially require new testing.v1: https://lore.kernel.org/[email protected]/
lib/Kconfig.debug | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/Kconfig.debug +7
-2@@ -231,6 +231,11 @@ config DEBUG_INFO in the "Debug information" choice below, indicating that debug information will be generated for build targets. +# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which +# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 +config AS_HAS_NON_CONST_LEB128 + def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:) + choice prompt "Debug information" depends on DEBUG_KERNEL@@ -253,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time.@@ -277,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for someQuoted 9 lines
Quoted 4 lines
base-commit:
bb1435f3f575b5213eaf27434efa3971f51c01de--
2.38.0--
Thanks,
~Nick Desaulniers--
Best Regards
Masahiro Yamada
Andrew Morton
maintainerQuoted 4 lines · On Fri, 14 Oct 2022 13:42:11 -0700 Nathan Chancellor <[email protected]> wrote:
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supported
hm, which kernels want this?
I could merge it for 6.1, which seems suitable. If we want it backported into earlier kernels then a Fixes: would be nice, to prevent it from being ported back further than necessary.
Nathan Chancellor
maintainerHi Andrew,
Quoted 5 lines · Andrew Morton
Quoted 3 lines · On Fri, 14 Oct 2022 13:42:11 -0700 Nathan Chancellor <[email protected]> wrote:
When building with a RISC-V kernel with DWARF5 debug info using clang and the GNU assembler, several instances of the following error appear:
Quoted 7 lines
Quoted 1 line
/tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supportedhm, which kernels want this?
I could merge it for 6.1, which seems suitable. If we want it backported into earlier kernels then a Fixes: would be nice, to prevent it from being ported back further than necessary.
Masahiro took this for 6.1 via the kbuild tree, it is now in mainline as commit 0a6de78cff60 ("lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5"). It does need to go to stable but it needs a few prerequisite changes to cover all cases and I did not want to try and describe those dependencies in the patch itself. I should be able to handle the backports manually tomorrow.
Cheers,
Nathan