From patchwork Sun Oct 2 18:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12996877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D17A0C433FE for ; Sun, 2 Oct 2022 18:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbiJBSMQ (ORCPT ); Sun, 2 Oct 2022 14:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbiJBSMQ (ORCPT ); Sun, 2 Oct 2022 14:12:16 -0400 Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4351A815; Sun, 2 Oct 2022 11:12:14 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-10.nifty.com with ESMTP id 292IBAaC004037; Mon, 3 Oct 2022 03:11:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 292IBAaC004037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664734271; bh=j+CRdXzDCIk7h80ILGqHG4tBdM0hTFPUxyAM5SiBoS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAEivjclBA6W7LqmJhbRFutW83NUCp0xaCCbFtUdbSuNF9z5EsaFMSy2a7BK6qM4L nR/nvHbm5jQShAeZ3CdemC93qFAxhu7L/EJlFrgTQzlkU6XJTu3wTjDZnl7NIysOQX X+GmldZI3ExdcbgSqdOAxIwLohY7WAuuhFZ1TBOx0fqT0Hbg3zom2hbiGJmVAa2X58 KaAQHLjlbBXJeN5SB8eYq8GZ8pphPQrpp0e8l90jbauGsJJVMUlCkGoYUwr7pvasVh rMXQqlRgik3fqxYOqKdEGSZZkZ3U9VOqtEsIWI7rAE/+aUNwD/nITsbZXZGhQVaZ+V atpSsY0Ps/0KA== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Masahiro Yamada Subject: [PATCH 1/3] Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5 Date: Mon, 3 Oct 2022 03:11:05 +0900 Message-Id: <20221002181107.51286-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002181107.51286-1-masahiroy@kernel.org> References: <20221002181107.51286-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nathan Chancellor --- 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 From patchwork Sun Oct 2 18:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12996879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEB9CC433F5 for ; Sun, 2 Oct 2022 18:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230042AbiJBSMe (ORCPT ); Sun, 2 Oct 2022 14:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiJBSM2 (ORCPT ); Sun, 2 Oct 2022 14:12:28 -0400 Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7F4334986; Sun, 2 Oct 2022 11:12:26 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-10.nifty.com with ESMTP id 292IBAaD004037; Mon, 3 Oct 2022 03:11:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 292IBAaD004037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664734272; bh=R4t/6fMIwaYlwYPM6wHfjnpUbzkfUGo1Wg0yhRD/I3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtDj4kjXQHcvkPNqLOciJfgK9o2uMkx7+e6I20+8vFD1PFvteJhpRTtbcT9BWNlB3 vdrxJnK+my43MGIlWax/+JmVCW24W0dojt7fIadApe4vL/MMUsSxsNOKlAJfVkBERw fpaxX49lk2zK+SCWezNUM7piUTxMTKvgMg9UfpXS31o8zI9EVQqpnXySyhGU7jWfI7 VhqEuN3j+pTiGqaYjppTUR6pn6RCx4PZ4Omi0eNZioAX6P8vQM7+OJeFyvL8JiEbKV 0K0oShESbv1vSjvPK6+OqEOsMfqrNScicc7odv8y75mpRSXN6v+FyqCiHcSFtPORz7 rRLYn0fzGj7JA== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Masahiro Yamada , Tom Rix , llvm@lists.linux.dev Subject: [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Date: Mon, 3 Oct 2022 03:11:06 +0900 Message-Id: <20221002181107.51286-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002181107.51286-1-masahiroy@kernel.org> References: <20221002181107.51286-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Reviewed-by: Nathan Chancellor --- 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. From patchwork Sun Oct 2 18:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12996878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEA09C433F5 for ; Sun, 2 Oct 2022 18:12:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbiJBSMR (ORCPT ); Sun, 2 Oct 2022 14:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiJBSMQ (ORCPT ); Sun, 2 Oct 2022 14:12:16 -0400 Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A46E1ADA2; Sun, 2 Oct 2022 11:12:14 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-10.nifty.com with ESMTP id 292IBAaE004037; Mon, 3 Oct 2022 03:11:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 292IBAaE004037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664734273; bh=zCQAWimx1b0EV8M8GrWxsKCps/Q6cJmJi+PVar9Dm/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdDFG5jVelGC1W2G54sqFkE1Rm9LKIjgC3cjhbYr0KaxNvRKDDi2dn0TNiNSxXbwR YZnvecs9JMEMMdO/3FVjClheUGXHsbtKoE1ojTDBoVti91W4ZiWN9y4PxjDpALoMCf hi0wZRpuig4U91iw6KdrbSWbjaa/iKyEHVI245xubgLJz/ki1/PB4XPcyCqqRNMZyz hXuGs7/T+XozI+/UacigH5ZFFDZzaZx2VwGRaO5g1uCNQOiz1mINTnI7zQw2bF74H4 synPbEGye3IOnt02HVOHyt133v3aujCfxDzj0oJplF1fFjnjQEVymF5G3+IMJ7Ik6R RWz5XaY6YCUsQ== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Masahiro Yamada , Miguel Ojeda Subject: [PATCH 3/3] Kconfig.debug: split debug-level and DWARF-version into separate choices Date: Mon, 3 Oct 2022 03:11:07 +0900 Message-Id: <20221002181107.51286-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002181107.51286-1-masahiroy@kernel.org> References: <20221002181107.51286-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 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 Reviewed-by: Nick Desaulniers Acked-by: Miguel Ojeda Reviewed-by: Nathan Chancellor --- 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)