Re: [PATCH] Kbuild: implement support for DWARF5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 1, 2020 at 6:21 PM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
>
> On Thu, Oct 22, 2020 at 10:21 AM 'Nick Desaulniers' via Clang Built
> Linux <clang-built-linux@xxxxxxxxxxxxxxxx> 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



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux