Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1191078rwb; Wed, 28 Sep 2022 14:43:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45oRAfUr3BoQpA1trKHs8dqktfXda1HigSvX48Vcn8l4bD3RjffmEJ2hdga+iLuQPhNxBI X-Received: by 2002:a63:4750:0:b0:43c:dac:9e4b with SMTP id w16-20020a634750000000b0043c0dac9e4bmr31081067pgk.300.1664401394459; Wed, 28 Sep 2022 14:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664401394; cv=none; d=google.com; s=arc-20160816; b=S+VzzjbI5qw1x7Ew7Zo1m5fkQn26fby5Qd5TqbrWn7Yzqh2pXiBOR4fBZAPgPDDSDQ zcYrLjRS3DzwSJIZMm7TAR7zlGn28VmNs9svb9YKAjlh35rTButqP/k+5uYA5pbYzmtl pQu0GmJKOwLlH1bKovctSM8zGbBP6G6oFrUzGb4VSk9SNpWferwl/MSc9gV/YHUoTzdi V81JkEFpwIFFj6FW7NQ8A/t7PQer6wjc42XeH0+u7+y2rYD1WjJ5B2iSx4OM0Fz38/JZ pp/od2jzKWEhQIWL+gHDNGozQezGwq4rR2kv8gsW/fs9Uhdhs4M9FbFq1WGLwtWGGHBN IiWA== 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=xz0sXl216A+rpOebqGDowLJDpg8OJnVV28wKop+ATlA=; b=CQd52EwVR0YLsX3z99EJSl0GLika7gR+HS9DvKRZHMOTb2eXAujSUFsAoXlnp7tfXe 6y1rP/owtebUtzwQVk4BB0rNY9qHbK3jNJ/dC89NU5f6wkodp1qJX2PrjtDctPrjI+WN e6yY+tW8qmEYHb3qiYiTScqYZafd6dC6NMIcKhgBnpydGlgDgedHRjEOLdjohJrBlKN1 FpJdnUgByAM411Frn5G/jQo2c3y9DNUGMW+MF2WBynnbHZqjCQM6bUbBnOC8qE3jEy4v 8mk39XxDLJZGs0TkQrHzUYPxbcpGZ6ecNoALd8S/VNz7OPAp6Zb25bAgpnZi+NZXync1 AH1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pyeKR7S/"; 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 lp6-20020a17090b4a8600b001fafaf2e8fesi3657773pjb.104.2022.09.28.14.43.03; Wed, 28 Sep 2022 14:43:14 -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="pyeKR7S/"; 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 S234174AbiI1Vgw (ORCPT + 99 others); Wed, 28 Sep 2022 17:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233335AbiI1Vgu (ORCPT ); Wed, 28 Sep 2022 17:36:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF357D792; Wed, 28 Sep 2022 14:36:49 -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 DF63261FE5; Wed, 28 Sep 2022 21:36:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EF29C433D6; Wed, 28 Sep 2022 21:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664401008; bh=aT8rvgKz7c6G4ZCSZioQYbTyzSYZAZy9hqJAzraHnDw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pyeKR7S/R81B3srxAHth1JOo3X7zSYqY8N6htG5l86xMIqsG+133M1R+lTz9khsSS g+FUDoxyGX0HE0mNKz9+ds4kQAtixk4nDn3iDmWRG7jiBT3sekVpZVvkZmfSVVRDhF SxGIMTuAOpgiBgUEm+h4UzLY0xiUnyGFsS+CH1f+xUPar9f/Eo+yRuNJBpX2cQvYAO +WiSn5R0QGqBCEb1N0eUlK9UBUYFbzn8Gca2h9jT2otSQKTjjrLExrmiHUn5laPk+Q hBWuum5xeZ05/rSYc0pb2i/m0JsadNWBx52uQgU6ZdG1nPNB5Z0BYT73pGo3ejVrs+ 07MSrfM+JiP9Q== Date: Wed, 28 Sep 2022 14:36:45 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Andrew Morton , Masahiro Yamada , 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.2 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 Wed, Sep 28, 2022 at 02:13:47PM -0700, Nick Desaulniers wrote: > On Wed, Sep 28, 2022 at 11: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 > > + depends on !CC_IS_CLANG || AS_HAS_NON_CONST_LEB128 > > Reraising my concern from > https://github.com/ClangBuiltLinux/linux/issues/1719#issuecomment-1258678969 Sorry, I thought I addressed your concern with my comment right below it but I probably should have worded it better. > We've put a fair amount of work into getting CC=clang LLVM_IAS=0 to > work for DWARF v5 (both on the GNU binutils side, and Kbuild), I'd > hate to see that effectively knee-capped because of an issue in GNU > binutils that is only relevant for one architecture. Sure, that is a completely reasonable concern. However... > I'd concede support for ARCH=riscv, but not for all other > architectures, which this effectively does. No, it does not, CONFIG_AS_HAS_NON_CONST_LEB128 can still be enabled when GNU as supports this construct for a particular architecture; as far as I can tell, RISC-V is the only one that doesn't. See the tests with ARCH=arm64 and ARCH=x86_64 compared with ARCH=riscv below. $ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 LLVM_IAS=0 defconfig $ rg "CONFIG_AS_(IS|VERSION|HAS)" .config 9:CONFIG_AS_IS_GNU=y 10:CONFIG_AS_VERSION=23950 4750:CONFIG_AS_HAS_NON_CONST_LEB128=y $ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=0 defconfig $ rg "CONFIG_AS_(IS|VERSION|HAS)" .config 9:CONFIG_AS_IS_GNU=y 10:CONFIG_AS_VERSION=23950 442:CONFIG_AS_HAS_LDAPR=y 443:CONFIG_AS_HAS_LSE_ATOMICS=y 451:CONFIG_AS_HAS_ARMV8_2=y 452:CONFIG_AS_HAS_SHA3=y 465:CONFIG_AS_HAS_PAC=y 466:CONFIG_AS_HAS_CFI_NEGATE_RA_STATE=y 473:CONFIG_AS_HAS_ARMV8_4=y 480:CONFIG_AS_HAS_ARMV8_5=y 9719:CONFIG_AS_HAS_NON_CONST_LEB128=y $ make -skj"$(nproc)" ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- LLVM=1 LLVM_IAS=0 defconfig $ rg "CONFIG_AS_(IS|VERSION|HAS)" .config 9:CONFIG_AS_IS_GNU=y 10:CONFIG_AS_VERSION=23950 Cheers, Nathan