All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Kconfig.debug: make more efforts to fix CONFIG_DEBUG_INFO for Clang+GAS
@ 2022-10-02 18:11 Masahiro Yamada
  2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-02 18:11 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Nick Desaulniers, Nathan Chancellor,
	Masahiro Yamada, Tom Rix, llvm




Masahiro Yamada (3):
  Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
  Kconfig.debug: add toolchain checks for
    DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  Kconfig.debug: split debug-level and DWARF-version into separate
    choices

 lib/Kconfig.debug | 62 +++++++++++++++++++++++++++++------------------
 1 file changed, 38 insertions(+), 24 deletions(-)

-- 
2.34.1


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

* [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
  2022-10-02 18:11 [PATCH 0/3] Kconfig.debug: make more efforts to fix CONFIG_DEBUG_INFO for Clang+GAS Masahiro Yamada
@ 2022-10-02 18:11 ` Masahiro Yamada
  2022-10-03 16:47   ` Nathan Chancellor
  2022-10-03 16:53   ` Nick Desaulniers
  2022-10-02 18:11 ` [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Masahiro Yamada
  2022-10-02 18:11 ` [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices Masahiro Yamada
  2 siblings, 2 replies; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-02 18:11 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Nick Desaulniers, Nathan Chancellor, Masahiro Yamada

Commit c0a5c81ca9be ("Kconfig.debug: drop GCC 5+ version check for
DWARF5") could have cleaned up the code a bit deeper.

"CC_IS_CLANG &&" is unneeded. No functional change is intended.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 lib/Kconfig.debug | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d3e5f36bb01e..f4b2165f24db 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -264,7 +264,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 config DEBUG_INFO_DWARF4
 	bool "Generate DWARF Version 4 debuginfo"
 	select DEBUG_INFO
-	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
 	help
 	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
 	  if using clang without clang's integrated assembler, and gdb 7.0+.
@@ -276,7 +276,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
-	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
+	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
 	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
-- 
2.34.1


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

* [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  2022-10-02 18:11 [PATCH 0/3] Kconfig.debug: make more efforts to fix CONFIG_DEBUG_INFO for Clang+GAS Masahiro Yamada
  2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
@ 2022-10-02 18:11 ` Masahiro Yamada
  2022-10-03 17:10   ` Nathan Chancellor
  2022-10-02 18:11 ` [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices Masahiro Yamada
  2 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-02 18:11 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Nick Desaulniers, Nathan Chancellor,
	Masahiro Yamada, Tom Rix, llvm

CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT passes the -g option to the
command line. The actual DWARF version is up to the toolchain.

The combination of GCC and GAS works fine, and Clang with the integrated
assembler is good too.

The combination of Clang and GAS is a bit tricky, but at least, the
default -g flag worked until LLVM 14 was released because Clang <=13
defaults to DWARF v4.

Clang 14 switched to DWARF v5 by default.

Now, CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT has the same issue as
addressed by commit 98cd6f521f10 ("Kconfig: allow explicit opt in to
DWARF v5").

CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y for Clang >= 14 and
GAS < 2.35 produces a ton of errors like follows:

  /tmp/main-c2741c.s: Assembler messages:
  /tmp/main-c2741c.s:109: Error: junk at end of line, first unrecognized character is `"'
  /tmp/main-c2741c.s:109: Error: file number less than one

Add 'depends on' to check toolchains.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f4b2165f24db..cc90414d492e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -253,6 +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)
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
-- 
2.34.1


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

* [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices
  2022-10-02 18:11 [PATCH 0/3] Kconfig.debug: make more efforts to fix CONFIG_DEBUG_INFO for Clang+GAS Masahiro Yamada
  2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
  2022-10-02 18:11 ` [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Masahiro Yamada
@ 2022-10-02 18:11 ` Masahiro Yamada
  2022-10-03 17:20   ` Nathan Chancellor
  2 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-02 18:11 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Nick Desaulniers, Nathan Chancellor,
	Masahiro Yamada, Miguel Ojeda

Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from
a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice,
but it should rather belong to the debug level choice.

This commit consolidates CONFIG options into two choices:

 - Debug info level (NONE / REDUCED / DEFAULT)

 - DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)

This is more consistent with compilers' policy because the -g0 compiler
flag means "no debug info".

  GCC manual:

    -g<level>

      Request debugging information and also use level to specify how
      much information. The default level is 2.

      Level 0 produces no debug information at all. Thus, -g0 negates -g.

      Level 1 produces minimal information, enough for making backtraces
      in parts of the program that you don’t plan to debug. This includes
      descriptions of functions and external variables, and line number
      tables, but no information about local variables.

      Level 3 includes extra information, such as all the macro
      definitions present in the program. Some debuggers support macro
      expansion when you use -g3.

  Rustc Codegen manual:

    debuginfo

      This flag controls the generation of debug information. It takes
      one of the following values:

      0: no debug info at all (the default).
      1: line tables only.
      2: full debug info.

I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.

This change will make it easier to add another debug info level if
necessary.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
---

 lib/Kconfig.debug | 59 +++++++++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 23 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index cc90414d492e..ce1faae1a979 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -234,15 +234,10 @@ config DEBUG_INFO
 choice
 	prompt "Debug information"
 	depends on DEBUG_KERNEL
+	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502)
 	help
 	  Selecting something other than "None" results in a kernel image
 	  that will include debugging info resulting in a larger kernel image.
-	  This adds debug symbols to the kernel and modules (gcc -g), and
-	  is needed if you intend to use kernel crashdump or binary object
-	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
-
-	  Choose which version of DWARF debug info to emit. If unsure,
-	  select "Toolchain default".
 
 config DEBUG_INFO_NONE
 	bool "Disable debug information"
@@ -250,10 +245,40 @@ config DEBUG_INFO_NONE
 	  Do not build the kernel with debugging information, which will
 	  result in a faster and smaller build.
 
+config DEBUG_INFO_REDUCED
+	bool "Reduced debugging information"
+	select DEBUG_INFO
+	help
+	  If you say Y here compiler is instructed to generate less debugging
+	  information for structure types. This means that tools that
+	  need full debugging information (like kgdb or systemtap) won't
+	  be happy. But if you merely need debugging information to
+	  resolve line numbers there is no loss. Advantage is that
+	  build directory object sizes shrink dramatically over a full
+	  DEBUG_INFO build and compile times are reduced too.
+	  Only works with newer gcc versions.
+
+config DEBUG_INFO_DEFAULT
+	bool "Default-level debugging information"
+	select DEBUG_INFO
+	help
+	  If you say Y here compiler is instructed to generate the default
+	  level of debugging information.
+
+	  This adds debug symbols to the kernel and modules (gcc -g), and
+	  is needed if you intend to use kernel crashdump or binary object
+	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
+
+endchoice # "Debug information"
+
+choice
+	prompt "DWARF version"
+	depends on DEBUG_INFO
+	help
+	  Which version of DWARF debug info to emit.
+
 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)
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -262,9 +287,10 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 	  support newer revisions, and prevent testing newer versions, but
 	  those should be less common scenarios.
 
+	  If unsure, say Y.
+
 config DEBUG_INFO_DWARF4
 	bool "Generate DWARF Version 4 debuginfo"
-	select DEBUG_INFO
 	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
 	help
 	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
@@ -276,7 +302,6 @@ config DEBUG_INFO_DWARF4
 
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
-	select DEBUG_INFO
 	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
 	help
 	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
@@ -291,22 +316,10 @@ config DEBUG_INFO_DWARF5
 	  config if they rely on tooling that has not yet been updated to
 	  support DWARF Version 5.
 
-endchoice # "Debug information"
+endchoice # "DWARF version"
 
 if DEBUG_INFO
 
-config DEBUG_INFO_REDUCED
-	bool "Reduce debugging information"
-	help
-	  If you say Y here gcc is instructed to generate less debugging
-	  information for structure types. This means that tools that
-	  need full debugging information (like kgdb or systemtap) won't
-	  be happy. But if you merely need debugging information to
-	  resolve line numbers there is no loss. Advantage is that
-	  build directory object sizes shrink dramatically over a full
-	  DEBUG_INFO build and compile times are reduced too.
-	  Only works with newer gcc versions.
-
 config DEBUG_INFO_COMPRESSED
 	bool "Compressed debugging information"
 	depends on $(cc-option,-gz=zlib)
-- 
2.34.1


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

* Re: [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
  2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
@ 2022-10-03 16:47   ` Nathan Chancellor
  2022-10-03 16:53   ` Nick Desaulniers
  1 sibling, 0 replies; 12+ messages in thread
From: Nathan Chancellor @ 2022-10-03 16:47 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Nick Desaulniers

On Mon, Oct 03, 2022 at 03:11:05AM +0900, Masahiro Yamada wrote:
> Commit c0a5c81ca9be ("Kconfig.debug: drop GCC 5+ version check for
> DWARF5") could have cleaned up the code a bit deeper.
> 
> "CC_IS_CLANG &&" is unneeded. No functional change is intended.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Good point!

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
>  lib/Kconfig.debug | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index d3e5f36bb01e..f4b2165f24db 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -264,7 +264,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>  config DEBUG_INFO_DWARF4
>  	bool "Generate DWARF Version 4 debuginfo"
>  	select DEBUG_INFO
> -	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> +	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>  	help
>  	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
>  	  if using clang without clang's integrated assembler, and gdb 7.0+.
> @@ -276,7 +276,7 @@ config DEBUG_INFO_DWARF4
>  config DEBUG_INFO_DWARF5
>  	bool "Generate DWARF Version 5 debuginfo"
>  	select DEBUG_INFO
> -	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> +	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>  	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
> -- 
> 2.34.1
> 

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

* Re: [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
  2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
  2022-10-03 16:47   ` Nathan Chancellor
@ 2022-10-03 16:53   ` Nick Desaulniers
  2022-10-03 19:56     ` Masahiro Yamada
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2022-10-03 16:53 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor

On Sun, Oct 2, 2022 at 11:11 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Commit c0a5c81ca9be ("Kconfig.debug: drop GCC 5+ version check for
> DWARF5") could have cleaned up the code a bit deeper.
>
> "CC_IS_CLANG &&" is unneeded. No functional change is intended.

This implies that there are only 2 compilers capable of building the
kernel; consider also removing
include/linux/compiler-intel.h
if ICC is no longer supported.  Otherwise, what implications does this
patch have for ICC?

>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  lib/Kconfig.debug | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index d3e5f36bb01e..f4b2165f24db 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -264,7 +264,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>  config DEBUG_INFO_DWARF4
>         bool "Generate DWARF Version 4 debuginfo"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>         help
>           Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
>           if using clang without clang's integrated assembler, and gdb 7.0+.
> @@ -276,7 +276,7 @@ config DEBUG_INFO_DWARF4
>  config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>         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
> --
> 2.34.1
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  2022-10-02 18:11 ` [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Masahiro Yamada
@ 2022-10-03 17:10   ` Nathan Chancellor
  2022-10-03 20:18     ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2022-10-03 17:10 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Tom Rix, llvm

On Mon, Oct 03, 2022 at 03:11:06AM +0900, Masahiro Yamada wrote:
> CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT passes the -g option to the
> command line. The actual DWARF version is up to the toolchain.
> 
> The combination of GCC and GAS works fine, and Clang with the integrated
> assembler is good too.
> 
> The combination of Clang and GAS is a bit tricky, but at least, the
> default -g flag worked until LLVM 14 was released because Clang <=13
> defaults to DWARF v4.
> 
> Clang 14 switched to DWARF v5 by default.
> 
> Now, CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT has the same issue as
> addressed by commit 98cd6f521f10 ("Kconfig: allow explicit opt in to
> DWARF v5").
> 
> CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y for Clang >= 14 and
> GAS < 2.35 produces a ton of errors like follows:
> 
>   /tmp/main-c2741c.s: Assembler messages:
>   /tmp/main-c2741c.s:109: Error: junk at end of line, first unrecognized character is `"'
>   /tmp/main-c2741c.s:109: Error: file number less than one
> 
> Add 'depends on' to check toolchains.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  lib/Kconfig.debug | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index f4b2165f24db..cc90414d492e 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -253,6 +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)
>  	help
>  	  The implicit default version of DWARF debug info produced by a
>  	  toolchain changes over time.
> -- 
> 2.34.1
> 
> 

Could we do something like this instead? Bikeshed the configuration
names as much as you want but we are duplicating most of this
conditional in a few different places so it would be good to consolidate
those in my opinion. Even though the DWARF4 and DWARF5 conditions are
the same, they might diverge so I think it makes sense to keep them
separate.

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index cc90414d492e..8e34a639cd40 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -231,6 +231,17 @@ config DEBUG_INFO
 	  in the "Debug information" choice below, indicating that debug
 	  information will be generated for build targets.
 
+config CC_AND_AS_SUPPORT_DWARF4
+	def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
+
+config CC_AND_AS_SUPPORT_DWARF5
+	def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
+
+config CC_AND_AS_SUPPORT_DWARF_DEFAULT
+	bool
+	default y if CC_AND_AS_SUPPORT_DWARF5 && (CLANG_VERSION >= 140000 || GCC_VERSION >= 110000)
+	default y if CC_AND_AS_SUPPORT_DWARF4 && (CLANG_VERSION < 140000 || GCC_VERSION < 110000)
+
 choice
 	prompt "Debug information"
 	depends on DEBUG_KERNEL
@@ -253,7 +264,7 @@ config DEBUG_INFO_NONE
 config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 	bool "Rely on the toolchain's implicit default DWARF version"
 	select DEBUG_INFO
-	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502)
+	depends on CC_AND_AS_SUPPORT_DWARF_DEFAULT
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -265,7 +276,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 config DEBUG_INFO_DWARF4
 	bool "Generate DWARF Version 4 debuginfo"
 	select DEBUG_INFO
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
+	depends on CC_AND_AS_SUPPORT_DWARF4
 	help
 	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
 	  if using clang without clang's integrated assembler, and gdb 7.0+.
@@ -277,7 +288,7 @@ config DEBUG_INFO_DWARF4
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
 	select DEBUG_INFO
-	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
+	depends on CC_AND_AS_SUPPORT_DWARF5
 	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] 12+ messages in thread

* Re: [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices
  2022-10-02 18:11 ` [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices Masahiro Yamada
@ 2022-10-03 17:20   ` Nathan Chancellor
  2022-10-03 20:58     ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2022-10-03 17:20 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Miguel Ojeda

On Mon, Oct 03, 2022 at 03:11:07AM +0900, Masahiro Yamada wrote:
> Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from
> a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice,
> but it should rather belong to the debug level choice.
> 
> This commit consolidates CONFIG options into two choices:
> 
>  - Debug info level (NONE / REDUCED / DEFAULT)
> 
>  - DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)
> 
> This is more consistent with compilers' policy because the -g0 compiler
> flag means "no debug info".
> 
>   GCC manual:
> 
>     -g<level>
> 
>       Request debugging information and also use level to specify how
>       much information. The default level is 2.
> 
>       Level 0 produces no debug information at all. Thus, -g0 negates -g.
> 
>       Level 1 produces minimal information, enough for making backtraces
>       in parts of the program that you don’t plan to debug. This includes
>       descriptions of functions and external variables, and line number
>       tables, but no information about local variables.
> 
>       Level 3 includes extra information, such as all the macro
>       definitions present in the program. Some debuggers support macro
>       expansion when you use -g3.
> 
>   Rustc Codegen manual:
> 
>     debuginfo
> 
>       This flag controls the generation of debug information. It takes
>       one of the following values:
> 
>       0: no debug info at all (the default).
>       1: line tables only.
>       2: full debug info.
> 
> I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.
> 
> This change will make it easier to add another debug info level if
> necessary.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>

As far as I can tell, this will require updating defconfigs again to
include an explicit 'CONFIG_DEBUG_INFO_DEFAULT=y', right? It might be
nice to do that as part of this change to keep everything working, as
there was some fallout from the last time:

92f89ec1b534 ("powerpc: Restore CONFIG_DEBUG_INFO in defconfigs")
ddd366bf01de ("ARM: defconfig: address renamed CONFIG_DEBUG_INFO=y")

Regardless, I think this is a good change.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
>  lib/Kconfig.debug | 59 +++++++++++++++++++++++++++++------------------
>  1 file changed, 36 insertions(+), 23 deletions(-)
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index cc90414d492e..ce1faae1a979 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -234,15 +234,10 @@ config DEBUG_INFO
>  choice
>  	prompt "Debug information"
>  	depends on DEBUG_KERNEL
> +	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502)
>  	help
>  	  Selecting something other than "None" results in a kernel image
>  	  that will include debugging info resulting in a larger kernel image.
> -	  This adds debug symbols to the kernel and modules (gcc -g), and
> -	  is needed if you intend to use kernel crashdump or binary object
> -	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
> -
> -	  Choose which version of DWARF debug info to emit. If unsure,
> -	  select "Toolchain default".
>  
>  config DEBUG_INFO_NONE
>  	bool "Disable debug information"
> @@ -250,10 +245,40 @@ config DEBUG_INFO_NONE
>  	  Do not build the kernel with debugging information, which will
>  	  result in a faster and smaller build.
>  
> +config DEBUG_INFO_REDUCED
> +	bool "Reduced debugging information"
> +	select DEBUG_INFO
> +	help
> +	  If you say Y here compiler is instructed to generate less debugging
> +	  information for structure types. This means that tools that
> +	  need full debugging information (like kgdb or systemtap) won't
> +	  be happy. But if you merely need debugging information to
> +	  resolve line numbers there is no loss. Advantage is that
> +	  build directory object sizes shrink dramatically over a full
> +	  DEBUG_INFO build and compile times are reduced too.
> +	  Only works with newer gcc versions.
> +
> +config DEBUG_INFO_DEFAULT
> +	bool "Default-level debugging information"
> +	select DEBUG_INFO
> +	help
> +	  If you say Y here compiler is instructed to generate the default
> +	  level of debugging information.
> +
> +	  This adds debug symbols to the kernel and modules (gcc -g), and
> +	  is needed if you intend to use kernel crashdump or binary object
> +	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
> +
> +endchoice # "Debug information"
> +
> +choice
> +	prompt "DWARF version"
> +	depends on DEBUG_INFO
> +	help
> +	  Which version of DWARF debug info to emit.
> +
>  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)
>  	help
>  	  The implicit default version of DWARF debug info produced by a
>  	  toolchain changes over time.
> @@ -262,9 +287,10 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>  	  support newer revisions, and prevent testing newer versions, but
>  	  those should be less common scenarios.
>  
> +	  If unsure, say Y.
> +
>  config DEBUG_INFO_DWARF4
>  	bool "Generate DWARF Version 4 debuginfo"
> -	select DEBUG_INFO
>  	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>  	help
>  	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
> @@ -276,7 +302,6 @@ config DEBUG_INFO_DWARF4
>  
>  config DEBUG_INFO_DWARF5
>  	bool "Generate DWARF Version 5 debuginfo"
> -	select DEBUG_INFO
>  	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
>  	help
>  	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
> @@ -291,22 +316,10 @@ config DEBUG_INFO_DWARF5
>  	  config if they rely on tooling that has not yet been updated to
>  	  support DWARF Version 5.
>  
> -endchoice # "Debug information"
> +endchoice # "DWARF version"
>  
>  if DEBUG_INFO
>  
> -config DEBUG_INFO_REDUCED
> -	bool "Reduce debugging information"
> -	help
> -	  If you say Y here gcc is instructed to generate less debugging
> -	  information for structure types. This means that tools that
> -	  need full debugging information (like kgdb or systemtap) won't
> -	  be happy. But if you merely need debugging information to
> -	  resolve line numbers there is no loss. Advantage is that
> -	  build directory object sizes shrink dramatically over a full
> -	  DEBUG_INFO build and compile times are reduced too.
> -	  Only works with newer gcc versions.
> -
>  config DEBUG_INFO_COMPRESSED
>  	bool "Compressed debugging information"
>  	depends on $(cc-option,-gz=zlib)
> -- 
> 2.34.1
> 

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

* Re: [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
  2022-10-03 16:53   ` Nick Desaulniers
@ 2022-10-03 19:56     ` Masahiro Yamada
  0 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-03 19:56 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor

On Tue, Oct 4, 2022 at 1:53 AM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Sun, Oct 2, 2022 at 11:11 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Commit c0a5c81ca9be ("Kconfig.debug: drop GCC 5+ version check for
> > DWARF5") could have cleaned up the code a bit deeper.
> >
> > "CC_IS_CLANG &&" is unneeded. No functional change is intended.
>
> This implies that there are only 2 compilers capable of building the
> kernel; consider also removing
> include/linux/compiler-intel.h
> if ICC is no longer supported.  Otherwise, what implications does this
> patch have for ICC?




I am just doing logical simplification in general.

When A and B are bool,

   !A || (A && B)

is always redundant.
It can be simplified into

   !A || B



So, this patch is irrelevant to the presence of the third compiler, ICC.

Such an implication happened in commit c0a5c81ca9be.
When you dropped GCC 5+ check, you converted
"GCC_VERSION >= 50000" into "!CC_IS_CLANG" instead of "CC_IS_GCC".


"CC_IS_GCC" and "!CC_IS_CLANG" are not equivalent,
but a lot of code already expects that, and nobody asked
"We have the third compiler, so do we need CC_IS_ICC?"



I agree that we can drop ICC support, but I want to
point out that ICC is DON'T_CARE to my patch.








> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  lib/Kconfig.debug | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index d3e5f36bb01e..f4b2165f24db 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -264,7 +264,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> >  config DEBUG_INFO_DWARF4
> >         bool "Generate DWARF Version 4 debuginfo"
> >         select DEBUG_INFO
> > -       depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> >         help
> >           Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
> >           if using clang without clang's integrated assembler, and gdb 7.0+.
> > @@ -276,7 +276,7 @@ config DEBUG_INFO_DWARF4
> >  config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> > -       depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> > +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> >         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
> > --
> > 2.34.1
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  2022-10-03 17:10   ` Nathan Chancellor
@ 2022-10-03 20:18     ` Masahiro Yamada
  2022-10-03 20:32       ` Nathan Chancellor
  0 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-03 20:18 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Tom Rix, llvm

On Tue, Oct 4, 2022 at 2:10 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Mon, Oct 03, 2022 at 03:11:06AM +0900, Masahiro Yamada wrote:
> > CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT passes the -g option to the
> > command line. The actual DWARF version is up to the toolchain.
> >
> > The combination of GCC and GAS works fine, and Clang with the integrated
> > assembler is good too.
> >
> > The combination of Clang and GAS is a bit tricky, but at least, the
> > default -g flag worked until LLVM 14 was released because Clang <=13
> > defaults to DWARF v4.
> >
> > Clang 14 switched to DWARF v5 by default.
> >
> > Now, CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT has the same issue as
> > addressed by commit 98cd6f521f10 ("Kconfig: allow explicit opt in to
> > DWARF v5").
> >
> > CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y for Clang >= 14 and
> > GAS < 2.35 produces a ton of errors like follows:
> >
> >   /tmp/main-c2741c.s: Assembler messages:
> >   /tmp/main-c2741c.s:109: Error: junk at end of line, first unrecognized character is `"'
> >   /tmp/main-c2741c.s:109: Error: file number less than one
> >
> > Add 'depends on' to check toolchains.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  lib/Kconfig.debug | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index f4b2165f24db..cc90414d492e 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -253,6 +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)
> >       help
> >         The implicit default version of DWARF debug info produced by a
> >         toolchain changes over time.
> > --
> > 2.34.1
> >
> >
>
> Could we do something like this instead? Bikeshed the configuration
> names as much as you want but we are duplicating most of this
> conditional in a few different places so it would be good to consolidate
> those in my opinion. Even though the DWARF4 and DWARF5 conditions are
> the same, they might diverge so I think it makes sense to keep them
> separate.
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index cc90414d492e..8e34a639cd40 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,6 +231,17 @@ config DEBUG_INFO
>           in the "Debug information" choice below, indicating that debug
>           information will be generated for build targets.
>
> +config CC_AND_AS_SUPPORT_DWARF4
> +       def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> +
> +config CC_AND_AS_SUPPORT_DWARF5
> +       def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> +
> +config CC_AND_AS_SUPPORT_DWARF_DEFAULT
> +       bool
> +       default y if CC_AND_AS_SUPPORT_DWARF5 && (CLANG_VERSION >= 140000 || GCC_VERSION >= 110000)
> +       default y if CC_AND_AS_SUPPORT_DWARF4 && (CLANG_VERSION < 140000 || GCC_VERSION < 110000)


No, this is an overkill.




In my patch, you can enable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
for the combination of:
    CC_IS_CLANG=y
    CLANG_VERSION < 140000
    AS_IS_GNU=y
    AS_VERSION < 23502

But, your code disallows it.

You are requiring binutils 2.35.2 for Clang+GAS, but
it is not necessary.







>  choice
>         prompt "Debug information"
>         depends on DEBUG_KERNEL
> @@ -253,7 +264,7 @@ config DEBUG_INFO_NONE
>  config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>         bool "Rely on the toolchain's implicit default DWARF version"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502)
> +       depends on CC_AND_AS_SUPPORT_DWARF_DEFAULT
>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -265,7 +276,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>  config DEBUG_INFO_DWARF4
>         bool "Generate DWARF Version 4 debuginfo"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> +       depends on CC_AND_AS_SUPPORT_DWARF4
>         help
>           Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
>           if using clang without clang's integrated assembler, and gdb 7.0+.
> @@ -277,7 +288,7 @@ config DEBUG_INFO_DWARF4
>  config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> +       depends on CC_AND_AS_SUPPORT_DWARF5
>         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



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
  2022-10-03 20:18     ` Masahiro Yamada
@ 2022-10-03 20:32       ` Nathan Chancellor
  0 siblings, 0 replies; 12+ messages in thread
From: Nathan Chancellor @ 2022-10-03 20:32 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Tom Rix, llvm

On Tue, Oct 04, 2022 at 05:18:49AM +0900, Masahiro Yamada wrote:
> On Tue, Oct 4, 2022 at 2:10 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > On Mon, Oct 03, 2022 at 03:11:06AM +0900, Masahiro Yamada wrote:
> > > CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT passes the -g option to the
> > > command line. The actual DWARF version is up to the toolchain.
> > >
> > > The combination of GCC and GAS works fine, and Clang with the integrated
> > > assembler is good too.
> > >
> > > The combination of Clang and GAS is a bit tricky, but at least, the
> > > default -g flag worked until LLVM 14 was released because Clang <=13
> > > defaults to DWARF v4.
> > >
> > > Clang 14 switched to DWARF v5 by default.
> > >
> > > Now, CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT has the same issue as
> > > addressed by commit 98cd6f521f10 ("Kconfig: allow explicit opt in to
> > > DWARF v5").
> > >
> > > CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y for Clang >= 14 and
> > > GAS < 2.35 produces a ton of errors like follows:
> > >
> > >   /tmp/main-c2741c.s: Assembler messages:
> > >   /tmp/main-c2741c.s:109: Error: junk at end of line, first unrecognized character is `"'
> > >   /tmp/main-c2741c.s:109: Error: file number less than one
> > >
> > > Add 'depends on' to check toolchains.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> > >
> > >  lib/Kconfig.debug | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > index f4b2165f24db..cc90414d492e 100644
> > > --- a/lib/Kconfig.debug
> > > +++ b/lib/Kconfig.debug
> > > @@ -253,6 +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)
> > >       help
> > >         The implicit default version of DWARF debug info produced by a
> > >         toolchain changes over time.
> > > --
> > > 2.34.1
> > >
> > >
> >
> > Could we do something like this instead? Bikeshed the configuration
> > names as much as you want but we are duplicating most of this
> > conditional in a few different places so it would be good to consolidate
> > those in my opinion. Even though the DWARF4 and DWARF5 conditions are
> > the same, they might diverge so I think it makes sense to keep them
> > separate.
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index cc90414d492e..8e34a639cd40 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -231,6 +231,17 @@ config DEBUG_INFO
> >           in the "Debug information" choice below, indicating that debug
> >           information will be generated for build targets.
> >
> > +config CC_AND_AS_SUPPORT_DWARF4
> > +       def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> > +
> > +config CC_AND_AS_SUPPORT_DWARF5
> > +       def_bool !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> > +
> > +config CC_AND_AS_SUPPORT_DWARF_DEFAULT
> > +       bool
> > +       default y if CC_AND_AS_SUPPORT_DWARF5 && (CLANG_VERSION >= 140000 || GCC_VERSION >= 110000)
> > +       default y if CC_AND_AS_SUPPORT_DWARF4 && (CLANG_VERSION < 140000 || GCC_VERSION < 110000)
> 
> 
> No, this is an overkill.
> 
> In my patch, you can enable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> for the combination of:
>     CC_IS_CLANG=y
>     CLANG_VERSION < 140000
>     AS_IS_GNU=y
>     AS_VERSION < 23502
> 
> But, your code disallows it.
> 
> You are requiring binutils 2.35.2 for Clang+GAS, but
> it is not necessary.

Ah, I figured that part was necessary because of the condition added to
CONFIG_DEBUG_INFO_DWARF4 by commit 32ef9e5054ec ("Makefile.debug:
re-enable debug info for .S files") but I see now that was because of
some binutils behavior that you pointed out on Nick's v2 of that change,
which I failed to pay attention to because I had already reviewed the
change and did not read subsequent reviews/revisions as I should have,
so my apologies.

https://lore.kernel.org/CAK7LNATWDH01=ZKLnsxc0vcib1zGDbEq8jLQwhWP7HkkmSb_Mw@mail.gmail.com/

Regardless, I still think the duplication in these conditions is
unfortunate and I would like to see it cleaned up in some way but I
don't have a strong opinion on the matter. To the original change:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

Once these are applied to linux-kbuild, I will send a v2 of my RISC-V
fix.

> >  choice
> >         prompt "Debug information"
> >         depends on DEBUG_KERNEL
> > @@ -253,7 +264,7 @@ config DEBUG_INFO_NONE
> >  config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> >         bool "Rely on the toolchain's implicit default DWARF version"
> >         select DEBUG_INFO
> > -       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502)
> > +       depends on CC_AND_AS_SUPPORT_DWARF_DEFAULT
> >         help
> >           The implicit default version of DWARF debug info produced by a
> >           toolchain changes over time.
> > @@ -265,7 +276,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> >  config DEBUG_INFO_DWARF4
> >         bool "Generate DWARF Version 4 debuginfo"
> >         select DEBUG_INFO
> > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> > +       depends on CC_AND_AS_SUPPORT_DWARF4
> >         help
> >           Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
> >           if using clang without clang's integrated assembler, and gdb 7.0+.
> > @@ -277,7 +288,7 @@ config DEBUG_INFO_DWARF4
> >  config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> > -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
> > +       depends on CC_AND_AS_SUPPORT_DWARF5
> >         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
> 
> 
> 
> -- 
> Best Regards
> Masahiro Yamada

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

* Re: [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices
  2022-10-03 17:20   ` Nathan Chancellor
@ 2022-10-03 20:58     ` Masahiro Yamada
  0 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2022-10-03 20:58 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Miguel Ojeda

On Tue, Oct 4, 2022 at 2:20 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Mon, Oct 03, 2022 at 03:11:07AM +0900, Masahiro Yamada wrote:
> > Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from
> > a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice,
> > but it should rather belong to the debug level choice.
> >
> > This commit consolidates CONFIG options into two choices:
> >
> >  - Debug info level (NONE / REDUCED / DEFAULT)
> >
> >  - DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)
> >
> > This is more consistent with compilers' policy because the -g0 compiler
> > flag means "no debug info".
> >
> >   GCC manual:
> >
> >     -g<level>
> >
> >       Request debugging information and also use level to specify how
> >       much information. The default level is 2.
> >
> >       Level 0 produces no debug information at all. Thus, -g0 negates -g.
> >
> >       Level 1 produces minimal information, enough for making backtraces
> >       in parts of the program that you don’t plan to debug. This includes
> >       descriptions of functions and external variables, and line number
> >       tables, but no information about local variables.
> >
> >       Level 3 includes extra information, such as all the macro
> >       definitions present in the program. Some debuggers support macro
> >       expansion when you use -g3.
> >
> >   Rustc Codegen manual:
> >
> >     debuginfo
> >
> >       This flag controls the generation of debug information. It takes
> >       one of the following values:
> >
> >       0: no debug info at all (the default).
> >       1: line tables only.
> >       2: full debug info.
> >
> > I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.
> >
> > This change will make it easier to add another debug info level if
> > necessary.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > Acked-by: Miguel Ojeda <ojeda@kernel.org>
>
> As far as I can tell, this will require updating defconfigs again to
> include an explicit 'CONFIG_DEBUG_INFO_DEFAULT=y', right? It might be
> nice to do that as part of this change to keep everything working, as
> there was some fallout from the last time:
>
> 92f89ec1b534 ("powerpc: Restore CONFIG_DEBUG_INFO in defconfigs")
> ddd366bf01de ("ARM: defconfig: address renamed CONFIG_DEBUG_INFO=y")
>
> Regardless, I think this is a good change.


Thanks.

I will do that in v2.









-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2022-10-03 20:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 18:11 [PATCH 0/3] Kconfig.debug: make more efforts to fix CONFIG_DEBUG_INFO for Clang+GAS Masahiro Yamada
2022-10-02 18:11 ` [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Masahiro Yamada
2022-10-03 16:47   ` Nathan Chancellor
2022-10-03 16:53   ` Nick Desaulniers
2022-10-03 19:56     ` Masahiro Yamada
2022-10-02 18:11 ` [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Masahiro Yamada
2022-10-03 17:10   ` Nathan Chancellor
2022-10-03 20:18     ` Masahiro Yamada
2022-10-03 20:32       ` Nathan Chancellor
2022-10-02 18:11 ` [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices Masahiro Yamada
2022-10-03 17:20   ` Nathan Chancellor
2022-10-03 20:58     ` Masahiro Yamada

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.