Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2004083rwb; Sun, 2 Oct 2022 12:36:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6foH1OUN6rU7aGkMgnxegrkdvW4X6+VAQ/UBrqQmrZ7AzjUWkPMBxyI0rYe6S8jjONvY0Z X-Received: by 2002:a17:907:7204:b0:783:e152:f1f1 with SMTP id dr4-20020a170907720400b00783e152f1f1mr13477060ejc.119.1664739399762; Sun, 02 Oct 2022 12:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664739399; cv=none; d=google.com; s=arc-20160816; b=FF2c0Vg0tGHBl082lqsJboqEAUVyu0cMy28c+z9VtfLylCX8xtoirUMkTQ24FdyZcn y3HnlsZmrX6wNVqVA3tqt48i9/IiREalBqDwpMezpos6o2kYkdLpAIem3FyMDq8iWz1C ODLXFPtLvWhtWglu4K6HM3Fiw6Naf3fR35C59C/AB2pu/eR1M5T0Wgca1W8PFVqmikkA joYpgdNKl6v/PGJ1bTl2d3PrWmiA8P6F2W8WFVCnEp0mGFyz+jlfQ9CVhGuevycoY93G xS0Bth0tp2kSwcIlN6kaWykSIbR/sOHGNDU1/XBjOFJ8ZKi+GgnG2t+rJra/564464O4 Bpqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=TRjUcYAKDUQUfOl2UzVa5Db91m2ohyT00gg0PveXTJw=; b=JQYVxkRD2SLc1qIyH609aK8zQYEwY1aYq4u9SD2aGHDkuRXMmshSwAt+faKC4SY101 M17wUG91XGNqYcNQii02flE/56Wsjg03uS0fDfiVmPwizaP3RzjW50nY+/UsxUxQcb2a SKsievCtBnF6QARWZqfQf+ZRta2Z9R+BHvEnTf4zsVbunsLV+x9qxWnOqBWKi4svC+vd vDpivAgH6eVcQ9TwKbtoJdfAfDRVc83SPI2syk5qln6mG5N8/x+SbjM1O4u0DwcUnYJT 0cD9T7XBV6IpjQxvZBdAUOBjButPqNlQjifZxkMPJUOwCU58LErgqX+GTo0sIeHOmr47 iVNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cazvcCWR; 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 dn10-20020a17090794ca00b0078b96722000si724525ejc.608.2022.10.02.12.36.13; Sun, 02 Oct 2022 12:36:39 -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=@nifty.com header.s=dec2015msa header.b=cazvcCWR; 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 S230130AbiJBSse (ORCPT + 99 others); Sun, 2 Oct 2022 14:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbiJBSsc (ORCPT ); Sun, 2 Oct 2022 14:48:32 -0400 Received: from conssluserg-01.nifty.com (conssluserg-01.nifty.com [210.131.2.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F6A92F022; Sun, 2 Oct 2022 11:48:30 -0700 (PDT) Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 292Im8lG008411; Mon, 3 Oct 2022 03:48:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 292Im8lG008411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664736489; bh=TRjUcYAKDUQUfOl2UzVa5Db91m2ohyT00gg0PveXTJw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cazvcCWRVaggUGDRHkSjgmGgbkC5Mc1zyB8gIqbwNm/CJKqG1RwJVo9tKr0+4kqy1 K/1v3k1Ua7Nrbnnx3FaKQ6N0LnrmcItK0O1QIbWSH0+/3KQBPPLQTHSvV2TueMn5WV TkJuTEzhxhss+KPcH8n1ZOPOCcXXWWtzXlZUfvayvzTrs09ZtlTAxHbv3/ItLm8L7A DtNEDM4Va6ldfeE1RzNY3UdwuHs8tTVoHDsnQLfy0+ATp9a6CC80qkQSHj7ISNUZnD 8kC0v+V9+k7Alfm90th2XK6qPDtLWRrJ/oRZyrpcXTqwKYwrj8ND5Pguec3Pqnusp9 XDpZoLnbHYM7Q== X-Nifty-SrcIP: [209.85.160.54] Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-1326637be6eso1155907fac.13; Sun, 02 Oct 2022 11:48:08 -0700 (PDT) X-Gm-Message-State: ACrzQf2vN6joKP8OVqgClonFzOBN5PsZRlc2Fs8s2PeojI6pnPVxY/V3 pKTPU0icKtgogOVHtnTw+eTez58/J71SQ7LIEi0= X-Received: by 2002:a05:6870:c58b:b0:10b:d21d:ad5e with SMTP id ba11-20020a056870c58b00b0010bd21dad5emr3514681oab.287.1664736487445; Sun, 02 Oct 2022 11:48:07 -0700 (PDT) MIME-Version: 1.0 References: <20220928182523.3105953-1-nathan@kernel.org> In-Reply-To: <20220928182523.3105953-1-nathan@kernel.org> From: Masahiro Yamada Date: Mon, 3 Oct 2022 03:47:30 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5 To: Nathan Chancellor 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 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. > + 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) 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? -- Best Regards Masahiro Yamada