Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3158211rwb; Mon, 3 Oct 2022 10:28:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Z5JU+PCAOwo2sU/BK+r3gNNWZYCVXJbvOFoNkx9Ot9+3nJGJplRQFfm1GzRteHsjgt8Nn X-Received: by 2002:a17:90b:38c3:b0:205:d6b5:582d with SMTP id nn3-20020a17090b38c300b00205d6b5582dmr12762105pjb.229.1664818105927; Mon, 03 Oct 2022 10:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664818105; cv=none; d=google.com; s=arc-20160816; b=D1ivj98iIhLCwZRLq16WG5bxTyQ5bC00r8we6Nh4RXFNdqAzIrfJbv/M0P4zUSjcTh 2esKfyo+zC0+uUIzuEjB0JgVnAkw8o6Hji2jyXeflDDGqcfwcHX922THgKh2jYgmXIy3 yNOLNAyNnjCJBdshzz+ADiZrgue/VKAphj8oQs1hPIxN4S7d4BHDSq+0AT5G6hhH0GS3 m5ri/NtDALlupI9jBBRhbVX/rlSD/lCka5Vyc/O2zjBGX8VHE/LZ4czTsT6ienOTX9MH yJpNS/jjFWu/v50WkKJYi+cv3xx1LsuJCIBhIWZsLADq/WkL+E/b6bIHcOkHmmvzVvTj vyVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MuFiHVTRac+8AumL+p++clctBTZK475kXP5jbBNws7E=; b=JcbC8MZfhbbdAIUuInvQtjA5o3ttCVl6EeRD2fIE0b50y4FIFBGuN2yLx9DRISXQRK Ua5JSFJ09xTfcepVDPsGXo5Nesb/LqSbvB869oadze/2Kk8OfFIUoVBBNFM2NvICptaG Ry/4nYBgQxP3xFUvwaW3wVEddW2hMbUOQZoleQOV+Uu2sF2URVRBnyfJq+OOJxjMNnSi r2YTX5MV5GjxgeWnX/V1yox4czkOdFpRRFdcD3f2gL9bcoTT3y6ERk282znMQFmmmfoT 4KJVHcky8qqdNocaE0b9wtIzYDyk5cSSOyLzpZUhOpuSlcsReZJUXllgbt1TWLaNXZfG x1oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tRUOnk/O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jn15-20020a170903050f00b0017486813f81si10678025plb.528.2022.10.03.10.28.13; Mon, 03 Oct 2022 10:28:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tRUOnk/O"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbiJCRKW (ORCPT + 99 others); Mon, 3 Oct 2022 13:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiJCRKL (ORCPT ); Mon, 3 Oct 2022 13:10:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D81192B9; Mon, 3 Oct 2022 10:10:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F322FB811B2; Mon, 3 Oct 2022 17:10:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C41CC433D6; Mon, 3 Oct 2022 17:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664817005; bh=jrqogJN868qyHKjau9Ij3FcAorXeaYlWGK7fPCmyOzw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tRUOnk/O14dqEtGuH88iwm/y+qBbJD6alLUrOSPbQnajN0YWqLWN3yji8kYnXY0cy r1eQRcD4BwLLJ4Xl8i+w0wnlk6vFhrU/tBA7iv5NksgGv3rZbBJcPbNUgawCfzfeBv 0iJ0OYjU+F+Y7dYtcAtj35NWkeKI43BsXaP4uvYej3z2KAOOQGlSkha95/hElXG00H PZ4ND6RbRaPhR9xBeZn3+nEJurAuU8OCgl8Nnj2CHc14UfBUrOJCtYCSKybFduKdgH j/ZltU+OQwj6dtyhLUQjPy5LD+a+832dGVzDFHsNIdDS4hH2Up3+Ma3QEkN7eb5Qxt d75j0gjeu7BNg== Date: Mon, 3 Oct 2022 10:10:03 -0700 From: Nathan Chancellor To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Tom Rix , llvm@lists.linux.dev Subject: Re: [PATCH 2/3] Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT Message-ID: References: <20221002181107.51286-1-masahiroy@kernel.org> <20221002181107.51286-3-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221002181107.51286-3-masahiroy@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > > 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