All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions
@ 2023-11-29 23:29 ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

Hi all,

This series disables DWARF5 for LLVM versions where it is known to be
broken due to linker relaxation:

https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6

If I understand correctly, it sounds like GNU binutils has a similar
issue but I am not sure of the status of the fixes and such, so I did
not bother with checking for it but it should be easy to add if so
desired.

Cheers,
Nathan

---
Nathan Chancellor (2):
      riscv: Hoist linker relaxation disabling logic into Kconfig
      riscv: Restrict DWARF5 when building with LLVM to known working versions

 arch/riscv/Kconfig  | 14 ++++++++++++++
 arch/riscv/Makefile |  4 +---
 lib/Kconfig.debug   |  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)
---
base-commit: 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
change-id: 20231129-riscv-restrict-dwarf5-llvm-a9824bb974cb

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions
@ 2023-11-29 23:29 ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

Hi all,

This series disables DWARF5 for LLVM versions where it is known to be
broken due to linker relaxation:

https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6

If I understand correctly, it sounds like GNU binutils has a similar
issue but I am not sure of the status of the fixes and such, so I did
not bother with checking for it but it should be easy to add if so
desired.

Cheers,
Nathan

---
Nathan Chancellor (2):
      riscv: Hoist linker relaxation disabling logic into Kconfig
      riscv: Restrict DWARF5 when building with LLVM to known working versions

 arch/riscv/Kconfig  | 14 ++++++++++++++
 arch/riscv/Makefile |  4 +---
 lib/Kconfig.debug   |  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)
---
base-commit: 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
change-id: 20231129-riscv-restrict-dwarf5-llvm-a9824bb974cb

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig
  2023-11-29 23:29 ` Nathan Chancellor
@ 2023-11-29 23:29   ` Nathan Chancellor
  -1 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

Certain configurations may need to be disabled if linker relaxation is
in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
not linker relaxation is in use into Kconfig so decisions can be made at
configuration time.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Kconfig  | 5 +++++
 arch/riscv/Makefile | 4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 95a2a06acc6a..72be1d8122a3 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
 	# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
 	depends on $(ld-option,--no-relax-gp)
 
+config RISCV_USE_LINKER_RELAXATION
+	def_bool y
+	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
+	depends on !LD_IS_LLD || LLD_VERSION >= 150000
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index a74be78678eb..e383aa9e2757 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -43,8 +43,7 @@ else
 	KBUILD_LDFLAGS += -melf32lriscv
 endif
 
-ifeq ($(CONFIG_LD_IS_LLD),y)
-ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
+ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
-endif
 
 ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
 	KBUILD_LDFLAGS += --no-relax-gp

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig
@ 2023-11-29 23:29   ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

Certain configurations may need to be disabled if linker relaxation is
in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
not linker relaxation is in use into Kconfig so decisions can be made at
configuration time.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Kconfig  | 5 +++++
 arch/riscv/Makefile | 4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 95a2a06acc6a..72be1d8122a3 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
 	# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
 	depends on $(ld-option,--no-relax-gp)
 
+config RISCV_USE_LINKER_RELAXATION
+	def_bool y
+	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
+	depends on !LD_IS_LLD || LLD_VERSION >= 150000
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index a74be78678eb..e383aa9e2757 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -43,8 +43,7 @@ else
 	KBUILD_LDFLAGS += -melf32lriscv
 endif
 
-ifeq ($(CONFIG_LD_IS_LLD),y)
-ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
+ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
@@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM
 	KBUILD_AFLAGS += -Wa,-mno-relax
 endif
 endif
-endif
 
 ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
 	KBUILD_LDFLAGS += --no-relax-gp

-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-11-29 23:29 ` Nathan Chancellor
@ 2023-11-29 23:29   ` Nathan Chancellor
  -1 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
to linker relaxation, which was worked around in clang by defaulting
RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
the kernel because the DWARF version can be independently changed from
the default in Kconfig.

Do not allow DWARF5 to be selected for RISC-V when using linker
relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
necessary to generate the correct debug info.

Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Kconfig | 9 +++++++++
 lib/Kconfig.debug  | 1 +
 2 files changed, 10 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 72be1d8122a3..81b473cb47b0 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
 	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
 	depends on !LD_IS_LLD || LLD_VERSION >= 150000
 
+# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
+config ARCH_HAS_BROKEN_DWARF5
+	def_bool y
+	depends on RISCV_USE_LINKER_RELAXATION
+	# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
+	depends on AS_IS_LLVM && AS_VERSION < 180000
+	# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
+	depends on LD_IS_LLD && LLD_VERSION < 180000
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index cc7d53d9dc01..a0ebce05a368 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
+	depends on !ARCH_HAS_BROKEN_DWARF5
 	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

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-11-29 23:29   ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-11-29 23:29 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, conor
  Cc: maskray, ndesaulniers, linux-riscv, llvm, patches, Nathan Chancellor

LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
to linker relaxation, which was worked around in clang by defaulting
RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
the kernel because the DWARF version can be independently changed from
the default in Kconfig.

Do not allow DWARF5 to be selected for RISC-V when using linker
relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
necessary to generate the correct debug info.

Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/riscv/Kconfig | 9 +++++++++
 lib/Kconfig.debug  | 1 +
 2 files changed, 10 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 72be1d8122a3..81b473cb47b0 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
 	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
 	depends on !LD_IS_LLD || LLD_VERSION >= 150000
 
+# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
+config ARCH_HAS_BROKEN_DWARF5
+	def_bool y
+	depends on RISCV_USE_LINKER_RELAXATION
+	# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
+	depends on AS_IS_LLVM && AS_VERSION < 180000
+	# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
+	depends on LD_IS_LLD && LLD_VERSION < 180000
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index cc7d53d9dc01..a0ebce05a368 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
+	depends on !ARCH_HAS_BROKEN_DWARF5
 	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

-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions
  2023-11-29 23:29 ` Nathan Chancellor
@ 2023-11-30 16:03   ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:03 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi all,
>
> This series disables DWARF5 for LLVM versions where it is known to be
> broken due to linker relaxation:
>
> https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
>
> If I understand correctly, it sounds like GNU binutils has a similar
> issue but I am not sure of the status of the fixes and such, so I did
> not bother with checking for it but it should be easy to add if so
> desired.

Using Clang with -fno-integrated-as requires binutils>=2.41
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f1cd8b94e7c941c2a9107c1112ab2339916b8efd
"RISC-V: Support subtraction of .uleb128."

Using -fno-integrated-as is less common nowadays, so I agree we do not
bother with checking for it now, if it is too troublesome.

> Cheers,
> Nathan
>
> ---
> Nathan Chancellor (2):
>       riscv: Hoist linker relaxation disabling logic into Kconfig
>       riscv: Restrict DWARF5 when building with LLVM to known working versions
>
>  arch/riscv/Kconfig  | 14 ++++++++++++++
>  arch/riscv/Makefile |  4 +---
>  lib/Kconfig.debug   |  1 +
>  3 files changed, 16 insertions(+), 3 deletions(-)
> ---
> base-commit: 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
> change-id: 20231129-riscv-restrict-dwarf5-llvm-a9824bb974cb
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>


-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions
@ 2023-11-30 16:03   ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:03 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi all,
>
> This series disables DWARF5 for LLVM versions where it is known to be
> broken due to linker relaxation:
>
> https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
>
> If I understand correctly, it sounds like GNU binutils has a similar
> issue but I am not sure of the status of the fixes and such, so I did
> not bother with checking for it but it should be easy to add if so
> desired.

Using Clang with -fno-integrated-as requires binutils>=2.41
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f1cd8b94e7c941c2a9107c1112ab2339916b8efd
"RISC-V: Support subtraction of .uleb128."

Using -fno-integrated-as is less common nowadays, so I agree we do not
bother with checking for it now, if it is too troublesome.

> Cheers,
> Nathan
>
> ---
> Nathan Chancellor (2):
>       riscv: Hoist linker relaxation disabling logic into Kconfig
>       riscv: Restrict DWARF5 when building with LLVM to known working versions
>
>  arch/riscv/Kconfig  | 14 ++++++++++++++
>  arch/riscv/Makefile |  4 +---
>  lib/Kconfig.debug   |  1 +
>  3 files changed, 16 insertions(+), 3 deletions(-)
> ---
> base-commit: 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
> change-id: 20231129-riscv-restrict-dwarf5-llvm-a9824bb974cb
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>


-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig
  2023-11-29 23:29   ` Nathan Chancellor
@ 2023-11-30 16:06     ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:06 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Certain configurations may need to be disabled if linker relaxation is
> in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
> not linker relaxation is in use into Kconfig so decisions can be made at
> configuration time.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Kconfig  | 5 +++++
>  arch/riscv/Makefile | 4 +---
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 95a2a06acc6a..72be1d8122a3 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
>         # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
>         depends on $(ld-option,--no-relax-gp)
>
> +config RISCV_USE_LINKER_RELAXATION
> +       def_bool y
> +       # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> +       depends on !LD_IS_LLD || LLD_VERSION >= 150000
> +
>  config ARCH_MMAP_RND_BITS_MIN
>         default 18 if 64BIT
>         default 8
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index a74be78678eb..e383aa9e2757 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -43,8 +43,7 @@ else
>         KBUILD_LDFLAGS += -melf32lriscv
>  endif
>
> -ifeq ($(CONFIG_LD_IS_LLD),y)
> -ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
> +ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
>         KBUILD_CFLAGS += -mno-relax
>         KBUILD_AFLAGS += -mno-relax
>  ifndef CONFIG_AS_IS_LLVM
> @@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM
>         KBUILD_AFLAGS += -Wa,-mno-relax
>  endif
>  endif
> -endif
>
>  ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
>         KBUILD_LDFLAGS += --no-relax-gp
>
> --
> 2.43.0


Reviewed-by: Fangrui Song <maskray@google.com>


-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig
@ 2023-11-30 16:06     ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:06 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Certain configurations may need to be disabled if linker relaxation is
> in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or
> not linker relaxation is in use into Kconfig so decisions can be made at
> configuration time.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Kconfig  | 5 +++++
>  arch/riscv/Makefile | 4 +---
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 95a2a06acc6a..72be1d8122a3 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
>         # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
>         depends on $(ld-option,--no-relax-gp)
>
> +config RISCV_USE_LINKER_RELAXATION
> +       def_bool y
> +       # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> +       depends on !LD_IS_LLD || LLD_VERSION >= 150000
> +
>  config ARCH_MMAP_RND_BITS_MIN
>         default 18 if 64BIT
>         default 8
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index a74be78678eb..e383aa9e2757 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -43,8 +43,7 @@ else
>         KBUILD_LDFLAGS += -melf32lriscv
>  endif
>
> -ifeq ($(CONFIG_LD_IS_LLD),y)
> -ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
> +ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
>         KBUILD_CFLAGS += -mno-relax
>         KBUILD_AFLAGS += -mno-relax
>  ifndef CONFIG_AS_IS_LLVM
> @@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM
>         KBUILD_AFLAGS += -Wa,-mno-relax
>  endif
>  endif
> -endif
>
>  ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
>         KBUILD_LDFLAGS += --no-relax-gp
>
> --
> 2.43.0


Reviewed-by: Fangrui Song <maskray@google.com>


-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-11-29 23:29   ` Nathan Chancellor
@ 2023-11-30 16:16     ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:16 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> to linker relaxation, which was worked around in clang by defaulting
> RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> the kernel because the DWARF version can be independently changed from
> the default in Kconfig.
>
> Do not allow DWARF5 to be selected for RISC-V when using linker
> relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> necessary to generate the correct debug info.
>
> Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Kconfig | 9 +++++++++
>  lib/Kconfig.debug  | 1 +
>  2 files changed, 10 insertions(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 72be1d8122a3..81b473cb47b0 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
>         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
>         depends on !LD_IS_LLD || LLD_VERSION >= 150000
>
> +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> +config ARCH_HAS_BROKEN_DWARF5
> +       def_bool y
> +       depends on RISCV_USE_LINKER_RELAXATION
> +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> +       depends on AS_IS_LLVM && AS_VERSION < 180000
> +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> +       depends on LD_IS_LLD && LLD_VERSION < 180000
> +
>  config ARCH_MMAP_RND_BITS_MIN
>         default 18 if 64BIT
>         default 8
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index cc7d53d9dc01..a0ebce05a368 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
>  config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
> +       depends on !ARCH_HAS_BROKEN_DWARF5
>         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
>
> --
> 2.43.0
>

A comment and "depends on" condition introduced by commit
0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
for non-constant .{s,u}leb128 support to DWARF5"
can now be refined.

> ib/Kconfig.debug
> (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)

AS_VERSION can now be 24100.

Thanks for the comment. I just marked
https://sourceware.org/bugzilla/show_bug.cgi?id=27215 (" as: Error:
non-constant .uleb128 is not supported on riscv64") as resolved :)

> +# 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

This comment can be updated:)


-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-11-30 16:16     ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-11-30 16:16 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> to linker relaxation, which was worked around in clang by defaulting
> RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> the kernel because the DWARF version can be independently changed from
> the default in Kconfig.
>
> Do not allow DWARF5 to be selected for RISC-V when using linker
> relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> necessary to generate the correct debug info.
>
> Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  arch/riscv/Kconfig | 9 +++++++++
>  lib/Kconfig.debug  | 1 +
>  2 files changed, 10 insertions(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 72be1d8122a3..81b473cb47b0 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
>         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
>         depends on !LD_IS_LLD || LLD_VERSION >= 150000
>
> +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> +config ARCH_HAS_BROKEN_DWARF5
> +       def_bool y
> +       depends on RISCV_USE_LINKER_RELAXATION
> +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> +       depends on AS_IS_LLVM && AS_VERSION < 180000
> +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> +       depends on LD_IS_LLD && LLD_VERSION < 180000
> +
>  config ARCH_MMAP_RND_BITS_MIN
>         default 18 if 64BIT
>         default 8
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index cc7d53d9dc01..a0ebce05a368 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
>  config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
> +       depends on !ARCH_HAS_BROKEN_DWARF5
>         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
>
> --
> 2.43.0
>

A comment and "depends on" condition introduced by commit
0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
for non-constant .{s,u}leb128 support to DWARF5"
can now be refined.

> ib/Kconfig.debug
> (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)

AS_VERSION can now be 24100.

Thanks for the comment. I just marked
https://sourceware.org/bugzilla/show_bug.cgi?id=27215 (" as: Error:
non-constant .uleb128 is not supported on riscv64") as resolved :)

> +# 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

This comment can be updated:)


-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-11-30 16:16     ` Fangrui Song
@ 2023-12-01 19:48       ` Nathan Chancellor
  -1 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-01 19:48 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > to linker relaxation, which was worked around in clang by defaulting
> > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > the kernel because the DWARF version can be independently changed from
> > the default in Kconfig.
> >
> > Do not allow DWARF5 to be selected for RISC-V when using linker
> > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > necessary to generate the correct debug info.
> >
> > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  arch/riscv/Kconfig | 9 +++++++++
> >  lib/Kconfig.debug  | 1 +
> >  2 files changed, 10 insertions(+)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 72be1d8122a3..81b473cb47b0 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> >
> > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > +config ARCH_HAS_BROKEN_DWARF5
> > +       def_bool y
> > +       depends on RISCV_USE_LINKER_RELAXATION
> > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > +
> >  config ARCH_MMAP_RND_BITS_MIN
> >         default 18 if 64BIT
> >         default 8
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index cc7d53d9dc01..a0ebce05a368 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> >  config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> > +       depends on !ARCH_HAS_BROKEN_DWARF5
> >         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
> >
> > --
> > 2.43.0
> >
> 
> A comment and "depends on" condition introduced by commit
> 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> for non-constant .{s,u}leb128 support to DWARF5"
> can now be refined.
> 
> > ib/Kconfig.debug
> > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> 
> AS_VERSION can now be 24100.

That will impact all architectures that use GNU as, even though the
issue was really only seen on RISC-V. It probably doesn't matter since
most architectures work with the integrated assembler and that is what
we tell people to use but I think the current check will continue to
work.

Alternatively, I could do something like this but it is quite ugly and
verbose :/

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a0ebce05a368..aea0ef5a5d1f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -231,11 +231,6 @@ 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
@@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
 	depends on !ARCH_HAS_BROKEN_DWARF5
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
 	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

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-01 19:48       ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-01 19:48 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > to linker relaxation, which was worked around in clang by defaulting
> > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > the kernel because the DWARF version can be independently changed from
> > the default in Kconfig.
> >
> > Do not allow DWARF5 to be selected for RISC-V when using linker
> > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > necessary to generate the correct debug info.
> >
> > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  arch/riscv/Kconfig | 9 +++++++++
> >  lib/Kconfig.debug  | 1 +
> >  2 files changed, 10 insertions(+)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 72be1d8122a3..81b473cb47b0 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> >
> > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > +config ARCH_HAS_BROKEN_DWARF5
> > +       def_bool y
> > +       depends on RISCV_USE_LINKER_RELAXATION
> > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > +
> >  config ARCH_MMAP_RND_BITS_MIN
> >         default 18 if 64BIT
> >         default 8
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index cc7d53d9dc01..a0ebce05a368 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> >  config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> > +       depends on !ARCH_HAS_BROKEN_DWARF5
> >         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
> >
> > --
> > 2.43.0
> >
> 
> A comment and "depends on" condition introduced by commit
> 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> for non-constant .{s,u}leb128 support to DWARF5"
> can now be refined.
> 
> > ib/Kconfig.debug
> > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> 
> AS_VERSION can now be 24100.

That will impact all architectures that use GNU as, even though the
issue was really only seen on RISC-V. It probably doesn't matter since
most architectures work with the integrated assembler and that is what
we tell people to use but I think the current check will continue to
work.

Alternatively, I could do something like this but it is quite ugly and
verbose :/

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a0ebce05a368..aea0ef5a5d1f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -231,11 +231,6 @@ 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
@@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
 	depends on !ARCH_HAS_BROKEN_DWARF5
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
 	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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-12-01 19:48       ` Nathan Chancellor
@ 2023-12-01 20:12         ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-01 20:12 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > to linker relaxation, which was worked around in clang by defaulting
> > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > the kernel because the DWARF version can be independently changed from
> > > the default in Kconfig.
> > >
> > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > necessary to generate the correct debug info.
> > >
> > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > ---
> > >  arch/riscv/Kconfig | 9 +++++++++
> > >  lib/Kconfig.debug  | 1 +
> > >  2 files changed, 10 insertions(+)
> > >
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index 72be1d8122a3..81b473cb47b0 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > >
> > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > +config ARCH_HAS_BROKEN_DWARF5
> > > +       def_bool y
> > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > +
> > >  config ARCH_MMAP_RND_BITS_MIN
> > >         default 18 if 64BIT
> > >         default 8
> > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > index cc7d53d9dc01..a0ebce05a368 100644
> > > --- a/lib/Kconfig.debug
> > > +++ b/lib/Kconfig.debug
> > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > >  config DEBUG_INFO_DWARF5
> > >         bool "Generate DWARF Version 5 debuginfo"
> > >         select DEBUG_INFO
> > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > >         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
> > >
> > > --
> > > 2.43.0
> > >
> >
> > A comment and "depends on" condition introduced by commit
> > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > for non-constant .{s,u}leb128 support to DWARF5"
> > can now be refined.
> >
> > > ib/Kconfig.debug
> > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> >
> > AS_VERSION can now be 24100.
>
> That will impact all architectures that use GNU as, even though the
> issue was really only seen on RISC-V. It probably doesn't matter since
> most architectures work with the integrated assembler and that is what
> we tell people to use but I think the current check will continue to
> work.

Agreed.

    depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
>= 23502 && AS_HAS_NON_CONST_LEB128)

is enabled for GCC. The long condition chain is for Clang. Given
Clang's behavior, we can simplify this to

    depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
AS_HAS_NON_CONST_LEB128)

This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
added to llvm-project.
This condition matches HAVE_AS_LEB128 in GCC in spirit.

> Alternatively, I could do something like this but it is quite ugly and
> verbose :/
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a0ebce05a368..aea0ef5a5d1f 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,11 +231,6 @@ 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:)
> -

Consider keeping this config, but just reword the comment.

>  choice
>         prompt "Debug information"
>         depends on DEBUG_KERNEL
> @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))

The RISCV condition would cause additional churn when LoongArch
ULEB128 support is added.

>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
>         depends on !ARCH_HAS_BROKEN_DWARF5
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
>         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



-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-01 20:12         ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-01 20:12 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > to linker relaxation, which was worked around in clang by defaulting
> > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > the kernel because the DWARF version can be independently changed from
> > > the default in Kconfig.
> > >
> > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > necessary to generate the correct debug info.
> > >
> > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > ---
> > >  arch/riscv/Kconfig | 9 +++++++++
> > >  lib/Kconfig.debug  | 1 +
> > >  2 files changed, 10 insertions(+)
> > >
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index 72be1d8122a3..81b473cb47b0 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > >
> > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > +config ARCH_HAS_BROKEN_DWARF5
> > > +       def_bool y
> > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > +
> > >  config ARCH_MMAP_RND_BITS_MIN
> > >         default 18 if 64BIT
> > >         default 8
> > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > index cc7d53d9dc01..a0ebce05a368 100644
> > > --- a/lib/Kconfig.debug
> > > +++ b/lib/Kconfig.debug
> > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > >  config DEBUG_INFO_DWARF5
> > >         bool "Generate DWARF Version 5 debuginfo"
> > >         select DEBUG_INFO
> > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > >         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
> > >
> > > --
> > > 2.43.0
> > >
> >
> > A comment and "depends on" condition introduced by commit
> > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > for non-constant .{s,u}leb128 support to DWARF5"
> > can now be refined.
> >
> > > ib/Kconfig.debug
> > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> >
> > AS_VERSION can now be 24100.
>
> That will impact all architectures that use GNU as, even though the
> issue was really only seen on RISC-V. It probably doesn't matter since
> most architectures work with the integrated assembler and that is what
> we tell people to use but I think the current check will continue to
> work.

Agreed.

    depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
>= 23502 && AS_HAS_NON_CONST_LEB128)

is enabled for GCC. The long condition chain is for Clang. Given
Clang's behavior, we can simplify this to

    depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
AS_HAS_NON_CONST_LEB128)

This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
added to llvm-project.
This condition matches HAVE_AS_LEB128 in GCC in spirit.

> Alternatively, I could do something like this but it is quite ugly and
> verbose :/
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a0ebce05a368..aea0ef5a5d1f 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,11 +231,6 @@ 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:)
> -

Consider keeping this config, but just reword the comment.

>  choice
>         prompt "Debug information"
>         depends on DEBUG_KERNEL
> @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))

The RISCV condition would cause additional churn when LoongArch
ULEB128 support is added.

>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
>         depends on !ARCH_HAS_BROKEN_DWARF5
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
>         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



-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-12-01 20:12         ` Fangrui Song
@ 2023-12-01 21:50           ` Nathan Chancellor
  -1 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-01 21:50 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 01, 2023 at 12:12:26PM -0800, Fangrui Song wrote:
> On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > > >
> > > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > > to linker relaxation, which was worked around in clang by defaulting
> > > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > > the kernel because the DWARF version can be independently changed from
> > > > the default in Kconfig.
> > > >
> > > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > > necessary to generate the correct debug info.
> > > >
> > > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > > ---
> > > >  arch/riscv/Kconfig | 9 +++++++++
> > > >  lib/Kconfig.debug  | 1 +
> > > >  2 files changed, 10 insertions(+)
> > > >
> > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > index 72be1d8122a3..81b473cb47b0 100644
> > > > --- a/arch/riscv/Kconfig
> > > > +++ b/arch/riscv/Kconfig
> > > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > > >
> > > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > > +config ARCH_HAS_BROKEN_DWARF5
> > > > +       def_bool y
> > > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > > +
> > > >  config ARCH_MMAP_RND_BITS_MIN
> > > >         default 18 if 64BIT
> > > >         default 8
> > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > > index cc7d53d9dc01..a0ebce05a368 100644
> > > > --- a/lib/Kconfig.debug
> > > > +++ b/lib/Kconfig.debug
> > > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > > >  config DEBUG_INFO_DWARF5
> > > >         bool "Generate DWARF Version 5 debuginfo"
> > > >         select DEBUG_INFO
> > > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > > >         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
> > > >
> > > > --
> > > > 2.43.0
> > > >
> > >
> > > A comment and "depends on" condition introduced by commit
> > > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > > for non-constant .{s,u}leb128 support to DWARF5"
> > > can now be refined.
> > >
> > > > ib/Kconfig.debug
> > > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > >
> > > AS_VERSION can now be 24100.
> >
> > That will impact all architectures that use GNU as, even though the
> > issue was really only seen on RISC-V. It probably doesn't matter since
> > most architectures work with the integrated assembler and that is what
> > we tell people to use but I think the current check will continue to
> > work.
> 
> Agreed.
> 
>     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
> >= 23502 && AS_HAS_NON_CONST_LEB128)
> 
> is enabled for GCC. The long condition chain is for Clang. Given
> Clang's behavior, we can simplify this to
> 
>     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
> AS_HAS_NON_CONST_LEB128)

I think we still need the version check due to
https://sourceware.org/bugzilla/show_bug.cgi?id=25611, which was added
in commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5").

> This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
> added to llvm-project.
> This condition matches HAVE_AS_LEB128 in GCC in spirit.
> 
> > Alternatively, I could do something like this but it is quite ugly and
> > verbose :/
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index a0ebce05a368..aea0ef5a5d1f 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -231,11 +231,6 @@ 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:)
> > -
> 
> Consider keeping this config, but just reword the comment.

Do you have a suggestion for how it should be reworded? I am struggling
to come up with something that conveys additional information in a
succinct manner.

> >  choice
> >         prompt "Debug information"
> >         depends on DEBUG_KERNEL
> > @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> 
> The RISCV condition would cause additional churn when LoongArch
> ULEB128 support is added.

Ah, I did not realize that LoongArch would have the same issue. This is
definitely not the right way to go for that then.

> >         help
> >           The implicit default version of DWARF debug info produced by a
> >           toolchain changes over time.
> > @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> >         depends on !ARCH_HAS_BROKEN_DWARF5
> > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> >         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

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-01 21:50           ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-01 21:50 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 01, 2023 at 12:12:26PM -0800, Fangrui Song wrote:
> On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > > >
> > > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > > to linker relaxation, which was worked around in clang by defaulting
> > > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > > the kernel because the DWARF version can be independently changed from
> > > > the default in Kconfig.
> > > >
> > > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > > necessary to generate the correct debug info.
> > > >
> > > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > > ---
> > > >  arch/riscv/Kconfig | 9 +++++++++
> > > >  lib/Kconfig.debug  | 1 +
> > > >  2 files changed, 10 insertions(+)
> > > >
> > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > index 72be1d8122a3..81b473cb47b0 100644
> > > > --- a/arch/riscv/Kconfig
> > > > +++ b/arch/riscv/Kconfig
> > > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > > >
> > > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > > +config ARCH_HAS_BROKEN_DWARF5
> > > > +       def_bool y
> > > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > > +
> > > >  config ARCH_MMAP_RND_BITS_MIN
> > > >         default 18 if 64BIT
> > > >         default 8
> > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > > index cc7d53d9dc01..a0ebce05a368 100644
> > > > --- a/lib/Kconfig.debug
> > > > +++ b/lib/Kconfig.debug
> > > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > > >  config DEBUG_INFO_DWARF5
> > > >         bool "Generate DWARF Version 5 debuginfo"
> > > >         select DEBUG_INFO
> > > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > > >         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
> > > >
> > > > --
> > > > 2.43.0
> > > >
> > >
> > > A comment and "depends on" condition introduced by commit
> > > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > > for non-constant .{s,u}leb128 support to DWARF5"
> > > can now be refined.
> > >
> > > > ib/Kconfig.debug
> > > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > >
> > > AS_VERSION can now be 24100.
> >
> > That will impact all architectures that use GNU as, even though the
> > issue was really only seen on RISC-V. It probably doesn't matter since
> > most architectures work with the integrated assembler and that is what
> > we tell people to use but I think the current check will continue to
> > work.
> 
> Agreed.
> 
>     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
> >= 23502 && AS_HAS_NON_CONST_LEB128)
> 
> is enabled for GCC. The long condition chain is for Clang. Given
> Clang's behavior, we can simplify this to
> 
>     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
> AS_HAS_NON_CONST_LEB128)

I think we still need the version check due to
https://sourceware.org/bugzilla/show_bug.cgi?id=25611, which was added
in commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5").

> This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
> added to llvm-project.
> This condition matches HAVE_AS_LEB128 in GCC in spirit.
> 
> > Alternatively, I could do something like this but it is quite ugly and
> > verbose :/
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index a0ebce05a368..aea0ef5a5d1f 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -231,11 +231,6 @@ 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:)
> > -
> 
> Consider keeping this config, but just reword the comment.

Do you have a suggestion for how it should be reworded? I am struggling
to come up with something that conveys additional information in a
succinct manner.

