* [PATCH][gdb] Fix build breaker with gcc 4.8 @ 2019-06-19 11:04 Tom de Vries 2019-06-19 12:43 ` Pedro Alves 2019-06-19 14:56 ` Steve Ellcey 0 siblings, 2 replies; 6+ messages in thread From: Tom de Vries @ 2019-06-19 11:04 UTC (permalink / raw) To: gdb-patches Hi, When compiling with gcc 4.8, we run into: ... /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \ âclass std::unordered_map<sect_offset, std::vector<sect_offset> >â src/gdb/dwarf2read.h:260:5: required from here /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \ incomplete type âstruct std::hash<sect_offset>â ... Fix this by adding std::hash<sect_offset>. Build and reg-tested on x86_64-linux with gcc 4.8. OK for trunk? Thanks, - Tom [gdb] Fix build breaker with gcc 4.8 gdb/ChangeLog: 2019-06-19 Tom de Vries <tdevries@suse.de> * dwarf2read.h (std::hash<sect_offset>): New specialization. --- gdb/dwarf2read.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 776860e454..494dcb32c1 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -99,6 +99,26 @@ struct signatured_type; struct die_info; typedef struct die_info *die_info_ptr; +/* An std::hash specialization, required for use of sect_offset in + std::unordered_map with gcc 4.8. */ + +namespace std +{ + template<> struct hash<sect_offset> + { + typedef sect_offset argument_type; + typedef std::size_t result_type; + using underlying_type + = typename std::underlying_type<argument_type>::type; + + result_type operator() (const argument_type &o) const noexcept + { + underlying_type u = static_cast<underlying_type> (o); + return std::hash<underlying_type> {} (u); + } + }; +}; + /* Collection of data recorded per objfile. This hangs off of dwarf2_objfile_data_key. */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][gdb] Fix build breaker with gcc 4.8 2019-06-19 11:04 [PATCH][gdb] Fix build breaker with gcc 4.8 Tom de Vries @ 2019-06-19 12:43 ` Pedro Alves 2019-06-19 14:35 ` Tom de Vries 2019-06-19 14:56 ` Steve Ellcey 1 sibling, 1 reply; 6+ messages in thread From: Pedro Alves @ 2019-06-19 12:43 UTC (permalink / raw) To: Tom de Vries, gdb-patches On 6/19/19 12:04 PM, Tom de Vries wrote: > Hi, > > When compiling with gcc 4.8, we run into: > ... > /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \ > âclass std::unordered_map<sect_offset, std::vector<sect_offset> >â > src/gdb/dwarf2read.h:260:5: required from here > /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \ > incomplete type âstruct std::hash<sect_offset>â > ... > > Fix this by adding std::hash<sect_offset>. > > Build and reg-tested on x86_64-linux with gcc 4.8. > > OK for trunk? > hash_enum was added for this: https://sourceware.org/ml/gdb-patches/2017-12/msg00210.html Can you use it here? It's currently used in dwarf2read.c, here: std::unordered_map<sect_offset, dwarf2_per_cu_data *, gdb::hash_enum<sect_offset>> Thanks, Pedro Alves > Thanks, > - Tom > > [gdb] Fix build breaker with gcc 4.8 > > gdb/ChangeLog: > > 2019-06-19 Tom de Vries <tdevries@suse.de> > > * dwarf2read.h (std::hash<sect_offset>): New specialization. > > --- > gdb/dwarf2read.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h > index 776860e454..494dcb32c1 100644 > --- a/gdb/dwarf2read.h > +++ b/gdb/dwarf2read.h > @@ -99,6 +99,26 @@ struct signatured_type; > struct die_info; > typedef struct die_info *die_info_ptr; > > +/* An std::hash specialization, required for use of sect_offset in > + std::unordered_map with gcc 4.8. */ > + > +namespace std > +{ > + template<> struct hash<sect_offset> > + { > + typedef sect_offset argument_type; > + typedef std::size_t result_type; > + using underlying_type > + = typename std::underlying_type<argument_type>::type; > + > + result_type operator() (const argument_type &o) const noexcept > + { > + underlying_type u = static_cast<underlying_type> (o); > + return std::hash<underlying_type> {} (u); > + } > + }; > +}; > + > /* Collection of data recorded per objfile. > This hangs off of dwarf2_objfile_data_key. */ > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][gdb] Fix build breaker with gcc 4.8 2019-06-19 12:43 ` Pedro Alves @ 2019-06-19 14:35 ` Tom de Vries 2019-06-19 14:49 ` Pedro Alves 0 siblings, 1 reply; 6+ messages in thread From: Tom de Vries @ 2019-06-19 14:35 UTC (permalink / raw) To: Pedro Alves, gdb-patches [-- Attachment #1: Type: text/plain, Size: 969 bytes --] On 19-06-19 14:43, Pedro Alves wrote: > On 6/19/19 12:04 PM, Tom de Vries wrote: >> Hi, >> >> When compiling with gcc 4.8, we run into: >> ... >> /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \ >> âclass std::unordered_map<sect_offset, std::vector<sect_offset> >â >> src/gdb/dwarf2read.h:260:5: required from here >> /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \ >> incomplete type âstruct std::hash<sect_offset>â >> ... >> >> Fix this by adding std::hash<sect_offset>. >> >> Build and reg-tested on x86_64-linux with gcc 4.8. >> >> OK for trunk? >> > > hash_enum was added for this: > > https://sourceware.org/ml/gdb-patches/2017-12/msg00210.html > > Can you use it here? > > It's currently used in dwarf2read.c, here: > > std::unordered_map<sect_offset, > dwarf2_per_cu_data *, > gdb::hash_enum<sect_offset>> > Yes, that works for me. OK for trunk? Thanks, - Tom [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-gdb-Fix-build-breaker-with-gcc-4.8.patch --] [-- Type: text/x-patch; name="0001-gdb-Fix-build-breaker-with-gcc-4.8.patch", Size: 1633 bytes --] [gdb] Fix build breaker with gcc 4.8 When compiling with gcc 4.8, we run into: ... /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \ âclass std::unordered_map<sect_offset, std::vector<sect_offset> >â src/gdb/dwarf2read.h:260:5: required from here /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \ incomplete type âstruct std::hash<sect_offset>â ... Fix this by setting the Hash template parameter of the unordered_map to gdb::hash_enum<sect_offset>, rather than using the default std::hash<sect_offset>. Build and reg-tested on x86_64-linux with gcc 4.8. gdb/ChangeLog: 2019-06-19 Tom de Vries <tdevries@suse.de> * dwarf2read.h (abstract_to_concrete): Change type to std::unordered_map<sect_offset, std::vector<sect_offset>, gdb::hash_enum<sect_offset>>. --- gdb/dwarf2read.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 776860e454..7113cfd384 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -24,6 +24,7 @@ #include "dwarf-index-cache.h" #include "filename-seen-cache.h" #include "gdb_obstack.h" +#include "common/hash_enum.h" /* Hold 'maintenance (set|show) dwarf' commands. */ extern struct cmd_list_element *set_dwarf_cmdlist; @@ -256,7 +257,8 @@ public: /* Mapping from abstract origin DIE to concrete DIEs that reference it as DW_AT_abstract_origin. */ - std::unordered_map<sect_offset, std::vector<sect_offset>> + std::unordered_map<sect_offset, std::vector<sect_offset>, \ + gdb::hash_enum<sect_offset>> \ abstract_to_concrete; }; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][gdb] Fix build breaker with gcc 4.8 2019-06-19 14:35 ` Tom de Vries @ 2019-06-19 14:49 ` Pedro Alves 0 siblings, 0 replies; 6+ messages in thread From: Pedro Alves @ 2019-06-19 14:49 UTC (permalink / raw) To: Tom de Vries, gdb-patches On 6/19/19 3:35 PM, Tom de Vries wrote: > OK for trunk? > OK. Thanks, Pedro Alves ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][gdb] Fix build breaker with gcc 4.8 2019-06-19 11:04 [PATCH][gdb] Fix build breaker with gcc 4.8 Tom de Vries 2019-06-19 12:43 ` Pedro Alves @ 2019-06-19 14:56 ` Steve Ellcey [not found] ` <0cedb79e-1423-90d8-0c61-1386f398ab20@suse.de> 1 sibling, 1 reply; 6+ messages in thread From: Steve Ellcey @ 2019-06-19 14:56 UTC (permalink / raw) To: gdb-patches, tdevries On Wed, 2019-06-19 at 13:04 +0200, Tom de Vries wrote: > > [gdb] Fix build breaker with gcc 4.8 > > gdb/ChangeLog: > > 2019-06-19 Tom de Vries <tdevries@suse.de> > > * dwarf2read.h (std::hash<sect_offset>): New specialization. I think this might have broken the GDB build with GCC 5.4. My gdb/binutils build using the latest sources is dying with the following message. I am building on Ubuntu 18.04 and the installed GCC 5.4 compiler. I haven't seen any errors from the buildbot, maybe that is using GCC 4.8? Error: In file included from /usr/include/c++/5/bits/hashtable.h:35:0, from /usr/include/c++/5/unordered_map:47, from /home/sellcey/tot/src/binutils- gdb/gdb/dwarf2read.h:23, from /home/sellcey/tot/src/binutils-gdb/gdb/dwarf- index-write.h:24, from /home/sellcey/tot/src/binutils-gdb/gdb/dwarf- index-cache.c:28: /usr/include/c++/5/bits/hashtable_policy.h: In instantiation of ‘struct std::__detail::__is_noexcept_hash<sect_offset, std::hash<sect_offset> >’: /usr/include/c++/5/type_traits:137:12: required from ‘struct std::__and_<std::__is_fast_hash<std::hash<sect_offset> >, std::__detail::__is_noexcept_hash<sect_offset, std::hash<sect_offset> > >’ /usr/include/c++/5/type_traits:148:38: required from ‘struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<sect_offset> >, std::__detail::__is_noexcept_hash<sect_offset, std::hash<sect_offset> > > >’ (etc, etc, etc) ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <0cedb79e-1423-90d8-0c61-1386f398ab20@suse.de>]
* Re: [EXT] Re: [PATCH][gdb] Fix build breaker with gcc 4.8 [not found] ` <0cedb79e-1423-90d8-0c61-1386f398ab20@suse.de> @ 2019-06-19 15:14 ` Steve Ellcey 0 siblings, 0 replies; 6+ messages in thread From: Steve Ellcey @ 2019-06-19 15:14 UTC (permalink / raw) To: gdb-patches, tdevries [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="utf-8", Size: 315 bytes --] On Wed, 2019-06-19 at 17:00 +0200, Tom de Vries wrote: > > > I think you're running into the same build breaker as me, for which I > just pushed a fix (and not this one). > > Thanks, > - Tom Yes, that patch fixes my build. Thanks. Steve Ellcey sellcey@marvell.com \x16º&Öéj×!zÊÞ¶êç×½ÓÙb²Ö«r\x18\x1dnr\x17¬ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-06-19 15:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 11:04 [PATCH][gdb] Fix build breaker with gcc 4.8 Tom de Vries
2019-06-19 12:43 ` Pedro Alves
2019-06-19 14:35 ` Tom de Vries
2019-06-19 14:49 ` Pedro Alves
2019-06-19 14:56 ` Steve Ellcey
[not found] ` <0cedb79e-1423-90d8-0c61-1386f398ab20@suse.de>
2019-06-19 15:14 ` [EXT] " Steve Ellcey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox