Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp846071pxb; Tue, 3 Nov 2020 14:14:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJybqbApA/CNqyrZpVxH5FiPWeW2pgJEHzeM91bPSu4tgi1S8mBZeSZxEyHLSO6v7rhBg62y X-Received: by 2002:a17:906:c041:: with SMTP id bm1mr21700363ejb.202.1604441694051; Tue, 03 Nov 2020 14:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441694; cv=none; d=google.com; s=arc-20160816; b=Yf1LHx+LkRFOUicsRYH44rMt7+YDb+Q4u6yWI6CWg3SvcKittTTpJROz5p/6FZ/KIE stqwlFdoFDOmjvTFTE+cAsmet/0Gbz0bM6f/cFDp1oK5Zhlosing9myjD55n3i4hfTH6 rthEr6AtdkTJLRsaQxke3Wbs/7pBMgz5T6eXqvpQZOkBGNd4oxV0FakQPoAsX6Vx51JE MHo18SvBbeh7xeHanuvuD+jVhgl7va2kXBAZlL9+56oft9qmuS6aZWz1ehiSSoM459+W aDpMWYWZ7L1Dh3oEFD7v6Ucb8IXSdb/r0jipS7hGnoaZs8i7B7H2QigbviGRPyfIRGPV fg3A== 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; bh=zwwyyZlsxtPwtkYdyrHXKpl0bLG1w1dXTG/u61TKkGA=; b=gflRKFfno7aGcDWSgDLwCyv+MxvjHZ8q1kShLiSpfJKclr+Ffxjab88eHxc+lKY+5T UqUik15DHaO/ad0FXh69GhAWYShty9mSYx0Eg6qBueq6LWKR0CzU655Vt+MSuRw1p5lE 1SS895as5oSHF18D+mHZh/FoV32gr3/yEQ3dvD8LjMBihXVAEhka45LLLvSKJaZu1R5U RqAfkBTNhcdcTq8IY2EKZ3FBi1fmmOafROTnB7FQpa10FUon8Zo5CIpu7ToktxO0GdS4 LqBYyFhYwNflXvBumzlOLKUjXOAxu6yVuv9bGeR1zYqT0srMwRSvAOquEsjvatZKU1FA ShBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="F/BOrbHN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs18si119802ejb.162.2020.11.03.14.14.29; Tue, 03 Nov 2020 14:14:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="F/BOrbHN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbgKCWNQ (ORCPT + 99 others); Tue, 3 Nov 2020 17:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbgKCWNP (ORCPT ); Tue, 3 Nov 2020 17:13:15 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749B8C061A04 for ; Tue, 3 Nov 2020 14:13:15 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id z24so14816764pgk.3 for ; Tue, 03 Nov 2020 14:13:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zwwyyZlsxtPwtkYdyrHXKpl0bLG1w1dXTG/u61TKkGA=; b=F/BOrbHN3ThwMUapjDBheSHLcKAGpUy6Fi0cQZ3GILWIaHyiysO/ujlkbPJcgcbjh0 w6E+DHNJAHoizgUEehefyU1cf6wrED2iZyv+iY8CIaeCaIhRwQidQe3xkaaPP+KI22hb u8BIUatkMIHsDa4wAq1pyRIKBSD+s2JOsZ4OPT33horuipKp+MR/aX7ZS9SqAZwkQiVI i0j5z5zhMaezpCSA7Uf+3lB6K16LNpOglV9wAGyvXII29N96oPEAX2IRWkbCYC8ZYt2z /wIf39FAFL+Ihzou81o1Iof1oH/2ytzjixHpsImGN7qELA0A/ZhGHKhm8+tW7i3yryhP 4beg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zwwyyZlsxtPwtkYdyrHXKpl0bLG1w1dXTG/u61TKkGA=; b=kyF6LsUhUvOxFHe1Nt1MmDWLd6j4KDv3kt5gX5OR/MSiFuAIGYqhJ6cDc11lP7WLTn xFd/vVCn8S/EkMl8JofM7i1eAgix6lxZwX9w31eQJmdBUkhwhisx321rrmpgQLpJHKiK qfG2wgGZaxn9ou4pkCMALEIPxAaot2lLQVsdC0WFkQBPNTTn4+fMBEFoDfQ7nlCtFbM6 WkAEsjdoa2GQhUA1bzDsA3V/3nf0JfZQ/uhuZ5ihD31EZjoY70fA7GwNluZWYArWc/9D 82UDfHbn1shaIdpS/xTFu+jhbqF01WOFHqkWLIC/IHRbGCVn43f4RipiStr9uxaefiKW 1cig== X-Gm-Message-State: AOAM532DV85nZu4Zqwquik00J+f7HZk+Jqv/sxRG0CfGgWt58vvDzwPn hE6z7cB9fHwSVNarE5ysdXXmRlosIWZfLlrc2wM2Fw== X-Received: by 2002:aa7:9a04:0:b029:163:fe2a:9e04 with SMTP id w4-20020aa79a040000b0290163fe2a9e04mr28701717pfj.30.1604441594716; Tue, 03 Nov 2020 14:13:14 -0800 (PST) MIME-Version: 1.0 References: <20201022012106.1875129-1-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 3 Nov 2020 14:13:03 -0800 Message-ID: Subject: Re: [PATCH] Kbuild: implement support for DWARF5 To: Masahiro Yamada Cc: Linux Kbuild mailing list , Linux Kernel Mailing List , clang-built-linux , linux-toolchains@vger.kernel.org, Jakub Jelinek , Alistair Delva , Nick Clifton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 1, 2020 at 6:21 PM Masahiro Yamada wrote: > > On Thu, Oct 22, 2020 at 10:21 AM 'Nick Desaulniers' via Clang Built > Linux wrote: > > > > diff --git a/scripts/test_dwarf5_support.sh b/scripts/test_dwarf5_support.sh > > new file mode 100755 > > index 000000000000..82c0eea45845 > > --- /dev/null > > +++ b/scripts/test_dwarf5_support.sh > > @@ -0,0 +1,4 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > +set -eu > > +echo ".file 0 \"asdf\"" | $* -Wa,-gdwarf-5 -c -x assembler -o /dev/null - > > > > Please tell me how this script detects the dwarf-5 capability. Ah, sorry, I should have put more context. Specifically, I wrote this patch initially back in May, but testing combinations of: - GCC + GNU as - Clang + GNU as - Clang + LLVM_IAS I hit a few snags in GNU as. I reported the issues, and they were quickly fixed. The fixes shipped in binutils 2.35 (or 2.35.1 as Jakub notes). https://sourceware.org/bugzilla/show_bug.cgi?id=25611 https://sourceware.org/bugzilla/show_bug.cgi?id=25612 https://sourceware.org/bugzilla/show_bug.cgi?id=25614 <-- .file 0 https://sourceware.org/bugzilla/show_bug.cgi?id=25917 This script is doing feature detection of `.file 0` directives (which is new in DWARF5) in the assembler and actively emitted by Clang. I'm happy to add whatever other unit tests might be interesting for detecting correct support for various features, if we find them to be required, which I'd say `.file 0` certainly is. Probably could test GCC + LLVM_IAS, too. Hence we need to test compiler and assembler support; either may be lacking. > This script fails for GCC 10. What is your version of binutils? Less than 2.35 I suspect? If so, then that's expected and the script is working as intended. Thanks for your feedback, I'll try to get a v2 out this week incorporating feedback from you, Fangrui, and Jakub. > > > masahiro@grover:~/workspace/linux-kbuild$ > ./scripts/test_dwarf5_support.sh clang > masahiro@grover:~/workspace/linux-kbuild$ echo $? > 0 > masahiro@grover:~/workspace/linux-kbuild$ > ./scripts/test_dwarf5_support.sh gcc-10 > {standard input}: Assembler messages: > {standard input}:1: Error: file number less than one > masahiro@grover:~/workspace/linux-kbuild$ echo $? > 1 > > > > > The manual says the fileno should be "a positive integer". > > > .file fileno filename > > When emitting dwarf2 line number information .file assigns filenames > to the .debug_line file name table. > The fileno operand should be a unique positive integer to use as the > index of the entry in the table. > The filename operand is a C string literal. > > The detail of filename indices is exposed to the user because the > filename table is shared with the > .debug_info section of the dwarf2 debugging information, and thus > the user must know the exact indices > that table entries will have. > > > > So, I modified the script as follows: > > > masahiro@grover:~/workspace/linux-kbuild$ git diff > diff --git a/scripts/test_dwarf5_support.sh b/scripts/test_dwarf5_support.sh > index 82c0eea45845..8d7213e8e51f 100755 > --- a/scripts/test_dwarf5_support.sh > +++ b/scripts/test_dwarf5_support.sh > @@ -1,4 +1,4 @@ > #!/bin/sh > # SPDX-License-Identifier: GPL-2.0 > set -eu > -echo ".file 0 \"asdf\"" | $* -Wa,-gdwarf-5 -c -x assembler -o /dev/null - > +echo ".file 1 \"asdf\"" | $* -Wa,-gdwarf-5 -c -x assembler -o /dev/null - > > > > > masahiro@grover:~/workspace/linux-kbuild$ ./scripts/test_dwarf5_support.sh gcc > masahiro@grover:~/workspace/linux-kbuild$ echo $? > 0 > > > > But, GCC 4.9 also passes this check. > > masahiro@grover:~/workspace/linux-kbuild$ > ~/tools/aarch64-linaro-4.9/bin/aarch64-linux-gnu-gcc --version > aarch64-linux-gnu-gcc (Linaro GCC 4.9-2016.02) 4.9.4 20151028 (prerelease) > Copyright (C) 2015 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > masahiro@grover:~/workspace/linux-kbuild$ > ./scripts/test_dwarf5_support.sh > ~/tools/aarch64-linaro-4.9/bin/aarch64-linux-gnu-gcc > masahiro@grover:~/workspace/linux-kbuild$ echo $? > 0 -- Thanks, ~Nick Desaulniers