> >  choice
> >         prompt "Debug information"
> >         depends on DEBUG_KERNEL
> > @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> 
> The RISCV condition would cause additional churn when LoongArch
> ULEB128 support is added.

Ah, I did not realize that LoongArch would have the same issue. This is
definitely not the right way to go for that then.

> >         help
> >           The implicit default version of DWARF debug info produced by a
> >           toolchain changes over time.
> > @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> >         depends on !ARCH_HAS_BROKEN_DWARF5
> > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> >         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

Cheers,
Nathan

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-12-01 21:50           ` Nathan Chancellor
@ 2023-12-02  4:31             ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-02  4:31 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 1, 2023 at 1:50 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Fri, Dec 01, 2023 at 12:12:26PM -0800, Fangrui Song wrote:
> > On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > > > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > > > >
> > > > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > > > to linker relaxation, which was worked around in clang by defaulting
> > > > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > > > the kernel because the DWARF version can be independently changed from
> > > > > the default in Kconfig.
> > > > >
> > > > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > > > necessary to generate the correct debug info.
> > > > >
> > > > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > > > ---
> > > > >  arch/riscv/Kconfig | 9 +++++++++
> > > > >  lib/Kconfig.debug  | 1 +
> > > > >  2 files changed, 10 insertions(+)
> > > > >
> > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > index 72be1d8122a3..81b473cb47b0 100644
> > > > > --- a/arch/riscv/Kconfig
> > > > > +++ b/arch/riscv/Kconfig
> > > > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > > > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > > > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > > > >
> > > > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > > > +config ARCH_HAS_BROKEN_DWARF5
> > > > > +       def_bool y
> > > > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > > > +
> > > > >  config ARCH_MMAP_RND_BITS_MIN
> > > > >         default 18 if 64BIT
> > > > >         default 8
> > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > > > index cc7d53d9dc01..a0ebce05a368 100644
> > > > > --- a/lib/Kconfig.debug
> > > > > +++ b/lib/Kconfig.debug
> > > > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > > > >  config DEBUG_INFO_DWARF5
> > > > >         bool "Generate DWARF Version 5 debuginfo"
> > > > >         select DEBUG_INFO
> > > > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > > > >         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
> > > > >
> > > > > --
> > > > > 2.43.0
> > > > >
> > > >
> > > > A comment and "depends on" condition introduced by commit
> > > > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > > > for non-constant .{s,u}leb128 support to DWARF5"
> > > > can now be refined.
> > > >
> > > > > ib/Kconfig.debug
> > > > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > > >
> > > > AS_VERSION can now be 24100.
> > >
> > > That will impact all architectures that use GNU as, even though the
> > > issue was really only seen on RISC-V. It probably doesn't matter since
> > > most architectures work with the integrated assembler and that is what
> > > we tell people to use but I think the current check will continue to
> > > work.
> >
> > Agreed.
> >
> >     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
> > >= 23502 && AS_HAS_NON_CONST_LEB128)
> >
> > is enabled for GCC. The long condition chain is for Clang. Given
> > Clang's behavior, we can simplify this to
> >
> >     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
> > AS_HAS_NON_CONST_LEB128)
>
> I think we still need the version check due to
> https://sourceware.org/bugzilla/show_bug.cgi?id=25611, which was added
> in commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5").

I see...

> > This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
> > added to llvm-project.
> > This condition matches HAVE_AS_LEB128 in GCC in spirit.
> >
> > > Alternatively, I could do something like this but it is quite ugly and
> > > verbose :/
> > >
> > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > index a0ebce05a368..aea0ef5a5d1f 100644
> > > --- a/lib/Kconfig.debug
> > > +++ b/lib/Kconfig.debug
> > > @@ -231,11 +231,6 @@ 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:)
> > > -
> >
> > Consider keeping this config, but just reword the comment.
>
> Do you have a suggestion for how it should be reworded? I am struggling
> to come up with something that conveys additional information in a
> succinct manner.

Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
a feature that older binutils ports, utilizing RISC-V style linker
relaxation, do not support.

(Signed LEB128 is used by DWARF as well, but it is encoded directly
into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
directives are not emitted)
(In assemblers, "label difference" is a more common term.)
(People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
full "DWARF version 5" feels too verbose.)

> > >  choice
> > >         prompt "Debug information"
> > >         depends on DEBUG_KERNEL
> > > @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> > > +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> >
> > The RISCV condition would cause additional churn when LoongArch
> > ULEB128 support is added.
>
> Ah, I did not realize that LoongArch would have the same issue. This is
> definitely not the right way to go for that then.
>
> > >         help
> > >           The implicit default version of DWARF debug info produced by a
> > >           toolchain changes over time.
> > > @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
> > >         bool "Generate DWARF Version 5 debuginfo"
> > >         select DEBUG_INFO
> > >         depends on !ARCH_HAS_BROKEN_DWARF5
> > > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> > >         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
>
> Cheers,
> Nathan
>


-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-02  4:31             ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-02  4:31 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 1, 2023 at 1:50 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Fri, Dec 01, 2023 at 12:12:26PM -0800, Fangrui Song wrote:
> > On Fri, Dec 1, 2023 at 11:49 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > On Thu, Nov 30, 2023 at 08:16:41AM -0800, Fangrui Song wrote:
> > > > On Wed, Nov 29, 2023 at 3:30 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > > > >
> > > > > LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due
> > > > > to linker relaxation, which was worked around in clang by defaulting
> > > > > RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for
> > > > > the kernel because the DWARF version can be independently changed from
> > > > > the default in Kconfig.
> > > > >
> > > > > Do not allow DWARF5 to be selected for RISC-V when using linker
> > > > > relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have
> > > > > the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0)
> > > > > necessary to generate the correct debug info.
> > > > >
> > > > > Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1]
> > > > > Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2]
> > > > > Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3]
> > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > > > ---
> > > > >  arch/riscv/Kconfig | 9 +++++++++
> > > > >  lib/Kconfig.debug  | 1 +
> > > > >  2 files changed, 10 insertions(+)
> > > > >
> > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > > > index 72be1d8122a3..81b473cb47b0 100644
> > > > > --- a/arch/riscv/Kconfig
> > > > > +++ b/arch/riscv/Kconfig
> > > > > @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
> > > > >         # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
> > > > >         depends on !LD_IS_LLD || LLD_VERSION >= 150000
> > > > >
> > > > > +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
> > > > > +config ARCH_HAS_BROKEN_DWARF5
> > > > > +       def_bool y
> > > > > +       depends on RISCV_USE_LINKER_RELAXATION
> > > > > +       # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
> > > > > +       depends on AS_IS_LLVM && AS_VERSION < 180000
> > > > > +       # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
> > > > > +       depends on LD_IS_LLD && LLD_VERSION < 180000
> > > > > +
> > > > >  config ARCH_MMAP_RND_BITS_MIN
> > > > >         default 18 if 64BIT
> > > > >         default 8
> > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > > > index cc7d53d9dc01..a0ebce05a368 100644
> > > > > --- a/lib/Kconfig.debug
> > > > > +++ b/lib/Kconfig.debug
> > > > > @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
> > > > >  config DEBUG_INFO_DWARF5
> > > > >         bool "Generate DWARF Version 5 debuginfo"
> > > > >         select DEBUG_INFO
> > > > > +       depends on !ARCH_HAS_BROKEN_DWARF5
> > > > >         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
> > > > >
> > > > > --
> > > > > 2.43.0
> > > > >
> > > >
> > > > A comment and "depends on" condition introduced by commit
> > > > 0a6de78cff600cb991f2a1b7ed376935871796a0 "lib/Kconfig.debug: Add check
> > > > for non-constant .{s,u}leb128 support to DWARF5"
> > > > can now be refined.
> > > >
> > > > > ib/Kconfig.debug
> > > > > (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > > >
> > > > AS_VERSION can now be 24100.
> > >
> > > That will impact all architectures that use GNU as, even though the
> > > issue was really only seen on RISC-V. It probably doesn't matter since
> > > most architectures work with the integrated assembler and that is what
> > > we tell people to use but I think the current check will continue to
> > > work.
> >
> > Agreed.
> >
> >     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION
> > >= 23502 && AS_HAS_NON_CONST_LEB128)
> >
> > is enabled for GCC. The long condition chain is for Clang. Given
> > Clang's behavior, we can simplify this to
> >
> >     depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU &&
> > AS_HAS_NON_CONST_LEB128)
>
> I think we still need the version check due to
> https://sourceware.org/bugzilla/show_bug.cgi?id=25611, which was added
> in commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5").

I see...

> > This will still work even after R_LARCH_{ADD,SUB}_ULEB128 support is
> > added to llvm-project.
> > This condition matches HAVE_AS_LEB128 in GCC in spirit.
> >
> > > Alternatively, I could do something like this but it is quite ugly and
> > > verbose :/
> > >
> > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > index a0ebce05a368..aea0ef5a5d1f 100644
> > > --- a/lib/Kconfig.debug
> > > +++ b/lib/Kconfig.debug
> > > @@ -231,11 +231,6 @@ 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:)
> > > -
> >
> > Consider keeping this config, but just reword the comment.
>
> Do you have a suggestion for how it should be reworded? I am struggling
> to come up with something that conveys additional information in a
> succinct manner.

Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
a feature that older binutils ports, utilizing RISC-V style linker
relaxation, do not support.

(Signed LEB128 is used by DWARF as well, but it is encoded directly
into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
directives are not emitted)
(In assemblers, "label difference" is a more common term.)
(People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
full "DWARF version 5" feels too verbose.)

> > >  choice
> > >         prompt "Debug information"
> > >         depends on DEBUG_KERNEL
> > > @@ -258,7 +253,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 && AS_HAS_NON_CONST_LEB128)
> > > +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> >
> > The RISCV condition would cause additional churn when LoongArch
> > ULEB128 support is added.
>
> Ah, I did not realize that LoongArch would have the same issue. This is
> definitely not the right way to go for that then.
>
> > >         help
> > >           The implicit default version of DWARF debug info produced by a
> > >           toolchain changes over time.
> > > @@ -283,7 +278,7 @@ config DEBUG_INFO_DWARF5
> > >         bool "Generate DWARF Version 5 debuginfo"
> > >         select DEBUG_INFO
> > >         depends on !ARCH_HAS_BROKEN_DWARF5
> > > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> > > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && ((!RISCV && AS_VERSION >= 23502) || (RISCV && AS_VERSION >= 24100)))
> > >         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
>
> Cheers,
> Nathan
>


-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-12-02  4:31             ` Fangrui Song
@ 2023-12-04 23:11               ` Nathan Chancellor
  -1 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-04 23:11 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 01, 2023 at 08:31:12PM -0800, Fangrui Song wrote:
> Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
> a feature that older binutils ports, utilizing RISC-V style linker
> relaxation, do not support.
> 
> (Signed LEB128 is used by DWARF as well, but it is encoded directly
> into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
> directives are not emitted)
> (In assemblers, "label difference" is a more common term.)
> (People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
> full "DWARF version 5" feels too verbose.)

Thanks, does this diff seem reasonable to you? I'd like to keep the
issue link as a paper trail and I figured that we might as well make the
configuration name slightly more accurate with that additional
information. I will send it as a separate patch in v2 tomorrow if so in
order to give people a chance to further chime in on the series.

Cheers,
Nathan

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a0ebce05a368..76c2cc697573 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -231,9 +231,10 @@ 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
+# Clang generates .uleb128 with label differences for DWARF v5, a feature that
+# older binutils ports do not support when utilizing RISC-V style linker
+# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
+config AS_HAS_NON_CONST_ULEB128
 	def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
 
 choice
@@ -258,7 +259,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 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -283,7 +284,7 @@ config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
 	depends on !ARCH_HAS_BROKEN_DWARF5
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
 	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

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-04 23:11               ` Nathan Chancellor
  0 siblings, 0 replies; 24+ messages in thread
