Bug 24835 - powerpc build breaker with Werror=odr
Summary: powerpc build breaker with Werror=odr
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: build (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 13.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 22395
  Show dependency treegraph
 
Reported: 2019-07-22 16:35 UTC by Tom de Vries
Modified: 2022-11-11 05:31 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2019-07-22 16:35:15 UTC
With a ppc64 build, I run into a build breaker due to an ODR violation:
...
[ 1304s] ../../../gdb/gdbserver/../arch/ppc-linux-tdesc.h:45:28: error: 'tdesc_powerpc_isa207_vsx64l' violates the C++ One Definition Rule [-Werror=odr]
[ 1304s]    45 | extern struct target_desc *tdesc_powerpc_isa207_vsx64l;
[ 1304s]       |                            ^
[ 1304s] powerpc-isa207-vsx64l-generated.c:27:27: note: 'tdesc_powerpc_isa207_vsx64l' was previously declared here
[ 1304s]    27 | const struct target_desc *tdesc_powerpc_isa207_vsx64l;
...

The problem is that regdat.sh generates *tdesc_${name} using const:
...
    echo "const struct target_desc *tdesc_${name};"
...
while ppc-linux-tdesc.h declares it without const.
Comment 1 Tom Tromey 2022-02-27 23:07:20 UTC
Is it enough to just remove that 'const' from regdat.sh?
That seems like an unobjectionable patch to me.
Comment 2 Keith Seitz 2022-07-30 01:27:47 UTC
(In reply to Tom Tromey from comment #1)
> Is it enough to just remove that 'const' from regdat.sh?
> That seems like an unobjectionable patch to me.

It is enough to get PowerPC building again. The question is,
would we rather change everything to 'const' instead? While
noticeably less trivial, it does work. [Tested on x86_64,
aarch64, ppc64le, s390x rawhide scratch-builds enabling LTO.]
Comment 3 Tom Tromey 2022-09-09 00:56:03 UTC
See also the generic ODR bug.
I don't recall what other violations I knew about when
I commented there, but I assume I just did a build with
LTO and -Wodr.
Comment 4 Tom Tromey 2022-09-09 00:56:57 UTC
(In reply to Keith Seitz from comment #2)
> (In reply to Tom Tromey from comment #1)
> > Is it enough to just remove that 'const' from regdat.sh?
> > That seems like an unobjectionable patch to me.
> 
> It is enough to get PowerPC building again. The question is,
> would we rather change everything to 'const' instead? 

If they are truly unchanging then it definitely seems better.
Comment 5 Tom Tromey 2022-11-10 22:09:46 UTC
I think this was fixed by 

commit ac9b8c676e9f52c5238bbc61a2cdd27e3d59db10
Author: Keith Seitz <keiths@redhat.com>
Date:   Fri Sep 9 08:44:50 2022 -0700

    Constify target_desc declarations