This version of gdb is broken when beeing compiled with -std=c++17 In file gdb/unittests/string_view-selftests.c you can read /* No need to test string_view if we're using C++17, since we're going to use the "real" version. */ #if __cplusplus < 201703L Therefore _initialize_string_view_selftests doesn't get defined. But the generated file gdb/init.c does invoke this, which gives a linker error. The following patch fixes this --- a/gdb/Makefile.in.ORIG 2019-03-12 02:49:16.000000000 +0100 +++ b/gdb/Makefile.in 2019-03-13 13:44:19.939962060 +0100 @@ -1870,6 +1870,9 @@ @sed -e 's/\(.*\)/ _initialize_\1 ();/' <init.l-tmp >>init.c-tmp @echo '}' >>init.c-tmp + @sed -i -e'/_initialize_string_view_selftests ();/i \ +#if __cplusplus < 201703L' -e'/_initialize_string_view_selftests ();/a \ +#endif' init.c-tmp @$(SHELL) $(srcdir)/../move-if-change init.c-tmp init.c @echo stamp > stamp-init .PRECIOUS: init.c
(In reply to Helmut Jarausch from comment #0) > This version of gdb is broken when being compiled with -std=c++17 Do you pass it explicitly to CXXFLAGS? Please provide a build.log.
Created attachment 569092 [details] build log xz-compressed
(In reply to Sergei Trofimovich from comment #1) > (In reply to Helmut Jarausch from comment #0) > > This version of gdb is broken when being compiled with -std=c++17 > > Do you pass it explicitly to CXXFLAGS? Please provide a build.log. Yes, I have CXXFLAGS="${CFLAGS} -std=c++17" in my make.conf file.
Created attachment 569106 [details, diff] gdb-c++17.patch Aha. gdb-c++17.patch should be slightly less invasive way to do it: always define a test and make it a no-op on new compilers. Can you elaborate why specifically you are using that flag explicitly? Given it's not a default language yet it has a chance of triggering unexpected problems in upstream code. -std= is different from optimization flags in a way that it changes language semantics slightly (new overloads, default operators and keywords). It is expected to break occasionally (as opposed to optimization-only flags which should not affect C++ semantics).
Posted the fix upstream as https://sourceware.org/ml/gdb-patches/2019-03/msg00306.html
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=890e99a6aef35c3e8c9a828bdf5ca9eafec6a1bb commit 890e99a6aef35c3e8c9a828bdf5ca9eafec6a1bb Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-03-14 22:49:20 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-03-14 22:49:37 +0000 sys-devel/gdb: fix build against -std=c++17 Patch is proposed upstream as: https://sourceware.org/ml/gdb-patches/2019-03/msg00306.html Reported-by: Helmut Jarausch Closes: https://bugs.gentoo.org/680232 Package-Manager: Portage-2.3.62, Repoman-2.3.12 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> sys-devel/gdb/files/gdb-8.3.50.20190312-c++17.patch | 19 +++++++++++++++++++ sys-devel/gdb/gdb-8.3.50.20190312-r1.ebuild | 1 + 2 files changed, 20 insertions(+)
Applied upstream as https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=58785d9888c699770154ef1d42fcea7598e8d704