From: Nathan Chancellor @ 2023-12-04 23:11 UTC (permalink / raw)
  To: Fangrui Song
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Fri, Dec 01, 2023 at 08:31:12PM -0800, Fangrui Song wrote:
> Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
> a feature that older binutils ports, utilizing RISC-V style linker
> relaxation, do not support.
> 
> (Signed LEB128 is used by DWARF as well, but it is encoded directly
> into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
> directives are not emitted)
> (In assemblers, "label difference" is a more common term.)
> (People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
> full "DWARF version 5" feels too verbose.)

Thanks, does this diff seem reasonable to you? I'd like to keep the
issue link as a paper trail and I figured that we might as well make the
configuration name slightly more accurate with that additional
information. I will send it as a separate patch in v2 tomorrow if so in
order to give people a chance to further chime in on the series.

Cheers,
Nathan

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a0ebce05a368..76c2cc697573 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -231,9 +231,10 @@ 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
+# Clang generates .uleb128 with label differences for DWARF v5, a feature that
+# older binutils ports do not support when utilizing RISC-V style linker
+# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
+config AS_HAS_NON_CONST_ULEB128
 	def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
 
 choice
@@ -258,7 +259,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 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -283,7 +284,7 @@ config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
 	depends on !ARCH_HAS_BROKEN_DWARF5
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
 	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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
  2023-12-04 23:11               ` Nathan Chancellor
@ 2023-12-05 23:39                 ` Fangrui Song
  -1 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-05 23:39 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Mon, Dec 4, 2023 at 3:12 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Fri, Dec 01, 2023 at 08:31:12PM -0800, Fangrui Song wrote:
> > Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
> > a feature that older binutils ports, utilizing RISC-V style linker
> > relaxation, do not support.
> >
> > (Signed LEB128 is used by DWARF as well, but it is encoded directly
> > into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
> > directives are not emitted)
> > (In assemblers, "label difference" is a more common term.)
> > (People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
> > full "DWARF version 5" feels too verbose.)
>
> Thanks, does this diff seem reasonable to you? I'd like to keep the
> issue link as a paper trail and I figured that we might as well make the
> configuration name slightly more accurate with that additional
> information. I will send it as a separate patch in v2 tomorrow if so in
> order to give people a chance to further chime in on the series.
>
> Cheers,
> Nathan
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a0ebce05a368..76c2cc697573 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,9 +231,10 @@ 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
> +# Clang generates .uleb128 with label differences for DWARF v5, a feature that
> +# older binutils ports do not support when utilizing RISC-V style linker
> +# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
> +config AS_HAS_NON_CONST_ULEB128
>         def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
>
>  choice
> @@ -258,7 +259,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 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -283,7 +284,7 @@ config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
>         depends on !ARCH_HAS_BROKEN_DWARF5
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         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

This diff looks good to me.


-- 
宋方睿

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions
@ 2023-12-05 23:39                 ` Fangrui Song
  0 siblings, 0 replies; 24+ messages in thread
From: Fangrui Song @ 2023-12-05 23:39 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: paul.walmsley, palmer, aou, conor, ndesaulniers, linux-riscv,
	llvm, patches

On Mon, Dec 4, 2023 at 3:12 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Fri, Dec 01, 2023 at 08:31:12PM -0800, Fangrui Song wrote:
> > Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
> > a feature that older binutils ports, utilizing RISC-V style linker
> > relaxation, do not support.
> >
> > (Signed LEB128 is used by DWARF as well, but it is encoded directly
> > into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
> > directives are not emitted)
> > (In assemblers, "label difference" is a more common term.)
> > (People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
> > full "DWARF version 5" feels too verbose.)
>
> Thanks, does this diff seem reasonable to you? I'd like to keep the
> issue link as a paper trail and I figured that we might as well make the
> configuration name slightly more accurate with that additional
> information. I will send it as a separate patch in v2 tomorrow if so in
> order to give people a chance to further chime in on the series.
>
> Cheers,
> Nathan
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a0ebce05a368..76c2cc697573 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,9 +231,10 @@ 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
> +# Clang generates .uleb128 with label differences for DWARF v5, a feature that
> +# older binutils ports do not support when utilizing RISC-V style linker
> +# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
> +config AS_HAS_NON_CONST_ULEB128
>         def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
>
>  choice
> @@ -258,7 +259,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 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -283,7 +284,7 @@ config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
>         depends on !ARCH_HAS_BROKEN_DWARF5
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         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

This diff looks good to me.


-- 
宋方睿

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-12-05 23:40 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 23:29 [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions Nathan Chancellor
2023-11-29 23:29 ` Nathan Chancellor
2023-11-29 23:29 ` [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig Nathan Chancellor
2023-11-29 23:29   ` Nathan Chancellor
2023-11-30 16:06   ` Fangrui Song
2023-11-30 16:06     ` Fangrui Song
2023-11-29 23:29 ` [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions Nathan Chancellor
2023-11-29 23:29   ` Nathan Chancellor
2023-11-30 16:16   ` Fangrui Song
2023-11-30 16:16     ` Fangrui Song
2023-12-01 19:48     ` Nathan Chancellor
2023-12-01 19:48       ` Nathan Chancellor
2023-12-01 20:12       ` Fangrui Song
2023-12-01 20:12         ` Fangrui Song
2023-12-01 21:50         ` Nathan Chancellor
2023-12-01 21:50           ` Nathan Chancellor
2023-12-02  4:31           ` Fangrui Song
2023-12-02  4:31             ` Fangrui Song
2023-12-04 23:11             ` Nathan Chancellor
2023-12-04 23:11               ` Nathan Chancellor
2023-12-05 23:39               ` Fangrui Song
2023-12-05 23:39                 ` Fangrui Song
2023-11-30 16:03 ` [PATCH 0/2] RISC-V: Disable DWARF5 with known broken LLVM versions Fangrui Song
2023-11-30 16:03   ` Fangrui Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.