Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3075202rwb; Mon, 3 Oct 2022 09:18:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ANsxq2ZF+E6KQdq/ZNVLJntS42iey5RZO7tfdl+Oiu+rtbT7dYADgfCODxnITO+hSlOyG X-Received: by 2002:a17:906:7304:b0:6ff:a76:5b09 with SMTP id di4-20020a170906730400b006ff0a765b09mr15383613ejc.193.1664813914935; Mon, 03 Oct 2022 09:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664813914; cv=none; d=google.com; s=arc-20160816; b=05HXDzBfiUVgKrePIbVF1QiCif0p2Bhu6RWAOwius0IGd6Od5M6zIY737DQJO+tU4p mTNInawEJVsuA8JfXctUui5vhvqPJozUnka4KgRSO37cROw2OuG9mENhwcuHJbt15P4v wOqFLU4fsDQmSWlCEGD+qmNQhcKRn0VhxmO7hVjltyUnbn4s0O09B1LWvYrS70LEP2+3 hWJ7RVludHhqACJdrWTM0i45AipWNSBn++bBkl1fB5z7dYNvHgUpPzUH5FdIg/ymjTMC 1BGto4+RT/mCCSK85m+yfjATU5vQ7TapjjsU9OsCVgI+nvk3UB2Q1tcNs60/sMinzS7N zGSA== 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=/0nIbpA+qRK8j5q8Y4Vrs1iohp5AeLZjaPDdi7ft7/M=; b=HYUB8dxqgDh5frGtQvNd5VPQ7aI/JrIou/xVWdAQN7lepWhkNbSu/vovq6az7XJ4py 8NNv65HcRR443BxOJEnuzCZliBMZO9AqFHWEprasu0xQInfSP4cJzEOUhdD9/w8pdC7w ehJVPd62nGS4HePOpVeZQCWQJxWnTycgKl72z4FKatVf4IQx7LZ9kZhBnvYvr/g8CkC3 VfHbm4Ki4yKiO3pQ2FwTQ20NU8sK4ECO6Fr5hcnse6jABzRXnhGXcbrqQoRwnz6sr3d/ Hb/PpPV9bcFRBrpd778nX3/p20uVgq7D9YEpVaQGbRYkotmTSjHkpchZq2cVFVWAuXK3 ck5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VqLI6a7L; 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 z1-20020a1709060ac100b007825892f9edsi7665089ejf.656.2022.10.03.09.18.09; Mon, 03 Oct 2022 09:18:34 -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=VqLI6a7L; 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 S229733AbiJCQK7 (ORCPT + 99 others); Mon, 3 Oct 2022 12:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbiJCQK4 (ORCPT ); Mon, 3 Oct 2022 12:10:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0DF2C65D; Mon, 3 Oct 2022 09:10:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8CA7D61137; Mon, 3 Oct 2022 16:10:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AC1EC433D6; Mon, 3 Oct 2022 16:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664813454; bh=VNuWSL+WeJYDCChgOKB7QTNXhZXJ1iCWHHhQoDC15/M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VqLI6a7LmhNtbdijFB574BY8yHNZT2SmoFuyIHKCkvsfY38pwiC3Ce5QzLG/WTVhP qb0hCuXYC3l0JlnLOLUKnZjyR2su6ycCNigHzT32/3wBUmppA/Qu1Nl0BJQwB5nsHh AHvOt8msRJuAaPfYDrWBxc9pLIcodATPpBaUuB6zOjRcCaezSifnZRNk3yt76p1yIP oueDYo4LvY9nK1pG1owc6Fg6N2CYI1sge37kw44oCzHatb08SnmTDXvu5z4QBj1uRD Zq1vnspuDlFkemOqNq7zTqbMtI7m5jQCI1rVj77qevdHd14ng04Cj3m1mUHYtl04UO i1aENRviLNfCw== Date: Mon, 3 Oct 2022 09:10:51 -0700 From: Nathan Chancellor To: Masahiro Yamada Cc: Andrew Morton , Nick Desaulniers , Tom Rix , Palmer Dabbelt , linux-kbuild@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, llvm@lists.linux.dev, Conor Dooley Subject: Re: [PATCH] lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5 Message-ID: References: <20220928182523.3105953-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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:47:30AM +0900, Masahiro Yamada wrote: > On Thu, Sep 29, 2022 at 3:25 AM Nathan Chancellor wrote: > > > > When building with a RISC-V kernel with DWARF5 debug info using clang > > and the GNU assembler, several instances of the following error appear: > > > > /tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supported > > > > Dumping the .s file reveals these .uleb128 directives come from > > .debug_loc and .debug_ranges: > > > > .Ldebug_loc0: > > .byte 4 # DW_LLE_offset_pair > > .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset > > .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset > > .byte 1 # Loc expr size > > .byte 90 # DW_OP_reg10 > > .byte 0 # DW_LLE_end_of_list > > > > .Ldebug_ranges0: > > .byte 4 # DW_RLE_offset_pair > > .uleb128 .Ltmp6-.Lfunc_begin0 # starting offset > > .uleb128 .Ltmp27-.Lfunc_begin0 # ending offset > > .byte 4 # DW_RLE_offset_pair > > .uleb128 .Ltmp28-.Lfunc_begin0 # starting offset > > .uleb128 .Ltmp30-.Lfunc_begin0 # ending offset > > .byte 0 # DW_RLE_end_of_list > > > > There is an outstanding binutils issue to support a non-constant operand > > to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to > > be any movement on it, due to concerns over how it would work with > > linker relaxation. > > > > To avoid these build errors, prevent DWARF5 from being selected when > > using clang and an assembler that does not have support for these symbol > > deltas, which can be easily checked in Kconfig with as-instr plus the > > small test program from the dwz test suite from the binutils issue. > > > > Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27215 > > Link: https://github.com/ClangBuiltLinux/linux/issues/1719 > > Tested-by: Conor Dooley > > Signed-off-by: Nathan Chancellor > > --- > > lib/Kconfig.debug | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index d3e5f36bb01e..19de03ead2ed 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -231,6 +231,9 @@ config DEBUG_INFO > > in the "Debug information" choice below, indicating that debug > > information will be generated for build targets. > > > > +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 > > @@ -277,6 +280,10 @@ 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))) > > + # 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 > > If you plan to patch both DWARF_TOOLCHAIN_DEFAULT and DWARF5, > it will be cleaner to move this comment to AS_HAS_NON_CONST_LEB128. Sure, that sounds reasonable! I can base this change on the series that you recently sent: https://lore.kernel.org/20221002181107.51286-1-masahiroy@kernel.org/ > > + depends on !CC_IS_CLANG || AS_HAS_NON_CONST_LEB128 > > The condition "!CC_IS_CLANG" is repeated here. > > If you use the following patch as basic, > https://lore.kernel.org/lkml/20221002181107.51286-2-masahiroy@kernel.org/T/#u > > you can write the code like this: > > !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && > AS_HAS_NON_CONST_LEB128) Right, I had initially had something along this line but the length of the line bothered some folks in pre-review so I opted for a second line. With your clean ups, it seems reasonable to move it back to the original line. > Another big hammer solution is to give up Clang+GAS for CONFIG_DEBUG_INFO. > If we go this way, this patch is unneeded, though. > Thoughts? I think this is a simple enough solution to avoid that big hammer at the moment but if we continue to run into corner cases like this, that is certainly worth considering. Cheers, Nathan