Bug 27400 - odr tests fail with -gdwarf-5
Summary: odr tests fail with -gdwarf-5
Status: RESOLVED FIXED
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-12 09:57 UTC by Mark Wielaard
Modified: 2021-02-14 21:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Tentative patch (946 bytes, patch)
2021-02-13 23:18 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2021-02-12 09:57:05 UTC
$ gcc --version
gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
Copyright (C) 2020 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.

$ as --version
GNU assembler version 2.35-18.fc33
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-redhat-linux'.

$ export CC="gcc -gdwarf-5" CXX="g++ -gdwarf-5"

$ make clean && make && make check

[...]
Running /home/mark/dwz/testsuite/dwz.tests/dwz-tests.exp ...
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-class-ns.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-class.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-def-decl.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-loc.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-struct-ns.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-struct.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-union-ns.sh
child process exited abnormally
FAIL: /home/mark/dwz/testsuite/dwz.tests/odr-union.sh

		=== dwz Summary ===

# of expected passes		51
# of unexpected failures	8
[...]

The same can be seen with gcc11 from git trunk which defaults to -gdwarf-5 (so you don't need any setting of CC or CXX).
Comment 1 Tom de Vries 2021-02-12 19:19:59 UTC
Ack, managed to reproduce, thanks.
Comment 2 Tom de Vries 2021-02-13 08:37:22 UTC
I've looked at the odr-struct.sh fail.

First of all, odr is not enabled because the language is DW_LANG_C_plus_plus_14 instead of DW_LANG_C_plus_plus, so we need this in a few places:
...
     case DW_LANG_C_plus_plus:
+    case DW_LANG_C_plus_plus_03:
+    case DW_LANG_C_plus_plus_11:
+    case DW_LANG_C_plus_plus_14:
...

Then, it seems the checksums for both struct aaa are different, because of processing a DW_AT_decl_line with DW_FORM_implicit_const.  The const has the same value (according to readelf), but somehow the resulting hashes are different.
Comment 3 Tom de Vries 2021-02-13 23:18:09 UTC
Created attachment 13224 [details]
Tentative patch
Comment 4 Tom de Vries 2021-02-14 08:07:29 UTC
(In reply to Tom de Vries from comment #2)
> I've looked at the odr-struct.sh fail.
> 
> First of all, odr is not enabled because the language is
> DW_LANG_C_plus_plus_14 instead of DW_LANG_C_plus_plus, so we need this in a
> few places:
> ...
>      case DW_LANG_C_plus_plus:
> +    case DW_LANG_C_plus_plus_03:
> +    case DW_LANG_C_plus_plus_11:
> +    case DW_LANG_C_plus_plus_14:
> ...
> 
Fix in https://sourceware.org/git/?p=dwz.git;a=commit;h=6d5673b84fa075d296d4ad4d60c03823cb773863